feat(auth): enforce per-endpoint credential restrictions and make the auth chain order-independent#1718
feat(auth): enforce per-endpoint credential restrictions and make the auth chain order-independent#1718AmanGIT07 wants to merge 1 commit into
Conversation
…h chain order-independent GetPrincipal now records how a principal authenticated (Principal.AuthVia) and enforces the caller's assertion list against it, so AuthToken and the session endpoints actually restrict credential types. GetByJWT returns classifiable errors so the authenticator chain is order-independent, and the redundant opaque assertion is removed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds ChangesPAT AuthToken enforcement and AuthVia tracking
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage Report for CI Build 28435903758Coverage increased (+0.1%) to 43.888%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Summary
Make per-endpoint credential restrictions actually enforced and the authentication chain order-independent.
GetPrincipalpreviously returned the interceptor-cached principal without consulting the per-call assertion list, so a handler's credential restriction (e.g.AuthToken's) had no effect.Closes #1698
Changes
Principal.AuthVia(which credential authenticated the principal);GetPrincipalenforces the caller's assertion list against it in one place.AuthToken: accept PAT explicitly; reject credential types outside its list (e.g. an already-issued access token); return the auth status code (401) on rejection instead of wrapping as 500.ListSessions/RevokeSession): their existing{session}restriction is now enforced — non-session credentials are rejected. Behavior change: a bearer access-token caller of these endpoints is now rejected (PATs were already denied there).GetByJWTreturns classifiable errors sojwt_grantskips tokens that aren't service-user grants (not a JWT, non-UUID key id, or unknown credential) instead of hard-failing; only a genuine credential verification failure is terminal.OpaqueTokenClientAssertion(it shared an authenticator withClientCredentialsClientAssertion, making provenance ambiguous); opaque-token service-user credentials still validate via the client-credentials path.Technical Details
GetByJWTrequires the JWT key id to be a UUID (a service-user credential id) before performing a credential lookup.Test Plan
GetByJWTerror classification; PAT resolves regardless of assertion order; per-endpoint restrictions (session-only and the AuthToken list) accept/reject the right credentials;AuthTokenreturns 401 on a rejected credential.test/e2e/regression/authentication_test.go): PAT →AuthTokenreturns asub_type=app/patJWT that authenticates; the minted token cannot be re-exchanged atAuthToken(401). Run withmake e2e-test(Docker); not run in this environment.SQL Safety
N/A — no
*_repository.goorgoquchanges.