PR Feedback

* Tidy up passing of domain hint from initalisation to later methods
* Tidy up change set

Signed-off-by: Alex Crome <afscrome@users.noreply.github.com>
This commit is contained in:
Alex Crome
2023-10-25 21:49:23 +01:00
parent 3979524c74
commit d7def5d0cb
2 changed files with 17 additions and 25 deletions
+2 -13
View File
@@ -1,16 +1,5 @@
---
'@backstage/plugin-auth-backend-module-microsoft-provider': minor
'@backstage/plugin-auth-backend-module-microsoft-provider': patch
---
Added support for specifying a `domain_hint` on Microsoft authentication provider configuration.
This should typically be set to the same value as your `tenantId`.
If you allow users from multiple tenants to authenticate, then leave this blank.
```yaml
auth:
providers:
microsoft:
development:
#...
domainHint: ${AZURE_TENANT_ID}
```
Added support for specifying a domain hint on the Microsoft authentication provider configuration.
@@ -22,8 +22,6 @@ import {
PassportProfile,
} from '@backstage/plugin-auth-node';
let domainHint: string | undefined = undefined;
/** @public */
export const microsoftAuthenticator = createOAuthAuthenticator({
defaultProfileTransform:
@@ -32,9 +30,9 @@ export const microsoftAuthenticator = createOAuthAuthenticator({
const clientId = config.getString('clientId');
const clientSecret = config.getString('clientSecret');
const tenantId = config.getString('tenantId');
domainHint = config.getOptionalString('domainHint');
const domainHint = config.getOptionalString('domainHint');
return PassportOAuthAuthenticatorHelper.from(
const helper = PassportOAuthAuthenticatorHelper.from(
new MicrosoftStrategy(
{
clientID: clientId,
@@ -58,25 +56,30 @@ export const microsoftAuthenticator = createOAuthAuthenticator({
},
),
);
return {
helper,
domainHint,
};
},
async start(input, helper) {
async start(input, ctx) {
const options: Record<string, string> = {
accessType: 'offline',
};
if (domainHint !== undefined) {
options.domain_hint = domainHint;
if (ctx.domainHint !== undefined) {
options.domain_hint = ctx.domainHint;
}
return helper.start(input, options);
return ctx.helper.start(input, options);
},
async authenticate(input, helper) {
return helper.authenticate(input);
async authenticate(input, ctx) {
return ctx.helper.authenticate(input);
},
async refresh(input, helper) {
return helper.refresh(input);
async refresh(input, ctx) {
return ctx.helper.refresh(input);
},
});