Import
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
verification_keys | Optional[List[str]] | None | List of keys used to verify JWT signatures. For asymmetric algorithms (e.g. RS256), use public keys. For symmetric algorithms (e.g. HS256), use shared secrets. Each key is tried in order until one succeeds. Useful for accepting tokens from multiple issuers. |
jwks_file | Optional[str] | None | Path to a static JWKS (JSON Web Key Set) file containing public keys. Keys are matched by kid (key ID) from the JWT header. Alternative to verification_keys for RSA key management. |
algorithm | Optional[str] | "RS256" | JWT algorithm for token verification. Common options: RS256 (asymmetric), HS256 (symmetric). |
verify_audience | Optional[bool] | False | Whether to verify the JWT’s aud claim matches the expected audience. |
audience | Optional[str] | AgentOS id | Expected audience claim. When verify_audience=True, the token’s aud must match this value. Defaults to the AgentOS id. |
admin_scope | Optional[str] | "agent_os:admin" | The scope that grants full admin access. Holders bypass user isolation and can access all data. |
user_isolation | bool | False | Opt-in per-user data isolation. When True, non-admin callers can only read and write rows associated with their JWT sub claim. Affects sessions, memories, traces, and cancel/resume/continue routes. |
Usage
Algorithm Options
| Algorithm | Type | Key Format |
|---|---|---|
RS256 | Asymmetric (RSA) | Public key (PEM format) |
RS384 | Asymmetric (RSA) | Public key (PEM format) |
RS512 | Asymmetric (RSA) | Public key (PEM format) |
HS256 | Symmetric (HMAC) | Shared secret string |
HS384 | Symmetric (HMAC) | Shared secret string |
HS512 | Symmetric (HMAC) | Shared secret string |
ES256 | Asymmetric (ECDSA) | Public key (PEM format) |
ES384 | Asymmetric (ECDSA) | Public key (PEM format) |
ES512 | Asymmetric (ECDSA) | Public key (PEM format) |
Examples
Using RS256 (Asymmetric)
Using HS256 (Symmetric)
Using JWKS File
See Also
- Security Overview - AgentOS security overview
- Authorization - Scopes, roles, and access control
- JWT Middleware - Advanced JWT configuration
- JWTMiddleware Reference - Middleware class reference