Restrict chat invocation
Extend your AccessPolicy to allow users to chat with a particular agent.
By default, chatting with an agent is not permitted, even if the AccessPolicy grants access to the registry runtime resource. To chat with an agent, you must add runtime:* rules to your AccessPolicy. For a conceptual overview of how AccessPolicy works across all access control layers, see About access control.
Before you begin
Follow one of the quickstart guides to install Solo Enterprise for agentregistry and deploy your first agent. The quickstart also sets up Keycloak as an OIDC provider and creates an admin user that you use to create AccessPolicies in this guide.
Step 1: Create a Keycloak group and user
Use the Keycloak Admin REST API to create a developers group and a user who belongs to it.
Get an admin token for the Keycloak Admin REST API.
export KEYCLOAK_ADMIN_TOKEN=$(curl -s \ -d "client_id=admin-cli" -d "username=admin" -d "password=admin" \ -d "grant_type=password" \ "${KEYCLOAK_URL}/realms/master/protocol/openid-connect/token" \ | jq -r .access_token)Create the
developersgroup.curl -s -X POST \ -H "Authorization: Bearer ${KEYCLOAK_ADMIN_TOKEN}" \ -H "Content-Type: application/json" \ "${KEYCLOAK_URL}/admin/realms/${KEYCLOAK_REALM}/groups" \ -d '{"name": "developers"}'Create a
dev-useraccount and assign it to thedevelopersgroup.curl -s -X POST \ -H "Authorization: Bearer ${KEYCLOAK_ADMIN_TOKEN}" \ -H "Content-Type: application/json" \ "${KEYCLOAK_URL}/admin/realms/${KEYCLOAK_REALM}/users" \ -d '{ "username": "dev-user", "email": "dev-user@example.com", "firstName": "Dev", "lastName": "User", "enabled": true, "credentials": [{"type": "password", "value": "password", "temporary": false}] }' export DEV_USER_ID=$(curl -s \ -H "Authorization: Bearer ${KEYCLOAK_ADMIN_TOKEN}" \ "${KEYCLOAK_URL}/admin/realms/${KEYCLOAK_REALM}/users?username=dev-user" \ | jq -r '.[0].id') export DEVELOPERS_GROUP_ID=$(curl -s \ -H "Authorization: Bearer ${KEYCLOAK_ADMIN_TOKEN}" \ "${KEYCLOAK_URL}/admin/realms/${KEYCLOAK_REALM}/groups?search=developers" \ | jq -r '.[0].id') curl -s -X PUT \ -H "Authorization: Bearer ${KEYCLOAK_ADMIN_TOKEN}" \ "${KEYCLOAK_URL}/admin/realms/${KEYCLOAK_REALM}/users/${DEV_USER_ID}/groups/${DEVELOPERS_GROUP_ID}"
Step 2: Chat with the agent
Log in to Solo Enterprise for agentregistry as the
dev-useruser (dev-user/password).export OIDC_ISSUER=$KEYCLOAK_ISSUER export OIDC_CLIENT_ID=ar-cli arctl user loginInspect the JWT that is returned by Keycloak to confirm that the
developersgroup claim is in the token.arctl user info --show-tokens \ | jq -r '.access_token | split(".") | .[1] | @base64d | fromjson | {sub, email, Groups}'Example output:
{ "sub": "fbb5e028-4ef7-41de-8a6b-88365c26287d", "email": "dev-user@example.com", "Groups": [ "developers" ] }Verify the user’s identity. In your CLI output, verify that the
developersrole has a status ofconfigured. This setting means that the registry controller found a corresponding AccessPolicy for users with thedevelopersclaim value.arctl user whoamiExample output:
FIELD VALUE Subject fbb5e028-... Email dev-user@example.com Issuer http://172.18.0.15:8080/realms/agentregistry Superuser false ROLE STATUS developers configuredOpen the Solo Enterprise for agentregistry UI and navigate to the
myagentagent. In the Agent Details card, click Open Chat.Try chatting with the agent. For example, you can ask it what it can do for you. Then, hit Enter and wait for the agent to reply. Verify that access to the agent chat is forbidden.
Step 3: Enable invocation access
As the admin, create an AccessPolicy resource that allows chat invocation for the myagent agent in the Solo Enterprise for agentregistry UI when the user belongs to the developers user group.
Log out and log back into the registry with the admin user (
admin-user/password).arctl user logout arctl user loginCreate the AccessPolicy. The following example allows users that belong to the
developersgroup to interact with agents and MCP servers via the Solo Enterprise for agentregistry UI. However, chat invocation is limited to themyagentagent.cat <<EOF | arctl apply -f - apiVersion: ar.dev/v1alpha1 kind: AccessPolicy metadata: name: developers spec: description: "Invocation acccess for myagent agent" principals: - kind: Role name: developers rules: - actions: - "runtime:*" resources: - kind: agent name: myagent - actions: - "registry:*" resources: - kind: server name: "*" - kind: agent name: "*" - kind: runtime name: "*" EOFExample output:
✓ AccessPolicy/developers createdVerify the policy was created.
arctl get accesspoliciesExample output:
NAME DESCRIPTION developers Invocation acccess for myagent agent
Step 4: Verify invocation access
Open the Solo Enterprise for agentregistry UI, logout, and log back in as the dev user with the
dev-userusername andpasswordpassword.Navigate to the
myagentagent. In the Agent Details card, click Open Chat.Chat with the agent. For example, you can ask it what it can do for you. Verify that this time, chatting with the agent is allowed and that you get a response back from your agent.