Self-Hosted (BYO Token)
Run AgentOS without the AgentOS control plane by issuing and verifying your own JWTs.
AgentOS verifies any JWT signed with a key you provide. The AgentOS control plane is one issuer; you can also issue your own tokens, or accept tokens from third-party identity providers.
JWT verification and runtime permission checks are open-source features. You can integrate your own identity and RBAC without subscribing to the hosted control plane. Custom RBAC managed through that control plane has Enterprise plan requirements.
Issuance Models
| Model | Tokens minted by | Verification key | When to use |
|---|---|---|---|
| Control plane | os.agno.com | Public key from the control plane | Default. Works with the AgentOS UI out of the box. |
| Self-hosted | Your backend or identity provider | The key you sign with | Your application's end users, air-gapped or on-prem deployments, or full control over claims. |
Issuing Your Own Tokens
Sign tokens in your backend with the matching verification key. Asymmetric algorithms (RS256, ES256) use a public key. Symmetric algorithms (HS256) use a shared secret. See Algorithm Options for the full list.
Tokens must include the claims from Token Structure. With the default scope provider, the scopes claim controls what the caller can do.
Configure AgentOS with the verification key:
from agno.os import AgentOS, Authorization
agent_os = AgentOS(
id="my-agent-os",
agents=[agent],
authorization=Authorization(
verification_keys=["your-public-key-or-shared-secret"],
algorithm="RS256", # or "HS256" for shared secret
),
)Send the token in the Authorization header:
curl -H "Authorization: Bearer $TOKEN" http://localhost:7777/agentsSee the Basic Authorization (Symmetric) and Basic Authorization (Asymmetric) examples for generating signed tokens end to end.
Set verify_audience=True and audience when tokens should be bound to this AgentOS. Authorization(issuer="your-issuer") also verifies the token's iss claim. The legacy authorization_config=AuthorizationConfig(...) form remains supported with a deprecation warning; new configurations pass Authorization(...) as authorization=.
AgentOS can match the JWT's kid header against multiple keys in a local JWKS file. Keys are loaded when the validator is constructed; AgentOS does not poll a remote JWKS URL. On rotation, refresh the local file and restart the application or reconstruct its validator. See Configuration Options.
Third-Party Identity Providers
AgentOS can verify identity-provider JWTs with a supported signing algorithm and the provider's verification keys. Configure the key, algorithm, audience policy, and permission claim for your issuer:
- Download the provider's JWKS document to a local file.
- Set
jwks_fileto that path andalgorithmto the token's signing algorithm. - Set
scopes_claimto the name of a claim containing an array of permission strings. Built-in resources require native Agno names such asagents:readandagents:my-agent:run. Custom REST mappings do not replace those handler checks or the native mappings used by built-in MCP tools.
AgentOS treats a space-delimited OAuth scope string as one scope. For Auth0, enable RBAC and Add Permissions in the Access Token, then select scopes_claim="permissions" and configure permissions using Agno's scope names.
If the provider gives you a raw public key (PEM) instead of a JWKS endpoint, use verification_keys=[pem] and skip jwks_file. Setting both is also valid: AgentOS tries JWKS keys first (matched by kid), then static verification keys.
Example: WorkOS
Download the JWKS file from your WorkOS environment:
curl https://api.workos.com/sso/jwks/$WORKOS_CLIENT_ID > workos-jwks.jsonPoint AgentOS at it. WorkOS tokens carry permissions under the permissions claim, so set scopes_claim="permissions" on the JWT middleware:
from agno.os import AgentOS
from agno.os.middleware.jwt import JWTMiddleware
agent_os = AgentOS(
id="my-agent-os",
agents=[agent],
)
app = agent_os.get_app()
app.add_middleware(
JWTMiddleware,
jwks_file="workos-jwks.json",
algorithm="RS256",
scopes_claim="permissions",
authorization=True,
)WorkOS organization sessions carry the organization's role and permissions. Configure those permissions using native Agno scope names, such as agents:read. Reserve custom scope mappings for your own routes.
Why this example uses JWTMiddleware. Use Authorization for verification settings and for managed roles or a custom provider. For JWT scope-based authorization with a different permission claim name (WorkOS and Auth0 permissions, Okta scp), cookie tokens, or custom scope mappings, use JWTMiddleware directly. scopes_claim selects a claim; it does not translate your application's permission vocabulary into Agno scopes.
See WorkOS BYOT for a runnable example.
Integrate Existing RBAC
Choose how your identity provider's permissions reach the runtime:
- Permission strings: configure the issuer to send native Agno scopes, such as
registry:readoragents:my-agent:run. Select a different claim name withJWTMiddleware(scopes_claim="permissions")if needed. - Role names: use managed roles with
Authorization(roles_claim="roles"). Define each role's permissions locally; the verified token selects the role. - An existing policy service: use a custom authorization provider. The provider can use the verified principal and full JWT claims to decide resource access.
Permission checks and user isolation are separate controls. JWT tenant or group claims do not automatically scope your database queries, Registry, knowledge bases, tools, or credentials.
Managing End Users
Your issuer signs end users in; AgentOS does not. To keep a record of them in AgentOS, pass a UserDirectory as AgentOS(user_directory=...). Directory IDs match each token's sub, so issue a stable, unique sub per user. Profile claims such as email and name can provision users on their first request.
Manage the directory in code, through the /users admin API, or from the User Management page in os.agno.com. Disabling a user blocks their requests immediately, even with an unexpired token; AgentOS has no other way to revoke a self-issued JWT. The directory is not an allowlist, so restrict who can obtain a token in your issuer. See User Management.
Accepting Multiple Issuers
verification_keys is a list. AgentOS tries each key in order until one verifies the token. Pass a second key to accept tokens from both the AgentOS control plane and your own backend at the same time.
authorization=Authorization(
verification_keys=[
AGENTOS_CONTROL_PLANE_PUBLIC_KEY, # tokens issued by os.agno.com
YOUR_BACKEND_PUBLIC_KEY, # tokens minted by your service
],
algorithm="RS256",
)This keeps the AgentOS UI working for your team through the control plane while your backend mints tokens for your application's end users and service-to-service traffic. All keys in the list must use the algorithm set in algorithm.
For a mix of JWKS-based and raw-key issuers (e.g., a third-party IDP plus the AgentOS control plane), set both jwks_file and verification_keys. AgentOS tries JWKS keys first (matched by kid), then static verification keys as a fallback.
Order matters for performance, not correctness. AgentOS tries each key in order and stops at the first match. Put the most common issuer first to skip an extra decode attempt per request.
Reading Tokens from Cookies
By default, AgentOS reads the JWT from the Authorization: Bearer header. For browser apps that hit AgentOS directly, use the JWT middleware to read from a cookie, or both.
Use this as the single manual JWT middleware configuration, replacing the earlier manual setup. Stacking it behind a header-only JWT layer would still reject cookie-only requests.
from agno.os.middleware.jwt import JWTMiddleware, TokenSource
app = agent_os.get_app()
app.add_middleware(
JWTMiddleware,
verification_keys=["your-public-key"],
algorithm="RS256",
token_source=TokenSource.BOTH, # HEADER | COOKIE | BOTH
cookie_name="access_token",
authorization=True,
)See JWT Middleware for the full set of token-source options.
Next Steps
| Task | Guide |
|---|---|
| See claim structure and example tokens | Tokens |
| See the full scope reference | Scopes |
| Configure JWT middleware in depth | JWT Middleware |
| Read identity-provider role names | AgentOS Roles |
| Keep a directory of end users | User Management |
| Integrate a custom policy service | Custom Authorization |