AI agents
AI agents are specialized OAuth 2.0 identities that securely perform tasks on behalf of end users through a delegated token exchange process, ensuring distinct accountability and granular access control.
You can use AI agents to securely build digital assistants that operate on behalf of end users, such as a chatbot on a retail website helping a user navigate products, or an internal workforce assistant acting on behalf of an employee to access enterprise tools like Salesforce.
- Token delegation
-
Using OAuth 2.0 token exchange, an AI agent can swap an existing access token for a new, constrained, delegation token that encodes both the original subject and the acting agent. The AI agent can then complete tasks on behalf of a user or another agent, with scopes and audiences controlled by the authorization server.
- Common use cases
-
-
Automated operations: Use an AI agent to handle routine high-volume tasks, such as triaging tickets or provisioning access.
-
Digital assistants: Use AI agents to search products, manage preferences, or place orders.
-
How to use an AI agent
To use an AI agent, you must first complete these steps:
-
Register the agent in one of the following ways:
Once registered, you can use the AI agent like an OAuth 2.0 machine identity. For example:
Enable AI agents
In AM, AI agents are switched off by default.
To enable AI agents:
-
In the AM admin UI, set the advanced property
org.forgerock.am.oauth2.aiagents.enabledtotrue, and save your changes. -
Enable AI agents in the OAuth 2.0 provider.
-
In the AM admin UI, go to Realms > realm name > Services.
-
Create an OAuth 2.0 provider service if one doesn’t exist already.
-
On the OAuth 2.0 provider page, select the AI Agents tab, and select Enable AI Agents.
-
Save your changes.
-
Refresh the UI for the changes to apply.
-
-
Go to Applications > OAuth 2.0 and verify that AI Agents appears as the last item in the menu.
Register an AI agent in the UI
Use the AI agents UI to onboard an AI agent, configure its standard OAuth 2.0 properties as a specialized OAuth 2.0 client, update, or delete an agent.
To create an AI agent:
-
Go to Applications > OAuth 2.0 > AI Agents and click + Add AI Agent.
-
Provide values for Client ID, Client secret, Redirection URIs, Scope(s), and Default Scope(s), and click Create.
-
Configure the AI agent properties as required and save your changes.
Find out more about standard OAuth 2.0 client properties in Client application registration.
Register an AI agent dynamically
Use dynamic client registration (DCR) when you want to use automation or agents to onboard themselves.
-
Enable DCR in the provider:
-
In the AM admin UI, go to Realms > realm name > Services > OAuth2 Provider.
-
On the Client Dynamic Registration tab, enable Allow Open Dynamic Client Registration.
-
Save your changes.
-
-
Configure your webserver to map the DCR endpoint to appear under the authorization server metadata. This complies with RFC 8414.
For example, for an Apache Tomcat deployment:
-
Edit the
server.xmlto add the mapping:<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />to/Server/Service/Engine/Host -
Create a file called
rewrite.configand place it underCATALINA_HOME/conf/Catalina/localhost/. -
Add the following mapping to
rewrite.config:RewriteRule ^/\.well-known/oauth-authorization-server$ /am/oauth2/realms/root/.well-known/oauth-authorization-server/aiagent [L] -
Save your changes.
-
Restart Tomcat.
You can verify the AI agent registration URL by calling the well-known authorization server endpoint and reading the
registration_endpointvalue, for example:$ curl https://am.example.com:8443/am/oauth2/realms/root/.well-known/oauth-authorization-server/aiagent { "…": "…", "registration_endpoint": "https://am.example.com:8443/am/oauth2/aiagent/register", "…": "…" } -
-
To register an agent, you can now post a DCR request to the AI agent endpoint:
For example:
$ curl \ --request POST \ --header "Content-Type: application/json" \ --data "grant_type=client_credentials" \ --data "client_id=My AI Agent" \ --data "client_secret=client_secret" \ --data "scope=read" \ 'https://am.example.com:8443/am/oauth2/realms/root/aiagent/register'You can use DCR scripting to run extra checks and processes before and after the agent registration.