Skip to main content

Agent identity providers

Agent identity providers are the issuers a registered agent can be bound to, so that only tokens minted for that agent's application may act as the agent. An agent can be bound to a Microsoft Entra ID application, or to an application of any other OpenID Connect provider, such as the workforce identity provider your company already uses. Before an admin binds an agent, the gateway has to trust the issuer of the application's tokens. GET /v1/agents/identity/providers lists exactly the issuers that qualify, and the Agents page reads the same list to fill the Trusted Entra Tenant dropdown. If a tenant is not in the list, the binding would never match a real token, so the gateway refuses to offer it.

The route needs a Spanway enterprise license that includes the agent_governance feature and a proxy admin key. Trust itself comes from JWT authentication, either a per-issuer entry in spanway_jwtauth.issuers or the gateway-wide JWT_ISSUER and JWT_AUDIENCE.

A real-world scenario​

A platform admin registers a release-bot agent that runs in a cloud tenant and authenticates with an Entra application token. She wants to bind the agent to that application so a token stolen from another workload cannot invoke it. On the Agents page the Trusted Entra Tenant dropdown is empty, so she checks the providers route, sees that JWT auth has an issuer entry for the tenant but no audience, adds the audience, and the tenant appears. She then binds the agent and sets the execution mode.

Steps​

  1. Trust the tenant's issuer in JWT auth. Each issuer needs an audience, because an issuer without audience validation is never offered for a binding.

    general_settings:
    enable_jwt_auth: true
    spanway_jwtauth:
    issuers:
    - issuer: https://login.microsoftonline.com/f1c2d3e4-0000-0000-0000-000000000000/v2.0
    jwks_url: https://login.microsoftonline.com/f1c2d3e4-0000-0000-0000-000000000000/discovery/v2.0/keys
    audience: api://spanway
    team_id_jwt_field: azp

    Or trust one issuer gateway-wide with JWT_ISSUER and JWT_AUDIENCE, as described in JWT authentication. Restart the gateway after either change.

  2. List the issuers the gateway offers.

    curl -s http://localhost:4000/v1/agents/identity/providers -H "Authorization: Bearer $SPANWAY_API_KEY"
  3. In the Admin UI open Agents under Agentic and create or edit the agent. In the Agent Identity section set Identity Provider to Microsoft Entra ID (for another provider pick Any OpenID Connect provider and see OpenID Connect), pick the tenant under Trusted Entra Tenant, enter the Application (Client) ID, and choose the Execution Mode: Autonomous for an agent that calls with its own application token, On behalf of a user for one that acts for a signed in user, or Both. For Autonomous and Both, also enter the Enterprise Application Object ID. Find it in the Entra admin center under Enterprise applications, select the application and copy its Object ID. The Object ID shown under App registrations is a different value and is refused. The same through the API, keeping the agent_id the answer returns:

    curl -s -X POST http://localhost:4000/v1/agents \
    -H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \
    -d '{
    "agent_name": "release-bot",
    "identity": {
    "provider": "microsoft_entra",
    "tenant_id": "f1c2d3e4-0000-0000-0000-000000000000",
    "client_id": "9a7b1c2d-0000-0000-0000-000000000000",
    "service_principal_id": "5e4d3c2b-0000-0000-0000-000000000000"
    },
    "execution_mode": "autonomous"
    }' | tee agent.json
    AGENT_ID=$(jq -r .agent_id agent.json)
  4. Check the binding. The route takes the agent's generated agent_id, not its name.

    curl -s "http://localhost:4000/v1/agents/$AGENT_ID/identity" -H "Authorization: Bearer $SPANWAY_API_KEY"

Expected result​

Step 2 returns the trusted issuers as a JSON list.

["https://login.microsoftonline.com/f1c2d3e4-0000-0000-0000-000000000000/v2.0"]

The Trusted Entra Tenant dropdown on the Agents page offers the same tenant. After step 3 the agent is bound, and step 4 reports the binding with identity_managed: true, enabled, the execution_mode and last_authenticated_at, which fills in the first time a token from that application invokes the agent. A token from any other application or tenant is refused when it tries to act as release-bot.

OpenID Connect​

Any OpenID Connect provider that signs its tokens with a published key set can identify an agent. The agent signs in to its provider with its own application credentials (the client credentials grant) and sends the token it gets to the gateway. The gateway checks the signature and audience through JWT authentication as for any token, then matches the binding.

FieldWhat it meansDefault
Issuer (issuer)The exact iss value of the agent's tokens, an https address. It must be in the list from step 2.Required.
Client ID (client_id)The agent application's client id at the provider.Required.
Client ID claim (client_id_claim)The token claim that carries the client id. Providers differ: many use azp, others client_id, cid or appid. Look at a decoded token of the agent if unsure.azp.
Agent subject (subject)The exact sub value of the agent's own tokens. For the client credentials grant this is often the client id, sometimes with a suffix such as @clients.Required.
Required roles (required_roles)Values the token's roles claim must contain. Leave empty to require none.None.
Required scopes (required_scopes)Values the token's scope or scp claim must contain. Leave empty to require none.None.

