chore: improve oidc provider support

Adds fields to the Account model to support various pieces
of data returned by OIDC providers such as AzureAD and GitLab.

Additionally passes through the email verification status and handles
retrieving the email for providers such as AzureAD who use a different
claim instead.
This commit is contained in:
Mythie
2024-05-30 22:15:45 +10:00
parent d8d0734680
commit 70eeb1a746
3 changed files with 16 additions and 4 deletions

View File

@ -139,19 +139,24 @@ export const NEXT_AUTH_OPTIONS: AuthOptions = {
{
id: 'oidc',
name: 'OIDC',
type: 'oauth',
wellKnown: process.env.NEXT_PRIVATE_OIDC_WELL_KNOWN,
clientId: process.env.NEXT_PRIVATE_OIDC_CLIENT_ID,
clientSecret: process.env.NEXT_PRIVATE_OIDC_CLIENT_SECRET,
authorization: { params: { scope: 'openid email profile' } },
idToken: true,
checks: ['pkce', 'state'],
type: 'oauth',
idToken: true,
allowDangerousEmailAccountLinking: true,
profile(profile) {
return {
id: Number(profile.sub),
email: profile.email,
id: profile.sub,
email: profile.email || profile.preferred_username,
name: profile.name || `${profile.given_name} ${profile.family_name}`.trim(),
emailVerified: profile.email_verified ? new Date().toISOString() : null,
};
},
},