docs/ref/modules/server-api/authentication.md
All access to the Wazuh Server API is protected by JWT authentication and RBAC authorization. Additional protections include rate limiting, brute-force prevention, and security headers.
/security/user/authenticate)Authorization: Bearer <JWT_TOKEN>PyJWT for token encoding/decodingsequenceDiagram
participant C as Client
participant API as Server API
participant Auth as authentication.py
participant RBAC as RBAC ORM
C->>API: POST /security/user/authenticate
API->>Auth: Validate credentials
Auth->>RBAC: Check user in database
RBAC-->>Auth: User record
Auth-->>API: Generate JWT (EC-signed)
API-->>C: 200 + JWT token
C->>API: GET /agents (Authorization: Bearer <token>)
API->>Auth: Verify JWT signature
Auth-->>API: Token valid + user context
API->>API: Proceed with RBAC check
RBAC is enforced before any core logic is executed.
expose_resources from rbac/decorators.py403 Forbidden usually indicates RBAC blocking, not auth failurecontextvars for request-scoped access| File | Role |
|---|---|
rbac/decorators.py | expose_resources decorator that enforces action/resource permissions |
rbac/orm.py | ORM models for roles, policies, and user-role mappings |
rbac/preprocessor.py | Resource preprocessing before permission checks |
rbac/default_resources.py | Built-in default RBAC resource definitions |
rbac/auth_context.py | Authentication context handling |
429 Too Many Requests or immediate rejectionmiddlewares.py and error_handler.pyThe API sets the following security headers on all responses:
| Header | Value | Purpose |
|---|---|---|
Content-Security-Policy | none | Restricts resource loading |
X-Frame-Options | DENY | Prevents clickjacking |
Server | Wazuh | Masks underlying server technology |
These are applied via the secure Python library in middlewares.py.
403 as RBAC errors, not authentication failuresrbac_mode setting appropriate for your security posture (white for strict environments)