An OpenID Connect binding supports Autonomous agents only, because the gateway can only prove a person signed in through Microsoft SSO today. A token with a different issuer, client id or subject is refused, and so is one that lacks a required role or scope. A bound agent can also fetch its stored SaaS credentials with its token.

The same through the API:

curl -s -X POST http://localhost:4000/v1/agents \
-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \
-d '{
"agent_name": "release-bot",
"identity": {
"provider": "oidc",
"issuer": "https://idp.example.com/oauth2/default",
"client_id": "0oa1release2bot",
"client_id_claim": "cid",
"subject": "0oa1release2bot",
"required_scopes": ["agents.invoke"]
},
"execution_mode": "autonomous"
}'

A new OpenID Connect binding is recognised by each gateway replica once it reloads its agents from the database, which it does about every 10 seconds. Until then a token of that application is treated as an ordinary token.

Which issuers are listed​

The list is built from the JWT auth configuration at the time of the call. It is empty when enable_jwt_auth is off. Each entry of spanway_jwtauth.issuers is included when it has an audience and does not set disable_audience_validation. The gateway-wide JWT_ISSUER is added when JWT_AUDIENCE is also set and no issuer entry already names it. Nothing else is listed, so a tenant whose tokens could be accepted without checking the audience never becomes an identity binding.

MethodPathSummary
GET/v1/agents/identity/providersList the identity provider issuers an agent can be bound to
GET/v1/agents/{agent_id}/identityRead an agent's identity binding and execution mode

Errors​

What you seeWhyFix
403 naming the agent_governance feature.The license does not include it.Ask for a license with agent_governance, see enterprise.
403 Only proxy admins can create, update, or delete agentsThe caller is not a proxy admin.Use a proxy admin key. The Agents page hides the identity fields for other roles.
The list is [] and the dropdown is empty.JWT auth is off, or no issuer has an audience.Set enable_jwt_auth: true and give the issuer an audience, or set both JWT_ISSUER and JWT_AUDIENCE.
The tenant is trusted for API calls but missing here.Its issuer entry sets disable_audience_validation: true.Remove that flag and set audience.
400 Configure trusted JWT issuer and audience validation for this issuer firstThe tenant's or provider's issuer is not in the list from step 2.Trust the issuer in JWT auth with an audience, then try again.
400 Delegated agents require Microsoft SSO for the same trusted tenantOn behalf of a user or Both was chosen, but Admin UI SSO is not Microsoft Entra ID for that tenant.Configure Microsoft SSO with MICROSOFT_TENANT set to the same tenant, or use Autonomous.
400 Invalid agent identity configurationThe identity object is missing a field or a value is not valid.For Entra send provider, tenant_id, client_id and, for autonomous agents, service_principal_id as UUIDs. For OpenID Connect send provider oidc, an https issuer, client_id and subject.
400 An OpenID Connect identity supports autonomous agents only. Set execution_mode to autonomousAn OpenID Connect binding was given On behalf of a user or Both.Use Autonomous.
403 Token does not match the registered OpenID Connect application or 403 Token subject does not match the registered agent subjectThe token's iss, client id claim or sub is not the bound application's.Decode the token, compare it with the binding, and check Client ID claim.
403 Token lacks the required scopesAn OpenID Connect token lacks a scope in Required scopes.Grant the scope to the application at the provider.
400 Autonomous mode requires the Enterprise application service-principal object IDAutonomous or Both was chosen without service_principal_id.Copy the Object ID from Enterprise applications in Entra into Enterprise Application Object ID.
400 Bind an identity before enabling this managed agentThe agent was enabled without an active identity binding.Bind the identity first, then enable the agent.
404 Agent not found from the identity route.The id is wrong, or the agent's name was used instead of its id.Use the agent_id from the create answer, the Agents page or GET /v1/agents.
503 Agent policy could not be loaded or 503 Managed agent policy requires a databaseThe gateway could not read the agent's identity policy, or has no database.Check the database connection and retry.
403 Token does not match the registered Entra applicationThe token's issuer, tenant (tid) or azp is not the bound tenant and application. Only v2.0 tokens carry azp, so v1.0 tokens, which name the application in appid, are always refused.Issue v2.0 tokens (set accessTokenAcceptedVersion to 2 in the application manifest), compare the claims with the binding, and re-bind after rotating the application.
403 This agent requires its bound identity provider tokenThe call used a virtual key or another token, not a token of the bound application.Call with a token Entra issued to the application.
403 Agent is not enabled for this execution modeA user token reached an Autonomous agent, or an application token an On behalf of a user agent.Change Execution Mode to Both or use the matching token.
403 Token lacks the required application roles or 403 Token lacks the required delegated scopesThe token does not carry the roles or scopes the binding requires.Assign the roles or consent the scopes in Entra.
403 Agent execution is disabledThe agent is disabled or its binding is no longer active.Re-enable the agent with Execution set to Enabled.

Logs​

Binding and token checks write no log lines of their own. A refused token answers the caller with the messages above.

Audit​

Binding, changing or removing an identity is part of the agent update, so it writes an updated row on Spanway_AgentsTable with the identity before and after, see agent governance.