fix(auth): normalize AUTH_TYPE to uppercase to prevent silent redirect loop - #6810
Merged
Merged
Conversation
…t loop The AuthType enum values and backward-compat constants (MULTI_TENANT, SINGLE_TENANT, NO_AUTH) are all uppercase, but the raw AUTH_TYPE env var was compared without case normalization. Setting AUTH_TYPE=db (lowercase) — which the backend Python code accepts fine — caused the frontend to fall through to a raw TypeScript cast that produced an invalid enum value. The provider config lookup then returned undefined, silently defaulting to the NoAuth credentials provider, which auto-signs in without a login form and creates an infinite redirect loop. Adding .toUpperCase() to the env read makes 'db', 'DB', and 'Db' all resolve to AuthType.DB correctly. Fixes #6809
Contributor
|
💪 Fantastic work @alex-percy! Your very first PR to keep has been merged! 🎉🥳 You've just taken your first step into open-source, and we couldn't be happier to have you onboard. 🙌 For any support, feel free to reach out on the community: https://slack.keephq.dev. Happy coding! 👩💻👨💻 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6810 +/- ##
==========================================
- Coverage 30.45% 30.43% -0.02%
==========================================
Files 101 101
Lines 11785 11791 +6
==========================================
Hits 3589 3589
- Misses 8196 8202 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
One-line fix: adds
.toUpperCase()when reading theAUTH_TYPEenvironment variable in the frontend, so that lowercase values likedbcorrectly match the uppercaseAuthTypeenum ("DB").Problem
Setting
AUTH_TYPE=db(lowercase) works on the backend (Python, case-insensitive) but silently breaks the frontend. TheAuthTypeenum and backward-compat constants are all uppercase:But
auth.config.tscompared the raw env value without normalizing:This causes
baseProviderConfigs["db"]to returnundefined, silently falling back to theNoAuthcredentials provider. The signin page then auto-callssignIn("credentials"), creating a NextAuth session without a valid Keep JWT, which produces an infinite redirect loop with no error message.Fix
All enum values and backward-compat constants are already uppercase, so this is safe.
Fixes #6809