For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
MS Entra ID as an IdP
Use Microsoft Entra ID as an identity provider for OAuth.
To use OAuth features such as access token validation, you must have an OpenID Connect (OIDC) compatible identity provider (IdP).
Set up Microsoft Entra ID (formerly Azure Active Directory) as an IdP for Solo Enterprise for agentgateway. You register an application in Entra ID and collect the configuration values that you need for JWT authentication and other auth scenarios, such as Entra OBO token exchange.
Before you begin
Register an app in Entra ID
Register an application in Microsoft Entra ID and collect the configuration values that you need for agentgateway.
Make sure that you have access to a Microsoft Entra ID tenant. If you do not have one, you can create a free tenant for development purposes.
Register an application in the Microsoft Entra admin center. During registration, note the following:
- For Supported account types, choose the option that fits your organization. For testing, Accounts in this organizational directory only is sufficient.
- You do not need to configure a redirect URI for JWT validation flows.
After registration, collect the following values from the app’s Overview page in the Entra admin center. Save these values as environment variables.
Review the following table to understand this configuration.export ENTRA_TENANT_ID=<your-tenant-id> export ENTRA_CLIENT_ID=<your-application-client-id>Value Where to find it Description Tenant ID Overview > Directory (tenant) ID The unique identifier for your Entra ID tenant. Application (client) ID Overview > Application (client) ID The unique identifier for the registered app. Tokens issued for this app include this value as the audience ( aud) claim in the formatapi://<client-id>.Expose an API so that tokens can be issued for this app.
- In the Entra admin center, go to your app registration and select Expose an API.
- Next to Application ID URI, click Set. Accept the default value of
api://${ENTRA_CLIENT_ID}and click Save. - Click Add a scope. Enter a scope name such as
access_as_user, set Who can consent to Admins and users, fill in the display name and description fields, and click Add scope. - Click Add a client application. Enter the Azure CLI app ID such as
04b07795-8ddb-461a-bbee-02f9e1bf7b46, select the scope you just created, and click Add application. This authorizes the Azure CLI to request tokens for your app. To list the Azure CLI app ID, you can run this Azure CLI command:az ad sp list --display-name "Microsoft Azure CLI" --query "[].appId" -o tsv
Optional: If your auth scenario requires a client secret (such as Entra OBO token exchange), create one.
In the Entra admin center, go to Certificates & secrets > Client secrets > New client secret.
Save the secret Value (not the Secret ID). You cannot retrieve this value later.
export ENTRA_CLIENT_SECRET=<your-client-secret-value>
Note the OIDC discovery and JWKS endpoints for your tenant. These endpoints are the same for all apps in a tenant, and you can build the endpoint if you know your tenant ID. You can also find these endpoints by navigating to MS Entra ID > App registrations > ${YOUR_APP} > Endpoints.
# OIDC metadata document discovery endpoint export OIDC_ENDPOINT="https://login.microsoftonline.com/${ENTRA_TENANT_ID}/v2.0/.well-known/openid-configuration" # JWKS URI from the OIDC metadata document export JWKS_URI="https://login.microsoftonline.com/${ENTRA_TENANT_ID}/discovery/v2.0/keys"
Create the JWKS backend
Create an AgentgatewayBackend resource that points to the Microsoft login endpoint. This backend is used by the JWT authentication policy to fetch the Entra JWKS keys for token signature validation.
kubectl apply -f- <<EOF
apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayBackend
metadata:
name: entra-jwks
namespace: agentgateway-system
spec:
static:
host: login.microsoftonline.com
port: 443
policies:
tls: {}
EOF| Setting | Description |
|---|---|
static.host | The Microsoft login endpoint that hosts the Entra JWKS keys. |
static.port | HTTPS port 443 for secure communication. |
policies.tls | Enable TLS for the connection to the Microsoft endpoint. |
Create a JWT auth policy
Create an EnterpriseAgentgatewayPolicy that validates Entra-issued JWTs on your routes. This policy checks the token issuer, audience, and signature by using the remote Entra JWKS endpoint.
kubectl apply -f- <<EOF
apiVersion: enterpriseagentgateway.solo.io/v1alpha1
kind: EnterpriseAgentgatewayPolicy
metadata:
name: entra-jwt-policy
namespace: agentgateway-system
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: HTTPRoute
name: openai
traffic:
jwtAuthentication:
mode: Strict
providers:
- issuer: https://sts.windows.net/${ENTRA_TENANT_ID}/
audiences:
- "api://${ENTRA_CLIENT_ID}"
jwks:
remote:
jwksPath: /${ENTRA_TENANT_ID}/discovery/v2.0/keys
backendRef:
name: entra-jwks
kind: AgentgatewayBackend
group: agentgateway.dev
port: 443
EOF| Setting | Description |
|---|---|
targetRefs | Select the HTTPRoute that you want to protect with Entra JWT validation. This example targets the openai route that you set up as part of the Before you begin prerequisites. |
issuer | The Entra token issuer URL, either the v1 or v2 format. Check your token’s iss claim to confirm which format to use. For more information, see the Microsoft identity platform access tokens documentation
|
audiences | The expected audience claim in the token. Entra formats this as api://${ENTRA_CLIENT_ID} for custom APIs. |
jwks.remote.jwksPath | The path to the JWKS endpoint on login.microsoftonline.com, relative to the entra-jwks backend. |
jwks.remote.backendRef | Reference to the entra-jwks AgentgatewayBackend that you created in the previous step. |
Verify JWT validation
After you apply the JWT policy, verify that Entra token validation works for your route.
Send a request to the protected route without a token. Verify that the request is rejected.
curl "$INGRESS_GW_ADDRESS/v1/chat/completions" -H content-type:application/json -d '{ "model": "", "messages": [ { "role": "system", "content": "You are a platform engineer, testing out a feature." }, { "role": "user", "content": "test" } ] }'curl "localhost:8080/v1/chat/completions" -H content-type:application/json -d '{ "model": "", "messages": [ { "role": "system", "content": "You are a platform engineer, testing out a feature." }, { "role": "user", "content": "test" } ] }'Example output:
authentication failure: no bearer token foundGet an access token from Entra ID. You can use the Azure CLI or any OIDC client.
az login --scope "api://${ENTRA_CLIENT_ID}/access_as_user" export USER_TOKEN=$(az account get-access-token \ --resource "api://${ENTRA_CLIENT_ID}" \ --query accessToken -o tsv)Send a request with the token. Verify that the request succeeds.
curl "$INGRESS_GW_ADDRESS/v1/chat/completions" -H "Authorization: Bearer ${USER_TOKEN}" -H content-type:application/json -d '{ "model": "", "messages": [ { "role": "system", "content": "You are a platform engineer, testing out a feature." }, { "role": "user", "content": "test" } ] }'curl "localhost:8080/v1/chat/completions" -H "Authorization: Bearer ${USER_TOKEN}" -H content-type:application/json -d '{ "model": "", "messages": [ { "role": "system", "content": "You are a platform engineer, testing out a feature." }, { "role": "user", "content": "test" } ] }'Example output:
{"model":"gpt-3.5-turbo-0125","usage":{"prompt_tokens":23,"completion_tokens":17,"total_tokens":40,"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0},"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0}},"choices":[{"message":{"content":"Sure, I can help with that! What specific test do you need assistance with?","role":"assistant","refusal":null,"annotations":[]},"index":0,"logprobs":null,"finish_reason":"stop"}],"id":"chatcmpl-DPBEeCwuXMS99RhDiBXJ2HrYziv5c","object":"chat.completion","created":1774893760,"service_tier":"default","system_fingerprint":null}
Troubleshooting
Invalid or malformed token
What’s happening:
When you send a request with your user token, you see an error similar to the following.
authentication failure: the token is invalid or malformed: Error(InvalidIssuer)Why it’s happening:
Your policy might have the wrong issuer, audience, or JWKS path. If you applied the policy without replacing the environment variables such as as ${ENTRA_TENANT_ID}, you might have a backslash-escaped literal string in the policy, such as $\{ENTRA_TENANT_ID\}.
How to fix it:
Replace the environment variables in your policy with the actual values, reapply the policy, and try again.
Issuer mismatch (v1 vs v2 tokens)
What’s happening:
Requests with a valid token return Error(InvalidIssuer), even though the environment variables are correctly substituted in the policy.
Why it’s happening:
Entra issues v1 or v2 tokens depending on the accessTokenAcceptedVersion setting in your app manifest. The default is null, which means v1. Each version uses a different issuer format:
- v1:
https://sts.windows.net/<tenant-id>/ - v2:
https://login.microsoftonline.com/<tenant-id>/v2.0
If the issuer in your JWT policy does not match the iss claim in the token, validation fails.
How to fix it:
Decode your token to check the iss claim and ver field, and update the policy issuer to match.
Cleanup
You can optionally remove the resources that you set up as part of this guide.kubectl delete agentgatewaybackend entra-jwks -n agentgateway-system
kubectl delete enterpriseagentgatewaypolicy entra-jwt-policy -n agentgateway-system