fix(auth): require verified OIDC email for linking
This commit is contained in:
1 parent
00a65bfc58
commit
181850f77f
5 files changed
+37
-2
No files matched your search
@@ -7,6 +7,7 @@ import { fetchWithTrustedCertificatesAsync } from "@homarr/core/infrastructure/h
|
||||
|
||||
import { env } from "../../env";
|
||||
import { createRedirectUri } from "../../redirect";
|
||||
import { assertVerifiedEmailForCredentialsLinking } from "./verified-email";
|
||||
|
||||
export const OidcProvider = (headers: ReadonlyHeaders | null): OIDCConfig<Profile> => ({
|
||||
id: "oidc",
|
||||
@@ -56,6 +57,7 @@ export const OidcProvider = (headers: ReadonlyHeaders | null): OIDCConfig<Profil
|
||||
if (!profile.sub) {
|
||||
throw new Error(`OIDC provider did not return a sub property='${Object.keys(profile).join(",")}'`);
|
||||
}
|
||||
assertVerifiedEmailForCredentialsLinking(profile, env.AUTH_OIDC_ENABLE_DANGEROUS_CREDENTIALS_LINKING);
|
||||
const name = extractProfileName(profile);
|
||||
if (!name) {
|
||||
throw new Error(`OIDC provider did not return a name properties='${Object.keys(profile).join(",")}'`);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
export const assertVerifiedEmailForCredentialsLinking = (
|
||||
profile: { email_verified?: unknown },
|
||||
isCredentialsLinkingEnabled: boolean,
|
||||
) => {
|
||||
if (isCredentialsLinkingEnabled && profile.email_verified !== true) {
|
||||
throw new Error("OIDC provider did not return a verified email while credentials linking is enabled");
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user