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:
Alex Crome
2024-02-19 15:07:42 +00:00
parent 8d77d00733
commit a0b01eda2c
3 changed files with 4 additions and 12 deletions
+1 -1
View File
@@ -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,
),
});