fix(auth): fail startup when Google/GitHub OAuth client secret is missing - #5542
Open
pedrofrxncx wants to merge 1 commit into
Open
fix(auth): fail startup when Google/GitHub OAuth client secret is missing#5542pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
…sing AUTH_GOOGLE_CLIENT_ID or AUTH_GITHUB_CLIENT_ID set without their matching _CLIENT_SECRET silently produced a socialProvider config with an empty-string secret instead of failing fast, unlike every other provider pairing in this schema (SSO, email) which already gets a superRefine check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Source: hardening gap in
apps/api/src/auth/auth-env.ts(this session's "auth scopes validation" focus area) — the wildcard-scope gap in the same directory is already covered by open PR #5021, so this targets a distinct, un-covered validation hole in the same file.Why a maintainer wants this:
authEnvSchemaalready fails startup when Microsoft SSO, Google SSO, or an email-provider reference is half-configured (client ID set, secret missing) — but the plain social-login providers (AUTH_GOOGLE_CLIENT_ID/AUTH_GITHUB_CLIENT_ID) had no matching check. Setting just the client ID (a typo'd or partially-copied.env) silently produced asocialProviders.google/githubconfig withclientSecret: ""instead of failing fast — the exact inconsistency the SSO checks already exist to prevent for the other providers.Failure scenario: deploy with
AUTH_GOOGLE_CLIENT_IDset butAUTH_GOOGLE_CLIENT_SECRETunset (e.g. an incomplete secret-manager sync) → server boots fine, Better Auth registers the Google provider with an empty secret, and Google OAuth login fails confusingly at request time instead of at startup where it's obvious. Same for GitHub.Fix: two
superRefinechecks mirroring the existing SSO pattern — reject at config-parse time (which runs at server boot viagetConfig()→loadAuthConfig()) when a client ID is set without its secret. Added a regression test per provider (accept-when-complete + reject-when-incomplete), inverting-style tests matching the existing SSO test shape in the same file.Reviewer check:
bun test apps/api/src/auth/auth-env.test.tsLocally verified:
bun run fmt,cd apps/api && bunx tsc --noEmit,bun test apps/api/src/auth/auth-env.test.ts(14 pass),bunx oxlint apps/api/src/auth/auth-env.ts apps/api/src/auth/auth-env.test.ts(0 warnings/errors). Full CI validates the rest.Summary by cubic
Fail startup when Google/GitHub OAuth client secrets are missing to surface misconfigurations early and prevent runtime login failures. Aligns social-login validation with existing SSO checks.
superRefinechecks inapps/api/src/auth/auth-env.tsto requireAUTH_GOOGLE_CLIENT_SECRETandAUTH_GITHUB_CLIENT_SECRETwhen their client IDs are set.apps/api/src/auth/auth-env.test.tsfor accept/reject cases on Google and GitHub OAuth.Written for commit b75e2de. Summary will update on new commits.