From 159e107ab33b41565d0e275ba98408bf8a8990c9 Mon Sep 17 00:00:00 2001 From: Pepijn Schildkamp Date: Wed, 25 Aug 2021 16:07:48 +0200 Subject: [PATCH] Simplified default sign-in resolver to split on e-mail address Signed-off-by: Pepijn Schildkamp --- .../src/providers/oauth2/provider.ts | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/plugins/auth-backend/src/providers/oauth2/provider.ts b/plugins/auth-backend/src/providers/oauth2/provider.ts index 2f22411154..fc315a69ca 100644 --- a/plugins/auth-backend/src/providers/oauth2/provider.ts +++ b/plugins/auth-backend/src/providers/oauth2/provider.ts @@ -200,7 +200,7 @@ export const oAuth2EmailSignInResolver: SignInResolver = async ( const entity = await ctx.catalogIdentityClient.findUser({ annotations: { - 'oauth2/email': profile.email, + 'backstage.io/email': profile.email, }, }); @@ -220,21 +220,7 @@ export const oAuth2DefaultSignInResolver: SignInResolver = async ( throw new Error('Profile contained no email'); } - let userId: string; - - try { - const entity = await ctx.catalogIdentityClient.findUser({ - annotations: { - 'oauth2/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}`] },