From 821c9368f6e633174a5c3e5b6d105159e02e8f4d Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 12 Apr 2023 21:59:24 -0400 Subject: [PATCH] fix: profile.name is not mandatory anymore in OIDC provder --- plugins/oidc/server/auth/oidc.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/oidc/server/auth/oidc.ts b/plugins/oidc/server/auth/oidc.ts index 9a6de60d4..55c8234ed 100644 --- a/plugins/oidc/server/auth/oidc.ts +++ b/plugins/oidc/server/auth/oidc.ts @@ -94,11 +94,6 @@ if ( `An email field was not returned in the profile parameter, but is required.` ); } - if (!profile.name) { - throw AuthenticationError( - `A name field was not returned in the profile parameter, but is required.` - ); - } const team = await getTeamFromContext(ctx); const client = getClientFromContext(ctx); @@ -115,6 +110,13 @@ if ( // Claim name can be overriden using an env variable. // Default is 'preferred_username' as per OIDC spec. const username = get(profile, env.OIDC_USERNAME_CLAIM); + const name = profile.name || username || profile.username; + + if (!name) { + throw AuthenticationError( + `Neither a name or username was returned in the profile parameter, but at least one is required.` + ); + } const result = await accountProvisioner({ ip: ctx.ip, @@ -126,7 +128,7 @@ if ( subdomain, }, user: { - name: profile.name || username || profile.username, + name, email: profile.email, avatarUrl: profile.picture, },