From 2aed3df2c9f2623f07654bf02ed9ba0cde52f5e5 Mon Sep 17 00:00:00 2001 From: chicoribas Date: Mon, 12 Jul 2021 11:46:01 -0300 Subject: [PATCH] Simpler microsoftDefaultSignInResolver Signed-off-by: chicoribas --- .../src/providers/microsoft/provider.ts | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/plugins/auth-backend/src/providers/microsoft/provider.ts b/plugins/auth-backend/src/providers/microsoft/provider.ts index f97512cda5..633844a351 100644 --- a/plugins/auth-backend/src/providers/microsoft/provider.ts +++ b/plugins/auth-backend/src/providers/microsoft/provider.ts @@ -154,10 +154,6 @@ export class MicrosoftAuthProvider implements OAuthHandlers { profile, }; - if (!profile.email) { - throw new Error('Microsoft profile contained no email'); - } - if (this.signInResolver) { response.backstageIdentity = await this.signInResolver( { @@ -234,20 +230,7 @@ export const microsoftDefaultSignInResolver: SignInResolver = async throw new Error('Profile contained no email'); } - let userId: string; - try { - const entity = await ctx.catalogIdentityClient.findUser({ - annotations: { - 'microsoft.com/email': profile.email, - }, - }); - userId = entity.metadata.name; - } catch (error) { - ctx.logger.warn( - `Failed to look up user, ${error}, falling back to allowing login based on email pattern, this will probably break in the future`, - ); - userId = profile.email.split('@')[0]; - } + const userId = profile.email.split('@')[0]; const token = await ctx.tokenIssuer.issueToken({ claims: { sub: userId, ent: [`user:default/${userId}`] },