-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(auth): env-gate email/password and Google hd #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
52a57ed
1561073
5074fc4
3c20d80
808b835
407280a
c26a08d
d585dc3
d0299d9
7d4a573
56f4eeb
57001e6
ad1d702
fc0c594
4ffe150
14cd220
6ff0724
2212e3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,11 @@ const optional = (key: string): string | undefined => { | |
| return value && value.length > 0 ? value : undefined; | ||
| }; | ||
|
|
||
| const flag = (key: string): boolean => { | ||
| const value = optional(key)?.toLowerCase(); | ||
| return value === "true" || value === "1"; | ||
| }; | ||
|
|
||
| const pair = ( | ||
| idKey: string, | ||
| secretKey: string, | ||
|
|
@@ -65,6 +70,10 @@ export const env = { | |
| cookieDomain: optional("AUTH_COOKIE_DOMAIN"), | ||
| trustedOrigins: [...new Set([...appUrls, apiUrl])], | ||
| isProduction: process.env.NODE_ENV === "production", | ||
| /** Opt-in: set EMAIL_PASSWORD_ENABLED=true on a deploy to allow email/password auth. */ | ||
| emailAndPasswordEnabled: flag("EMAIL_PASSWORD_ENABLED"), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Turbo-managed deployments silently ignore both opt-ins, leaving email/password disabled and the Google hosted-domain restriction enabled even when the deploy notes set these variables. Adding both names to the root Prompt for AI agents |
||
| /** Opt-in: set GOOGLE_DISABLE_HD=true to omit Google hosted-domain restriction. */ | ||
| googleDisableHd: flag("GOOGLE_DISABLE_HD"), | ||
| } as const; | ||
|
|
||
| export function isGoogleConfigured(): boolean { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Enabling email/password for the first time via EMAIL_PASSWORD_ENABLED introduces an account-linking edge case. account.accountLinking.trustedProviders still lists only GOOGLE and MICROSOFT, not the email/password ("credential") provider. Better Auth auto-links a provider to an existing user by email only when the provider is in trustedProviders (or supplies email_verified); email/password does not satisfy that. So once a workspace user has an account created via Google, signing in later with email/password on the same address won't auto-link and can surface an "unable to link account" / conflicting-account flow. Worth deciding explicitly how this should behave before rolling the flag out on the aisales deploy. If email/password should be treated as the same identity, add the credential provider id to trustedProviders; otherwise confirm the manual-linking UX is acceptable and document it.
Prompt for AI agents