Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#174947061] Externalize token name attribute #88

Merged
merged 1 commit into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions GetUser/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function GetUserHandler(
adb2cCredentials: IServicePrincipalCreds,
servicePrincipalCreds: IServicePrincipalCreds,
azureApimConfig: IAzureApimConfig,
adb2cExtensionAppClientId: NonEmptyString
adb2cTokenAttributeName: NonEmptyString
): IGetSubscriptionKeysHandler {
return async (context, _, email) => {
const internalErrorHandler = (errorMessage: string, error: Error) =>
Expand Down Expand Up @@ -217,8 +217,7 @@ export function GetUserHandler(
.map(adb2User => {
return {
...taskResults,
token_name:
adb2User[`extension_${adb2cExtensionAppClientId}_token_name`]
token_name: adb2User[`${adb2cTokenAttributeName}`]
};
})
)
Expand Down Expand Up @@ -270,13 +269,13 @@ export function GetUser(
adb2cCredentials: IServicePrincipalCreds,
servicePrincipalCreds: IServicePrincipalCreds,
azureApimConfig: IAzureApimConfig,
adb2cExtensionAppClientId: NonEmptyString
adb2cTokenAttributeName: NonEmptyString
): express.RequestHandler {
const handler = GetUserHandler(
adb2cCredentials,
servicePrincipalCreds,
azureApimConfig,
adb2cExtensionAppClientId
adb2cTokenAttributeName
);

const middlewaresWrap = withRequestMiddlewares(
Expand Down
6 changes: 3 additions & 3 deletions GetUser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const azureApimConfig = {
subscriptionId: getRequiredStringEnv("AZURE_SUBSCRIPTION_ID")
};

const adb2cExtensionAppClientId = getRequiredStringEnv(
"ADB2C_EXTENSION_APP_CLIENT_ID"
const adb2cTokenAttributeName = getRequiredStringEnv(
"ADB2C_TOKEN_ATTRIBUTE_NAME"
);

// tslint:disable-next-line: no-let
Expand All @@ -50,7 +50,7 @@ app.get(
adb2cCreds,
servicePrincipalCreds,
azureApimConfig,
adb2cExtensionAppClientId
adb2cTokenAttributeName
)
);

Expand Down
2 changes: 1 addition & 1 deletion env.example
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ COSMOSDB_NAME=<COSMOSDB_NAME>
ADB2C_CLIENT_ID=1
ADB2C_CLIENT_KEY=1
ADB2C_TENANT_ID=1
ADB2C_EXTENSION_APP_CLIENT_ID=1
ADB2C_TOKEN_ATTRIBUTE_NAME=extension_attribute_name
SERVICE_PRINCIPAL_CLIENT_ID=1
SERVICE_PRINCIPAL_SECRET=1
SERVICE_PRINCIPAL_TENANT_ID=1
Expand Down