How it works
Request a token
Send your credentials and a Cloudflare Turnstile captcha token to
POST /api/Auth. The API validates both before issuing a JWT.Store the token
The response contains a single
token field. Store it in memory or secure storage on your client. Do not persist it in a cookie without appropriate HttpOnly and Secure flags.Send the token with every request
Include the token in the
Authorization header on all requests to protected endpoints:Login request
Send aPOST request to /api/Auth with a JSON body containing your username, password, and a valid Cloudflare Turnstile token.
Response
A successful login returns200 OK with the JWT in the response body:
The token value is a standard JWT. You can inspect its claims at jwt.io or decode it programmatically. See JWT structure for the full list of embedded claims.
Cloudflare Turnstile
Every login request must include aturnstileToken obtained from the Cloudflare Turnstile widget rendered on your login page. The API validates this token server-side before processing the credentials.
To integrate Turnstile in your frontend, follow the Cloudflare Turnstile documentation.
Token expiration
Tokens expire 30 minutes after they are issued. There is no refresh token mechanism.Token lifetime
30 minutes from the time of issue. The expiry is embedded in the token as the standard
exp claim.No refresh tokens
When a token expires, re-authenticate via
POST /api/Auth to get a new one.Handling 401 Unauthorized
When the API returns401 Unauthorized, the token is either missing, malformed, or expired. The correct response is to re-authenticate.
- Detect the
401response. - Redirect the user to your login screen (or trigger a programmatic re-login if your client stores credentials securely).
- On successful re-authentication, retry the original request with the new token.
Related pages
JWT structure
What claims are inside the token and how to decode them.
Permissions
How module-level permissions are embedded in and enforced from the JWT.