feat(auth): enforce supabase jwt authentication#39
Conversation
WalkthroughThe PR removes header-based authentication and related types/exports, centralizes authentication on Supabase JWT verification, tightens Supabase token shapes and runtime guards, updates tests and docs to use the Supabase-only flow, and adds test helpers and base JWT claim fixtures for tests. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client as Client (HTTP)
participant App as App
participant AuthProv as AuthenticationProvider
participant Verifier as Supabase Verifier / JWKS
Client->>App: HTTP request (Authorization: Bearer <token>)
App->>AuthProv: authentication.authenticate({ request })
note right of AuthProv #E8F6FF: test helper parses Bearer\nproduction verifies JWT via Supabase flow
AuthProv->>Verifier: validate token (signature, iss, aud, exp, iat, role)
Verifier-->>AuthProv: token payload / validation result
alt valid
AuthProv-->>App: { user: SupabaseToken }
App-->>Client: proceed (authenticated)
else invalid
AuthProv-->>App: throws AuthenticationError
App-->>Client: 401 / unauthorized
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used📓 Path-based instructions (3)packages/*/src/**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
packages/auth/src/authentication/**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
packages/auth/src/authentication/**/*.ts📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (3)📓 Common learnings📚 Learning: 2025-10-02T12:40:33.718ZApplied to files:
📚 Learning: 2025-10-02T12:40:33.718ZApplied to files:
🧬 Code graph analysis (1)packages/auth/src/authentication/supabase.ts (3)
🔇 Additional comments (4)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/db/src/index.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
packages/*/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
packages/*/src/**/*.{ts,tsx}: Avoid implicit any; TypeScript is run with strict enabled
Prefer type guards or the satisfies operator over as casts where appropriate
Prefer unknown for external inputs
Use PascalCase for types and enums
Use camelCase for variables and functions
Ensure source comments are written in English
Files:
packages/db/src/index.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: listee-dev/listee-libs PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-02T12:40:33.718Z
Learning: Applies to packages/auth/src/authentication/**/*.ts : Extend Supabase JWT verification (createSupabaseAuthentication using .well-known/jwks.json) only via dedicated modules to keep caching and claim validation centralized
Learnt from: CR
Repo: listee-dev/listee-libs PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-02T12:40:33.718Z
Learning: Applies to packages/auth/src/authentication/**/*.{ts,tsx} : Place runtime-specific authentication adapters under packages/auth/src/authentication/ (e.g., header.ts, supabase.ts, shared utilities, errors.ts)
📚 Learning: 2025-10-02T12:40:33.718Z
Learnt from: CR
Repo: listee-dev/listee-libs PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-02T12:40:33.718Z
Learning: Applies to packages/auth/src/authentication/**/*.ts : Extend Supabase JWT verification (createSupabaseAuthentication using .well-known/jwks.json) only via dedicated modules to keep caching and claim validation centralized
Applied to files:
packages/db/src/index.ts
📚 Learning: 2025-10-02T12:40:33.718Z
Learnt from: CR
Repo: listee-dev/listee-libs PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-02T12:40:33.718Z
Learning: Applies to packages/auth/src/authentication/**/*.{ts,tsx} : Place runtime-specific authentication adapters under packages/auth/src/authentication/ (e.g., header.ts, supabase.ts, shared utilities, errors.ts)
Applied to files:
packages/db/src/index.ts
🔇 Additional comments (1)
packages/db/src/index.ts (1)
154-155: LGTM! Clear documentation and appropriate type definition.The documentation comment with a reference to Supabase's official docs is helpful, and the
AuthenticatorAssuranceLeveltype correctly models the two-factor authentication levels used in Supabase JWT tokens.
Summary
AuthenticatedTokenis always aSupabaseTokenTesting
Summary by CodeRabbit
Breaking Changes
New Features
Documentation