Authentication¶
How to authenticate requests and authorize them, whichever transport the caller uses. Every
transport resolves to the same Principal, so your authorization
code never depends on how the request arrived.
-
Protecting routes
Gate endpoints with
current_user()and its keyword guards (superuser, scopes, verified, and custom checks). -
Sessions
Cookie auth, CSRF, remember-me, multi-device management, and the session lifecycle.
-
Bearer tokens
JWT access and refresh tokens, scopes, and revocation.
-
Multiple transports
Run sessions and bearer together behind one
Principal. -
OAuth
Google, GitHub, and custom providers.
-
Sudo mode
Short-lived re-authentication for sensitive actions.
Where to start¶
Not sure which to read first?
New to CRUDAuth? Protecting routes covers the one dependency you'll use everywhere.
Browser app? Sessions is the default and needs no configuration.
API, mobile, or CLI? Bearer tokens.
Supporting both at once? Multiple transports.
Adding social login? OAuth. Gating destructive actions? Sudo mode.