>-
The Senior Manager must evaluate the request to pick the absolute most secure authentication path.
Stack Selection Matrix:
[!IMPORTANT] Domain Constraints (
auth-provider)
- Wrap the root layout in
<ClerkProvider>. Protect all secure routes at the edge usingclerkMiddleware.- Server components must fetch user state strictly via
auth()andcurrentUser()from@clerk/nextjs/server.- Sub-agents must sync the backend Database users via a
user.createdWebhook sent from Clerk. Usesvixto cryptographically verify this webhook signature.
[!IMPORTANT] Domain Constraints (
auth-providerbackend)
- Sub-agents must validate the JWKS (JSON Web Key Set) issued by the Auth Provider using
jwks-rsaandjsonwebtoken. Do not blindly trust unverified tokens from the client.- Implement a global
requireAuthmiddleware that attaches the verified user payload to the request object.
[!IMPORTANT] Domain Constraints (
auth-providerbackend)
- Sub-agents must validate the JWKS via
python-joseand fetch keys securely usinghttpx. Cache the keys to prevent rate limiting.- Use FastAPI
security.HTTPBearer()to define the auth dependency and inject the user object into routes.
localStorage or sessionStorage if they are susceptible to XSS. Prefer HttpOnly cookies with Secure; SameSite=Strict flags.redirect_url against a predefined allowlist to prevent Open Redirect attacks..env and rotated annually.scopes needed for the feature (Principle of Least Privilege).