Skip to content

Commit 5f10ed6

Browse files
committed
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
1 parent 9568a4f commit 5f10ed6

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

‎packages/server/src/lib/auth.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,20 @@ const createBetterAuth = () =>
126126
...(await resolveTrustedOrigins()),
127127
].filter(Boolean);
128128

129-
if (
130-
!IS_CLOUD &&
131-
(ctx.path.startsWith("/sign-in/email") ||
132-
ctx.path.startsWith("/sign-in/social"))
133-
) {
129+
const isBlockedAuthPath =
130+
ctx.path.startsWith("/sign-in/email") ||
131+
ctx.path.startsWith("/sign-in/social") ||
132+
ctx.path.startsWith("/sign-in/passkey") ||
133+
ctx.path.startsWith("/sign-up/email") ||
134+
ctx.path.startsWith("/passkey/verify-authentication") ||
135+
ctx.path.startsWith("/passkey/generate-authenticate-options");
136+
137+
if (!IS_CLOUD && isBlockedAuthPath) {
134138
const settings = await getWebServerSettings();
135139
if (settings?.enforceSSO) {
136140
throw new APIError("FORBIDDEN", {
137141
message:
138-
"SSO is enforced. Direct password and social sign-in are disabled.",
142+
"SSO is enforced. Direct password, social, and passkey sign-in are disabled.",
139143
});
140144
}
141145
}

0 commit comments

Comments
 (0)