The CafeteriaPM API uses JWT Bearer tokens for authentication. All protected endpoints require anDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/123048152-JJDS/CafeteriaPM_S203/llms.txt
Use this file to discover all available pages before exploring further.
Authorization: Bearer <token> header. Tokens are obtained by posting credentials to POST /auth/login — there is no other authentication flow.
POST /auth/login
Validates user credentials and returns a signed JWT token along with basic user information. The token embeds the user’s ID and role, which the API uses for access control on every subsequent request.Request Body
The user’s email address. Must match an active user account exactly.
The user’s plain-text password. Verified against the bcrypt hash stored in the database.
Request Examples
Response (200 OK)
Signed JWT token. Include in all subsequent requests as
Authorization: Bearer <access_token>.Always
"bearer". Indicates the token scheme expected in the Authorization header.The authenticated user’s database ID.
The authenticated user’s display name.
The user’s assigned role:
admin, mesero, caja, or cocina.Error Responses
| Status | Body | Cause |
|---|---|---|
401 Unauthorized | {"detail": "Credenciales incorrectas"} | Email not found, account is inactive, or password does not match |
Using the Token
Once you have anaccess_token, include it as a Bearer token in the Authorization header of every protected request:
Token Details
| Property | Value |
|---|---|
| Algorithm | HS256 — configurable via the ALGORITHM environment variable |
| Default expiry | 480 minutes (8 hours) — configurable via ACCESS_TOKEN_EXPIRE_MINUTES |
| Signing key | Derived from the SECRET_KEY environment variable |
| Claim | Type | Description |
|---|---|---|
sub | string | The authenticated user’s ID, encoded as a string (e.g. "1") |
rol | string | The user’s role name (e.g. "admin", "mesero") |
exp | integer | Unix timestamp at which the token expires |
Token Errors
Protected endpoints share a common set of error responses produced by theget_current_user and require_roles dependency chain in app/core/security.py:
| Status | Body | Cause |
|---|---|---|
401 Unauthorized | {"detail": "Token inválido o expirado"} | JWT signature is invalid or the token has expired |
401 Unauthorized | {"detail": "Token inválido"} | JWT decoded successfully but the sub claim is missing |
401 Unauthorized | {"detail": "Usuario no encontrado o inactivo"} | Token is valid but the referenced user account no longer exists or has been deactivated |
403 Forbidden | {"detail": "Acceso denegado. Rol requerido: admin"} | User is authenticated but does not have the role required by the endpoint |
401 responses from protected endpoints include a WWW-Authenticate: Bearer header, as required by the OAuth2 Bearer Token specification.