fix: restore Better Auth route path literals#37
Closed
BunsDev wants to merge 0 commit into
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
Restores Better Auth ctx.path route template literals (slash-prefixed paths) in the server auth hooks so path-based provider inference and pre-/post-auth policy enforcement (SSO hard-binding, 2FA gates, cleanup/auditing) matches real Better Auth hook inputs again.
Changes:
- Replaced incorrect package-like tokens (e.g.
@opencoven-feedback/...) with Better Auth route templates (e.g.'/sign-in/email','/oauth2/callback/:providerId') for provider inference and path-set guards. - Normalized redirect targets back to application routes (e.g.
'/admin/login','/auth/login','/auth/two-factor-setup-required') used by the web app. - Restored SSO callback matching to
'/oauth2/callback/:providerId'so SSO post-processing hooks run on actual callbacks.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b541e11 to
1eb1874
Compare
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.
Motivation
/...) with package-like tokens (@opencoven-feedback/...), breakingctx.pathmatching and disabling critical pre-/post-auth policy enforcement such as SSO hard-binding and workspace 2FA gates.ctx.pathvalues and enforce policy.Description
apps/web/src/lib/server/auth/hooks.tswith the original Better Auth route templates (e.g.'/sign-in/email','/magic-link/verify','/oauth2/callback/:providerId') used byinferProvider,SESSION_CREATING_CALLBACK_PATHS, andNO_EMAIL_BEFORE_PATHS.'/oauth2/callback/:providerId'sohandleSsoCallbackAfterandhandleAutoProvisionAfterrun for real callbacks.CREDENTIAL_SIGN_IN_PATHS,MAGIC_LINK_VERIFY_PATHS,TWO_FACTOR_AUDIT_PATHS) and normalized redirect targets to application routes (e.g.'/admin/login','/auth/login','/auth/two-factor-setup-required').apps/web/src/lib/server/auth/hooks.tsand preserve the existing policy logic and hook structure.Testing
bun test apps/web/src/lib/server/auth/__tests__/infer-provider.test.ts, which was blocked and errored withCannot find module 'better-auth/api'because dependencies were not installed.bun install, which failed due to registry403responses for dependency tarballs, preventing a full test run.bun run typecheck(tsc --noEmit), which failed due to missing type definition packages after the failed install (errors for@testing-library/jest-domandbun).Codex Task