Session Configuration
id, role, brokerId, and employerId. The JWT is:
- Signed with
AUTH_SECRET— tamper-evident - Not encrypted by default — do not put sensitive data in the JWT payload beyond what is documented in RBAC
- Stored in a cookie — not in
localStorageorsessionStorage
Cookie Attributes
Auth.js sets the following attributes on the session cookie automatically:In development (
NODE_ENV !== "production"), the Secure flag is relaxed to allow HTTP on localhost. It is always enforced in production.Session Lifetime
Auth.js defaults apply:- Session max age: 30 days (rolling)
- JWT max age: 30 days
AUTH_SECRET is rotated, all existing sessions are immediately invalidated — they cannot be verified.
Session Invalidation
Sessions are invalidated by:- Signing out — Auth.js deletes the session cookie
- JWT secret rotation — all sessions become unverifiable
- Cookie expiry — browser discards the cookie after max-age
AUTH_SECRET in Vercel environment variables and redeploy.
Cross-Site Request Forgery (CSRF)
Auth.js includes built-in CSRF protection:- State tokens are used for OAuth flows (not applicable here, but the infrastructure is present)
SameSite=Laxon the session cookie prevents most cross-site POST attacks- The
Content-Security-Policy: form-action 'self'header (set innext.config.ts) prevents forms from submitting to external domains
XSS and Cookie Theft
TheHttpOnly flag means that even if an XSS vulnerability were exploited, JavaScript cannot read the session cookie. Combined with the Content Security Policy, the attack surface for session theft via script injection is significantly reduced.
Cookies Set by the Application
No tracking cookies, advertising cookies, or third-party cookies are set by the application.