Configure RBAC for Self-Managed Agent Memory
- how-to
Restrict operations on a self-managed Agent Memory server to 3 fixed roles carried in your identity provider’s tokens.
By default, Agent Memory authenticates callers but does not authorize them. This means that any valid token can reach every operation, including deleting a user or downloading diagnostic logs. Enabling authorization restricts each operation to a minimum role, so a token must carry a sufficient role to reach it. To learn about the Agent Memory’s Role-Based Access Control model, see Security and Access Control.
Prerequisites
-
You have configured authentication for Agent Memory. For more information, see Configure Authentication for Self-Managed Agent Memory.
-
You have administrative access to your identity provider to create roles and assign them to service accounts.
Procedure
To configure Role-Based Access Control (RBAC) for Agent Memory, use the following steps:
-
Create 3 roles in your identity provider:
ams_ro,ams_rw, andams_admin.The steps to create and assign a role vary by provider. For more information, see your identity provider’s documentation. -
Assign the appropriate role to each service account or client that calls Agent Memory.
Assigning a role does not require issuing a new credential. Access tokens are short-lived, so the client picks up its new role the next time it fetches a token.
For more information about which role each operation requires, see Minimum Role by Operation.
-
Verify the role reaches a newly issued token before enabling enforcement:
-
Run the following:
echo $TOKEN | cut -d'.' -f2 | base64 --decode 2>/dev/null | jqThe base64decode flag varies by platform:-don Linux,-Don earlier versions of macOS. You can also use a CLI tool such as jwt-cli to decode the token locally, or paste it into jwt.io to inspect its claims. Avoid pasting a live production token into any third-party website; use a non-production token instead. -
In the output, find the field at your configured
OIDC_ROLES_CLAIMpath and confirm it includes 1 ofams_ro,ams_rw, orams_admin.The claim path defaults to
realm_access.roles, which is the convention for Keycloak. If your identity provider places roles elsewhere, setOIDC_ROLES_CLAIMto match. For more information, see Self-Managed Agent Memory Environment Variable Reference.
-
-
Add the following environment variable to the
.envfile in your Agent Memory project directory:AGENTMEMORY_AUTHZ_ENABLED=true -
Use
docker composeto recreate the Agent Memory container to apply the new environment variable:This command briefly interrupts the Agent Memory service. In-flight requests fail until the new container is ready. docker compose up -d --force-recreate agentmemory-server
Minimum Role by Operation
Each of the following operations lists its minimum role.
A token with ams_rw also reaches everything ams_ro reaches, and a token with ams_admin reaches everything.
| Area | Operation | Minimum Role |
|---|---|---|
Users |
|
|
Users |
|
|
Users |
|
|
Users |
|
|
Sessions |
|
|
Sessions |
|
|
Memory |
|
|
Memory |
|
|
Prompts |
|
|
Prompts |
|
|
Logs |
|
|
Health and diagnostics |
|
|
Health and diagnostics |
|
Public: no token |
Operation Notes
GET /usersvs.GET /users/{user_id}-
GET /usersis admin-gated because its filters can return every user sharing a name or metadata value.GET /users/{user_id}requires onlyams_robecause it discovers nothing. The caller must already hold the ID, and a wrong guess returns404. DELETE /users/{user_id}-
Deletion is gated at
ams_rw, notams_admin, because in most deployments the agent runtime that creates users also needs to delete them. The operation is irreversible and there is no soft delete. If your security model requires tighter control over user deletion, gate it at the identity-provider level by limiting agent runtime tokens toams_rwand reservingams_adminfor a separate service account used only for delete workflows. /promptsmutations-
All mutations require
ams_adminbecause prompts are a global configuration that steers extraction for every ingestion. GET /logs/collect-
Requires
ams_adminbecause the diagnostic bundle carries server logs, configuration snapshots, and cluster information.
Troubleshooting
| Symptom | Cause | Solution |
|---|---|---|
Startup logs the following warning: |
Authentication is on, but |
Expected until you finish this procedure.
Set |
"Insufficient permissions" ( |
The token carries a recognized role, but it’s not a high enough for this specific operation. |
Assign |
|
Authorization is on, but the token does not carry a role that Agent Memory recognizes. |
Confirm |
|
|
Enable authentication, or set |