mirror of
https://github.com/Chewbaccalakis/rfid-database.git
synced 2026-09-10 00:11:56 -07:00
Fix OIDC email: load Authelia profile from UserInfo
Auth.js OIDC only reads ID-token claims by default; Authelia puts email on UserInfo. Set idToken:false, harden claim extraction, and document an optional Authelia claims_policy.
This commit is contained in:
@@ -5,3 +5,23 @@ export function isOidcConfigured(): boolean {
|
||||
process.env.AUTH_OIDC_CLIENT_SECRET?.trim()
|
||||
);
|
||||
}
|
||||
|
||||
/** Pull an email out of common OIDC claim shapes (Authelia, Keycloak, etc.). */
|
||||
export function emailFromOidcProfile(
|
||||
profile: Record<string, unknown>
|
||||
): string | null {
|
||||
const candidates = [
|
||||
profile.email,
|
||||
profile.preferred_username,
|
||||
profile.upn,
|
||||
profile.mail,
|
||||
(profile.user as { email?: unknown } | undefined)?.email,
|
||||
];
|
||||
|
||||
for (const value of candidates) {
|
||||
if (typeof value !== "string") continue;
|
||||
const trimmed = value.trim();
|
||||
if (trimmed.includes("@")) return trimmed.toLowerCase();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user