mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-10-19 23:21:36 +00:00
fix(auth): enforce SSO on server-side sign-in endpoints (#5291)
* fix(auth): enforce SSO on server-side sign-in endpoints Resolves #5288. - In better-auth hooks.before, reject /sign-in/email and /sign-in/social with FORBIDDEN when webServerSettings.enforceSSO is enabled - Prevents direct API password authentication when SSO enforcement is enabled * [autofix.ci] apply automated fixes * fix(auth): block passkey authentication and email signup when SSO is enforced - Include /sign-in/passkey, /passkey/verify-authentication, /passkey/generate-authenticate-options, and /sign-up/email in enforced SSO block - Prevents registered passkeys from bypassing enforced SSO policies --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -125,6 +125,24 @@ const createBetterAuth = () =>
|
||||
...(ctx.context.baseURL ? [new URL(ctx.context.baseURL).origin] : []),
|
||||
...(await resolveTrustedOrigins()),
|
||||
].filter(Boolean);
|
||||
|
||||
const isBlockedAuthPath =
|
||||
ctx.path.startsWith("/sign-in/email") ||
|
||||
ctx.path.startsWith("/sign-in/social") ||
|
||||
ctx.path.startsWith("/sign-in/passkey") ||
|
||||
ctx.path.startsWith("/sign-up/email") ||
|
||||
ctx.path.startsWith("/passkey/verify-authentication") ||
|
||||
ctx.path.startsWith("/passkey/generate-authenticate-options");
|
||||
|
||||
if (!IS_CLOUD && isBlockedAuthPath) {
|
||||
const settings = await getWebServerSettings();
|
||||
if (settings?.enforceSSO) {
|
||||
throw new APIError("FORBIDDEN", {
|
||||
message:
|
||||
"SSO is enforced. Direct password, social, and passkey sign-in are disabled.",
|
||||
});
|
||||
}
|
||||
}
|
||||
}),
|
||||
},
|
||||
emailVerification: {
|
||||
|
||||
Reference in New Issue
Block a user