Authentication and CSRF¶
Moo combines stateless JWT authentication with cookie-backed CSRF protection. Even public POST endpoints require a CSRF token.
Sign in flow¶
sequenceDiagram
participant Client
participant API
Client->>API: GET /v1/csrf
API-->>Client: XSRF-TOKEN cookie and token body
Client->>API: POST /v1/authenticate + X-XSRF-TOKEN
API-->>Client: jwt and refreshToken
Client->>API: Authenticated request + Bearer JWT
- Call
GET /v1/csrfand retain theXSRF-TOKENcookie. - For POST, PUT, PATCH, and DELETE requests, copy that cookie value into the
X-XSRF-TOKENheader. - Submit credentials to
POST /v1/authenticate. - Send the returned JWT as a Bearer token on protected operations.
- Rotate an expired access token with
POST /v1/refreshand the refresh token. - Call
POST /v1/logoutto delete the current user refresh token.
Refresh tokens are rotated when used. Treat both token types as secrets and do not place them in URLs or logs.