Integrate · 05
Authentication and social sign-in
Customers sign in with an email or username and a password. Staff can add TOTP. Google and Apple OAuth are optional; linking an identity never removes the last usable sign-in method.
Password authentication
The custom user model uses an email-or-username backend. Registration, login, logout, forgot-password, reset and account settings are under /account/. Password validators enforce minimum length, common-password, numeric and user-attribute checks.
| Surface | Path |
|---|---|
| Sign in | /account/login/ |
| Register | /account/register/ |
| Forgot password | /account/forgot-password/ |
| Reset | /account/reset/<uidb64>/<token>/ |
| Security settings | /account/security/ |
Google and Apple OAuth
Social sign-in uses OAuth callbacks at /account/oauth/google/callback/ and /account/oauth/apple/callback/. Register those exact URLs with each provider and set the client IDs/secrets in .env. Apple requires the team ID, key ID and private key in addition to the client ID.
GOOGLE_OAUTH_CLIENT_ID=...
GOOGLE_OAUTH_CLIENT_SECRET=...
APPLE_OAUTH_CLIENT_ID=...
APPLE_OAUTH_TEAM_ID=...
APPLE_OAUTH_KEY_ID=...
APPLE_OAUTH_PRIVATE_KEY=...Use the production callback URLs in the provider console. A localhost callback will not work on the live domain.
Identity linking
Signed-in customers can link or unlink Google and Apple identities from account settings. The account guard prevents removing the last usable sign-in method, so a customer cannot lock themselves out by unlinking the only provider they can use.
Two-factor authentication
Staff can enroll a TOTP authenticator and generate recovery codes. The security workbench tracks login attempts, IP blocks and rate-limit configuration. Require 2FA for anyone who can issue refunds, change payouts, edit settings or use the Django admin.
# Generate recovery material in a controlled support flow.
# Never ask a customer to send a TOTP code or recovery code by email.
open http://127.0.0.1:8000/account/security/
Sessions and cookies
Production sessions use the database backend, so they survive worker restarts and are shared by all Gunicorn workers. Session and CSRF cookies are secure and HTTP-only where the frontend does not need to read them; the CSRF cookie remains readable because the Studio sends fetch requests with the token.
| Setting | Production value |
|---|---|
SESSION_ENGINE | Database-backed sessions. |
SESSION_COOKIE_SECURE | True. |
CSRF_COOKIE_SECURE | True. |
SESSION_COOKIE_HTTPONLY | True. |
CSRF_COOKIE_HTTPONLY | False for Studio fetch. |