# Authentication and authorization security * Use established authentication standards and password hashing; never store plaintext or reversibly encrypted passwords. * Hash passwords with Argon2id (at least m=19 MiB, t=2, p=1); if unavailable, scrypt (N=2^17, r=8, p=1), bcrypt (cost 10 or higher; inputs beyond 72 bytes are truncated, so reject or pre-handle longer passwords), or PBKDF2-HMAC-SHA256 with at least 600,000 iterations where FIPS compliance requires it (OWASP Password Storage Cheat Sheet). Never create password schemes or reduce work factors merely to improve latency; rehash on login when parameters are raised. * Enforce authorization server-side for every sensitive operation and verify resource ownership and tenant boundaries. * Deny by default and check authorization on every request, including background jobs and alternate API paths. Do not trust role or identity values supplied by clients. * Use least-privilege roles, short-lived sessions or tokens, secure renewal and revocation, and invalidate credentials after password, recovery, or privilege changes. * Validate JWTs as RFC 8725 recommends: * Fix the accepted algorithms on the server, bind each key to exactly one algorithm, and never take the algorithm from the token header; reject `none`. * Validate signature, issuer, audience, expiry, and not-before, with bounded clock skew. Use explicit typing (`typ`, for example `at+jwt`) or distinct audiences to prevent substituting one token kind for another, such as an ID token for an access token. * Resolve the `kid` header only against a trusted key set, and treat it as untrusted input. Never fetch keys from token-supplied `jku`, `x5u`, or `jwk` headers. * Signed JWT payloads are readable by anyone; keep sensitive data out of them. * Protect login, recovery, reset, MFA, and privileged actions against brute force, enumeration, replay, CSRF, and privilege escalation. * Store session identifiers securely; rotate them after authentication or privilege changes and invalidate them on logout or account recovery. * Test unauthenticated, unauthorized, cross-user, cross-tenant, expired-token, revoked-session, and recovery-flow paths.