Session Cookies vs JWTs: Least-Privilege Auth with Expired Credential Detection in Appwrite
0 reputation · 24 Jul 2024, 14:14 UTC
0 reputation · 24 Jul 2024, 14:14 UTC
Appwrite offers two primary authentication paths: server-managed session cookies (httpOnly, same-site) and client-managed JWT Bearer tokens with a project-wide configurable expiry (default one hour). Both integrate with document-level permission checks (read("user:"), write("role:admin")) evaluated at request time, but they diverge sharply on platform support and expired-credential handling.
401 with no error code or claim indicating why authentication failed (expiry, revocation, malformation, or clock skew).This forces a choice: accept cookie limitations for simpler expiry UX (browser handles renewal silently), or adopt JWTs for universal client support and build custom expiry detection (e.g., decoding exp claim client-side) while handling the increased attack surface of longer-lived or frequently refreshed tokens.
exp checks for native — maintain least-privilege guarantees without duplicating permission logic?WWW-Authenticate challenge or error payload that distinguishes token expiry from revocation, enabling silent refresh vs. forced re-login UX?A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.