Moved defence against null tokens into defaultProfileTransform to apply more broadly than just Microsoft tokens.
Signed-off-by: Alex Crome <afscrome@users.noreply.github.com>
This commit is contained in:
@@ -2,4 +2,4 @@
|
||||
'@backstage/plugin-auth-backend-module-microsoft-provider': patch
|
||||
---
|
||||
|
||||
Fix error when Microsoft token is requested without the profile scope.
|
||||
Fix error when Microsoft tokens (or any other using the `defaultProfileTransform`) are requested without the profile scope.
|
||||
|
||||
@@ -26,16 +26,8 @@ import { union } from 'lodash';
|
||||
|
||||
/** @public */
|
||||
export const microsoftAuthenticator = createOAuthAuthenticator({
|
||||
defaultProfileTransform: (
|
||||
result: OAuthAuthenticatorResult<PassportProfile>,
|
||||
context,
|
||||
) => {
|
||||
result.fullProfile = result.fullProfile ?? {};
|
||||
return PassportOAuthAuthenticatorHelper.defaultProfileTransform(
|
||||
result,
|
||||
context,
|
||||
);
|
||||
},
|
||||
defaultProfileTransform:
|
||||
PassportOAuthAuthenticatorHelper.defaultProfileTransform,
|
||||
initialize({ callbackUrl, config }) {
|
||||
const clientId = config.getString('clientId');
|
||||
const clientSecret = config.getString('clientSecret');
|
||||
|
||||
@@ -57,7 +57,7 @@ export class PassportOAuthAuthenticatorHelper {
|
||||
OAuthAuthenticatorResult<PassportProfile>
|
||||
> = async input => ({
|
||||
profile: PassportHelpers.transformProfile(
|
||||
input.fullProfile,
|
||||
input.fullProfile ?? {},
|
||||
input.session.idToken,
|
||||
),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user