<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Miguel Moreno</title>
    <description>The latest articles on DEV Community by Miguel Moreno (@migas_moreno).</description>
    <link>https://dev.to/migas_moreno</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3728556%2F38583af4-8c77-43fb-80ed-c75abfbe53fc.png</url>
      <title>DEV Community: Miguel Moreno</title>
      <link>https://dev.to/migas_moreno</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/migas_moreno"/>
    <language>en</language>
    <item>
      <title>An operator behind the agent: Entra ID sign-ins turned into five-minute tokens across Google Agent Platform and Microsoft Foundry</title>
      <dc:creator>Miguel Moreno</dc:creator>
      <pubDate>Sun, 29 Nov 2026 23:29:30 +0000</pubDate>
      <link>https://dev.to/gde/an-operator-behind-the-agent-entra-id-sign-ins-turned-into-five-minute-tokens-across-google-agent-5a2m</link>
      <guid>https://dev.to/gde/an-operator-behind-the-agent-entra-id-sign-ins-turned-into-five-minute-tokens-across-google-agent-5a2m</guid>
      <description>&lt;p&gt;&lt;em&gt;As of November 2026. This is a proof of concept, not a production system. All identifiers in this post are examples.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is the fourth post about a proof of concept with two AI agents. Agent A runs on Azure, in Microsoft Foundry. Agent B runs on Google Cloud, in Agent Runtime. The &lt;a href="https://dev.to/gde/google-agent-platform-across-clouds-with-spiffe-zero-secrets-between-google-cloud-and-microsoft-1hjg"&gt;first post&lt;/a&gt; gave each agent an identity with no stored secret, and the &lt;a href="https://dev.to/gde/one-model-gateway-across-clouds-litellm-on-cloud-run-and-azure-with-zero-api-keys-3ma7"&gt;second&lt;/a&gt; gave them models with no API key. The &lt;a href="https://dev.to/gde/who-is-the-agent-acting-for-a-customers-sign-in-across-google-agent-platform-and-microsoft-56d2"&gt;third&lt;/a&gt; answered "who is the agent acting for?" when the person is a customer: one five-minute token per hop, asked for by whoever hands the request on.&lt;/p&gt;

&lt;p&gt;Not everyone who talks to these agents is a customer. &lt;strong&gt;Operators&lt;/strong&gt; are people inside the organisation, such as a contact centre, who reach the same agents and the same services. They do not sign in at the customer identity provider. They sign in with Entra ID, like everyone else at work.&lt;/p&gt;

&lt;p&gt;An operator does one of two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Acts for themselves.&lt;/strong&gt; They look a customer up, or ask an agent something that involves no customer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Serves a customer.&lt;/strong&gt; They have a customer on the line and ask the agents about that customer's accounts.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This post shows how both reach the same agents and services under the same rules as customers. It also covers what Entra ID tokens make hard: cutting a person off quickly. A short section at the end covers the third case: an agent acting with no person behind it at all.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbipg68vdhpcezc1x2d8k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbipg68vdhpcezc1x2d8k.png" alt="Figure 1: the path of an operator's request" width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the operator's Entra token cannot simply travel
&lt;/h2&gt;

&lt;p&gt;The customer design from the last post rests on tokens we issue ourselves: one destination, five minutes, an &lt;code&gt;act&lt;/code&gt; claim that names every actor, a scope that only shrinks, and a session the gateways can check. An Entra access token has none of that, and we cannot add it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It lives 60 to 90 minutes.&lt;/strong&gt; Microsoft documents a random lifetime in that range (&lt;a href="https://learn.microsoft.com/en-us/entra/identity-platform/configurable-token-lifetimes" rel="noopener noreferrer"&gt;configurable token lifetimes&lt;/a&gt;). We measured 78 to 82 minutes for our operators' tokens. Entra can shorten access tokens for an API to 10 minutes with a token lifetime policy. Microsoft discourages it, it does not apply in CAE sessions, and a 10-minute token still cannot be taken back, names no actors and cannot shrink.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It cannot be taken back.&lt;/strong&gt; Disabling the account and revoking the sessions stops new tokens. For a token already issued to an API of your own, Microsoft says that the user "loses access when the access token expires", and asks the application to "stop accepting Microsoft Entra access tokens even if they're still valid" (&lt;a href="https://learn.microsoft.com/en-us/entra/identity/users/users-revoke-access" rel="noopener noreferrer"&gt;revoke user access&lt;/a&gt;). Continuous Access Evaluation, which does cut live tokens, is documented for Microsoft's own services only (&lt;a href="https://learn.microsoft.com/en-us/entra/identity/conditional-access/concept-continuous-access-evaluation" rel="noopener noreferrer"&gt;CAE&lt;/a&gt;). Entra has no introspection endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It names one audience and no chain of actors.&lt;/strong&gt; Entra's own delegation flow, on-behalf-of, swaps one Entra token for another Entra token. It cannot add our agents to an &lt;code&gt;act&lt;/code&gt; claim, or shrink a scope that our services define.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Forwarding the operator's Entra token through two agents would leave a token that keeps working for over an hour in the hands of each of them, that any of them could replay as the operator, and that says nothing about the agents.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea: the Entra token stops at the gateway
&lt;/h2&gt;

&lt;p&gt;The rule from the customer design applies unchanged: &lt;strong&gt;the sign-in token stops at the gateway.&lt;/strong&gt; At the entry, the gateway exchanges the operator's Entra token for a token from an &lt;strong&gt;internal token service&lt;/strong&gt;, with RFC 8693 token exchange (&lt;a href="https://www.rfc-editor.org/rfc/rfc8693.html" rel="noopener noreferrer"&gt;RFC 8693&lt;/a&gt;). From there on, everything is as for customers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Whoever hands the request on asks for the next token, as itself, with its own platform identity and no secret.&lt;/li&gt;
&lt;li&gt;Each token is addressed to one destination, lasts at most five minutes, and never outlives the token it came from.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;act&lt;/code&gt; grows by one actor per hop, and the scope only shrinks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The internal token service is a second realm in the same Keycloak, next to the customers' realm, with its own signing keys. They are kept apart on purpose: customer identity and internal identity are two trust domains, and a configuration mistake in one does not open the other. The services trust both issuers, and every token says what kind of subject it carries (&lt;code&gt;subject_kind&lt;/code&gt;: &lt;code&gt;customer&lt;/code&gt;, &lt;code&gt;operator&lt;/code&gt; or &lt;code&gt;platform&lt;/code&gt;). Nobody has an account in the internal realm. Operators exist only in Entra ID.&lt;/p&gt;

&lt;p&gt;In the proof of concept, operators enter through Apigee, in front of Agent B. The gateway checks the Entra token as it does for any person: signature, tenant, audience, and a delegated token (&lt;code&gt;scp&lt;/code&gt;). It then checks the operator role: an Entra app role assigned to the operator, which the inventory maps to what that role allows. A person with no operator role is refused before any exchange.&lt;/p&gt;

&lt;h2&gt;
  
  
  Case 1: the operator acts for themselves
&lt;/h2&gt;

&lt;p&gt;The gateway exchanges the Entra token as itself, the same way it exchanges a customer's sign-in token. The internal token says:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sub&lt;/code&gt; is the operator's Entra object id, and &lt;code&gt;subject_kind&lt;/code&gt; is &lt;code&gt;operator&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;the scope is what the operator's role allows by itself;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;origin_iat&lt;/code&gt; is the time Entra issued the operator's token (more on that below).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What the role allows by itself is narrow on purpose. In the demo it is one operation: &lt;strong&gt;look a customer up&lt;/strong&gt; in the accounts service, with the customer's reference in the request (&lt;code&gt;accounts.lookup&lt;/code&gt;). The service answers, and logs which operator looked up which customer.&lt;/p&gt;

&lt;p&gt;The same operator can also talk to an agent without naming a customer. The agent then holds a token with no customer in it and no scope on accounts: the lookup scope is above the agent's ceiling, so the token service leaves it out. The agent cannot read anyone's accounts with it, and the service refuses an operator's own token on a customer operation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Case 2: the operator serves a customer
&lt;/h2&gt;

&lt;p&gt;The operator names the customer they are serving when the request enters. The gateway passes the name on with the exchange, and the internal token service checks three things before it answers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the operator's role allows serving customers;&lt;/li&gt;
&lt;li&gt;the customer exists, and their account is enabled, in the customers' realm;&lt;/li&gt;
&lt;li&gt;the scope is within what that customer may do &lt;strong&gt;and&lt;/strong&gt; within the role's ceiling for serving.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The token it issues has &lt;strong&gt;the customer in &lt;code&gt;sub&lt;/code&gt; and the operator as the first actor in &lt;code&gt;act&lt;/code&gt;&lt;/strong&gt;. From there, the agents hand the request on as they do for a customer, and each one is added to &lt;code&gt;act&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9phqadkkzfg5134wkamj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9phqadkkzfg5134wkamj.png" alt="Figure 2: four tokens while serving a customer" width="800" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The token the accounts API receives:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"iss"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://sts.example.com/realms/internal"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"sub"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"customer-7f3a…"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"subject_kind"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"customer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"aud"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"accounts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"azp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"agent-a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"scope"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"accounts.read"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"act"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"client_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"agent-a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"agent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"act"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"client_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"agent-b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"agent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"act"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"sub"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"operator-3c9e…"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"operator"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"idp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"entra"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"origin_iat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1795560000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"exp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1795563127&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few details matter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The scope is an intersection again.&lt;/strong&gt; Token scope = what the customer may do ∩ the role's ceiling for serving ∩ the ceiling of every agent on the path ∩ what was asked for. In the demo, the customer may read and order transfers, the role may only read while serving, and so may the agents. Every token in the chain says &lt;code&gt;accounts.read&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Money never moves.&lt;/strong&gt; The service refuses any transfer with an operator or an agent anywhere in &lt;code&gt;act&lt;/code&gt;, whatever the scope says. The token service never issues the transfer scope through this path anyway.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The customer is checked at every hop, not just at the entry.&lt;/strong&gt; Each exchange confirms that the customer still exists and is enabled. If the customer's account is disabled while a chain is running, the next exchange is refused.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The service sees who served the customer.&lt;/strong&gt; &lt;code&gt;act&lt;/code&gt; names the operator, with its kind, so the service's log answers both "for whom" and "by whom". It also tells the two issuers apart: operations that only a customer may start, such as handing a request to the agents, refuse a token from the internal realm.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cutting an operator off
&lt;/h2&gt;

&lt;p&gt;This is the hard part, and the reason the Entra token stops at the gateway.&lt;/p&gt;

&lt;p&gt;For customers, we own the issuer. Every internal hop asks the customer CIAM whether the customer's session is still open (RFC 7662 introspection), and a sign-out stops the chain. For operators, the session lives at Entra, and Entra will not tell our gateways that it has disabled someone. So the gateways keep a &lt;strong&gt;cut list&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnyfyr8mjf77pkuhijfwt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnyfyr8mjf77pkuhijfwt.png" alt="Figure 3: cutting an operator off" width="800" height="509"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One command writes the operator's object id to the cut list of &lt;strong&gt;both&lt;/strong&gt; gateways, then reads it back from both, and fails if either did not take it. From then on, a token is refused if its chain started before the cut. That check runs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;at the entry&lt;/strong&gt;, against the Entra token's &lt;code&gt;iat&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;on every internal hop&lt;/strong&gt;, against &lt;code&gt;origin_iat&lt;/code&gt;, on the operator in &lt;code&gt;sub&lt;/code&gt; (case 1) or the operator in &lt;code&gt;act&lt;/code&gt; (case 2).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Only a gateway may exchange a person's Entra token at the token service, and it checks the cut list first, so a cut operator gets no new chain. The token service does not read the cut list itself. An agent that already holds an internal token can still exchange it for the next hop, but only until that token's five minutes run out, and the next gateway refuses the result.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;origin_iat&lt;/code&gt; is a claim of our own. Every internal token copies the time Entra issued the token the chain started from. We first used &lt;code&gt;auth_time&lt;/code&gt; for this. RFC 9068 defines &lt;code&gt;auth_time&lt;/code&gt; as the time the person authenticated, which an Entra access token does not tell us, so we stopped borrowing it (&lt;a href="https://www.rfc-editor.org/rfc/rfc9068.html" rel="noopener noreferrer"&gt;RFC 9068&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;We measured it live. About ten seconds after the command, both gateways refused the operator's token. In the other test, an agent was already holding its token for the next hop when the operator was cut. API Management refused it with &lt;code&gt;operator_access_revoked&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A timed entry leaves the list by itself after two hours, longer than an Entra token for our APIs lives. A hard entry, which refuses every token of that person whatever its time, stays until someone removes it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The order in an incident.&lt;/strong&gt; The cut list closes the window that Entra leaves open. It does not replace the steps at Entra:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cut at both gateways.&lt;/strong&gt; This stops the person in seconds, including tokens already issued.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disable the account in Entra.&lt;/strong&gt; Entra stops issuing new tokens.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Revoke the sessions in Entra.&lt;/strong&gt; This invalidates refresh tokens and session cookies, with a delay of a few minutes (&lt;a href="https://learn.microsoft.com/en-us/graph/api/user-revokesigninsessions?view=graph-rest-1.0" rel="noopener noreferrer"&gt;revokeSignInSessions&lt;/a&gt;).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The demo uses the hard cut, because it does not touch the Entra account: the browser would otherwise get a fresh Entra token silently, issued after the cut, and walk straight back in. That is the same reason step 2 matters in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  No person at all: the platform
&lt;/h2&gt;

&lt;p&gt;The third case is an agent that acts on its own, with nobody behind it. Agent to agent with their own identities, as in the first post, needs no token from us. Calling a service is different: a service must never hand customer data to a caller with no customer behind it.&lt;/p&gt;

&lt;p&gt;The agent exchanges &lt;strong&gt;its own Entra token&lt;/strong&gt; (an application token issued for the internal token service, not a person's token) for a token with a &lt;strong&gt;platform scope&lt;/strong&gt;. The token service only accepts it from that agent's own identity, only for a business domain and never for another agent, and the token has no &lt;code&gt;act&lt;/code&gt; and no person. In the demo, Agent A reads the product catalogue this way. The service opens only the operations its contract marks as platform operations, none of which return customer data. A platform token on customer accounts is refused.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this sits among the standards
&lt;/h2&gt;

&lt;p&gt;As in the last post, we keep to what published documents say.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;RFC 8693&lt;/strong&gt; describes a token service that converts tokens between security domains. That is the entry exchange, and the platform token.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The IETF OAuth Transaction Tokens draft&lt;/strong&gt; (&lt;a href="https://datatracker.ietf.org/doc/draft-ietf-oauth-transaction-tokens/" rel="noopener noreferrer"&gt;working group draft&lt;/a&gt;) exchanges the external token at the entry for an internal one. Ours are per destination rather than for the whole call chain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NIST SP 800-204&lt;/strong&gt; recommends that user session tokens do not travel beyond the gateway.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NIST IR 8587&lt;/strong&gt; (NIST and CISA, September 2026) says access tokens should be valid for no more than one hour, and that issuers should propagate revocation to relying parties (&lt;a href="https://nvlpubs.nist.gov/nistpubs/ir/2026/NIST.IR.8587.pdf" rel="noopener noreferrer"&gt;NIST IR 8587&lt;/a&gt;). Our internal tokens last five minutes. The Entra token's 60 to 90 minutes is why the cut list exists.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OWASP&lt;/strong&gt; recommends short lifetimes and, when tokens must be revoked, a deny-list where they are consumed (&lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/JSON_Web_Token_Cheat_Sheet.html" rel="noopener noreferrer"&gt;JWT cheat sheet&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Shared Signals and CAEP are final OpenID specifications, but we found no documented way for Entra to send those events to a third-party receiver. If that changes, the cut list becomes a safety net instead of the main mechanism, with no change to the rest of the design.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we learned the hard way
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Two realms, not one.&lt;/strong&gt; The customers' realm uses Keycloak's narrow-only policy: an exchange can never return a scope that the token it started from does not have. An Entra token has no &lt;code&gt;scope&lt;/code&gt; at all, so in that realm the entry would come out empty. In the internal realm the narrowing is the extension's, and tests cover it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operators have no account, and Keycloak wants one.&lt;/strong&gt; A token exchange in Keycloak is tied to a user. We use Keycloak's &lt;em&gt;transient users&lt;/em&gt;, which live only for the session and are never stored, so nobody has an account in the internal realm, which a test checks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A timed cut is not enough on its own.&lt;/strong&gt; The first version of the demo cut tokens issued before a given time. The browser renewed the operator's Entra token in the background, and the new token was issued after the cut. In production, disabling the account closes that door. In the demo we use the hard cut.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Client credentials gave the platform too much.&lt;/strong&gt; The obvious way for an agent to get a token with no person is the client credentials grant. In our Keycloak setup that token carried every audience the agent's client could reach, other agents included, and the agent could exchange it into a chain it should not have. Exchanging the agent's own Entra token limits the destination to the domain it asks for.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keycloak finds a federated client by its identity, not by its name.&lt;/strong&gt; Our first design gave each agent a second client for platform tokens, with the same identity. Keycloak looks a client up by the identity in the assertion, so two clients with one identity do not work. One client per identity per realm.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What this design asks of you
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The cut is as fast as whoever triggers it.&lt;/strong&gt; Measured, it takes seconds once the command runs. Nothing runs it automatically. Microsoft Graph can notify you of changes to users, but Microsoft does not document a latency for those notifications (&lt;a href="https://learn.microsoft.com/en-us/graph/change-notifications-overview" rel="noopener noreferrer"&gt;change notifications&lt;/a&gt;), so we kept the cut a step in the incident runbook. A gateway could also read the person's state from Graph (&lt;code&gt;accountEnabled&lt;/code&gt;, &lt;code&gt;signInSessionsValidFromDateTime&lt;/code&gt;) with a short cache. We did not, to keep Graph off the path of every request and out of the question of what to do when it does not answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The gateways are where the cut lives.&lt;/strong&gt; Our services never see an Entra token: they only accept internal tokens, and every path to them goes through a gateway that checks the cut list. Anything that accepted operators' Entra tokens directly, outside the gateways, would not know about the cut.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The token service is on every hop that carries a person.&lt;/strong&gt; The customers' realm and the internal realm run in the same Keycloak, so its availability is the chain's availability, for operators as for customers. If it does not answer, the exchange fails and the request stops there. We have not load-tested it. One server is also one blast radius: separate realms protect against a configuration mistake in one of them, not against a compromise of the server itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Removing a role takes effect with the next Entra token.&lt;/strong&gt; A role already inside an issued token stays there until it expires. The cut list removes the person, not the role. A timed cut forces a new token, which no longer carries the role.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;These are bearer tokens.&lt;/strong&gt; A stolen internal token works for at most five minutes, at one destination, and only for a caller that matches its actor at the gateway. Holder binding, as RFC 9700 recommends, is not done (&lt;a href="https://www.rfc-editor.org/rfc/rfc9700.html" rel="noopener noreferrer"&gt;RFC 9700&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The rules are our own code.&lt;/strong&gt; As for customers, they live in a Keycloak extension nobody outside the project has reviewed, on an interface Keycloak does not promise to keep stable. Our operator tests have 51 checks, from a person with no operator role to a platform token on customer data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Operators sign in with Entra ID, and their Entra token stops at the gateway.&lt;/li&gt;
&lt;li&gt;From there on, they get the customers' rules: five-minute tokens, one destination, every actor in &lt;code&gt;act&lt;/code&gt;, a scope that only shrinks.&lt;/li&gt;
&lt;li&gt;Acting for themselves, the operator is the subject, with a narrow scope of their own. Serving a customer, the customer is the subject and the operator is the first actor, read only.&lt;/li&gt;
&lt;li&gt;Entra cannot take an issued token back. One command cuts the person at both gateways, on every hop, in seconds. Disabling the account in Entra keeps them out.&lt;/li&gt;
&lt;li&gt;An agent with no person behind it gets a platform scope that opens no customer data.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>googlecloud</category>
      <category>azure</category>
      <category>security</category>
      <category>ai</category>
    </item>
    <item>
      <title>Who is the agent acting for? A customer's sign-in across Google Agent Platform and Microsoft Foundry, one token per hop</title>
      <dc:creator>Miguel Moreno</dc:creator>
      <pubDate>Sun, 29 Nov 2026 22:16:09 +0000</pubDate>
      <link>https://dev.to/gde/who-is-the-agent-acting-for-a-customers-sign-in-across-google-agent-platform-and-microsoft-56d2</link>
      <guid>https://dev.to/gde/who-is-the-agent-acting-for-a-customers-sign-in-across-google-agent-platform-and-microsoft-56d2</guid>
      <description>&lt;p&gt;&lt;em&gt;As of November 2026. This is a proof of concept, not a production system. All identifiers in this post are examples.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is the third post about a proof of concept with two AI agents. Agent A runs on Azure, in Microsoft Foundry. Agent B runs on Google Cloud, in Agent Runtime. The &lt;a href="https://dev.to/gde/google-agent-platform-across-clouds-with-spiffe-zero-secrets-between-google-cloud-and-microsoft-1hjg"&gt;first post&lt;/a&gt; gave each agent an identity with no stored secret. The &lt;a href="https://dev.to/gde/one-model-gateway-across-clouds-litellm-on-cloud-run-and-azure-with-zero-api-keys-3ma7"&gt;second&lt;/a&gt; gave them models with no API key.&lt;/p&gt;

&lt;p&gt;Both posts answered "who is the agent?". This one answers the next question: &lt;strong&gt;who is the agent acting for, and what may it do for that person?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A customer signs in and asks for their account balance. Agent B receives the question and hands it to Agent A, which calls the accounts API. Four parties handle that request, and each one receives a different token.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flfd07y0c9em4z4fewrlg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flfd07y0c9em4z4fewrlg.png" alt="Figure 1: the path of a customer's request" width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with the usual approaches
&lt;/h2&gt;

&lt;p&gt;There are two quick ways to do this, and both go wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forward the customer's token.&lt;/strong&gt; The agent passes on the token it received. Now every agent on the path holds a token that works everywhere the customer's token works, for everything the customer may do. If a malicious instruction tricks one agent, that agent can replay the token anywhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Give the agents their own access.&lt;/strong&gt; The agents call the accounts API with a service identity that can read every account. The customer is now just a parameter in the request. The API cannot tell whether the customer really asked, and an agent that hallucinates a customer number gets real data back.&lt;/p&gt;

&lt;p&gt;We wanted the accounts API to receive proof of three things on every call: which customer this is, which agents are acting for them, and that this call is within what those agents may do.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea
&lt;/h2&gt;

&lt;p&gt;Four rules carry the design.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;No token is forwarded to a new destination.&lt;/strong&gt; Whoever passes a request on swaps the token for a new one that only works at the next destination. The swap is OAuth 2.0 Token Exchange (&lt;a href="https://www.rfc-editor.org/rfc/rfc8693.html" rel="noopener noreferrer"&gt;RFC 8693&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;At the entry, the gateway swaps.&lt;/strong&gt; The customer's sign-in token is addressed to the gateway and stops there. The gateway exchanges it for a token addressed to the first agent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;After that, whoever leaves asks, as itself.&lt;/strong&gt; An agent or a service that hands the request on exchanges the token &lt;em&gt;it received&lt;/em&gt;. It signs in to the customer identity provider (the CIAM) with its own platform identity, with no secret. On those hops the gateway checks the token and does not exchange it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The scope only shrinks.&lt;/strong&gt; What an agent may do for the customer is the customer's rights, cut down to what the organisation allows that agent. No exchange can add a scope.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The customer never sees a consent screen that lists agents. The organisation decides what each agent may do for customers, as a matter of policy, the same way it decides what its own mobile app may do.&lt;/p&gt;

&lt;p&gt;In the proof of concept the CIAM is Keycloak 26 on Cloud Run. The requests are plain RFC 8693, but the rules on top of them are not Keycloak's default behaviour: they are a Keycloak extension we wrote (more on that below). The gateways are Apigee on Google Cloud and API Management on Azure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the party that leaves asks
&lt;/h2&gt;

&lt;p&gt;The gateway could do every exchange instead, presenting the agent's own Entra token as the actor (&lt;code&gt;actor_token&lt;/code&gt;). RFC 8693 allows that too. We chose otherwise, for three reasons.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The token stays with its recipient.&lt;/strong&gt; A token addressed to Agent A can only be exchanged by Agent A, authenticated as itself. Anyone else who gets hold of it, including a gateway, cannot turn it into a token for somewhere else. This is also the default rule in Keycloak's own token exchange, where the requester must be in the subject token's audience.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A compromised gateway can do less.&lt;/strong&gt; When the gateway does every exchange, a gateway under an attacker's control can ask for tokens on behalf of every agent behind it. Now, on internal hops, it only sees tokens addressed to the next destination, and it cannot exchange them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The actor proves itself where the token is issued.&lt;/strong&gt; The CIAM no longer has to trust a gateway's claim that "this agent is acting". The agent authenticates to the CIAM directly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The cost is that every agent, and every service that leaves its business domain, now talks to the CIAM and has a few lines of exchange code. The model never sees any of it (see "What this design asks of you").&lt;/p&gt;

&lt;h2&gt;
  
  
  The exchange, as the agent sends it
&lt;/h2&gt;

&lt;p&gt;When Agent B hands the customer's request to Agent A, Agent B sends this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//ciam.example.com/realms/customers/protocol/openid-connect/token&lt;/span&gt;

&lt;span class="na"&gt;grant_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;urn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;ietf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;oauth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;grant&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;exchange&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;client_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;client_assertion_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;urn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;ietf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;oauth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;assertion&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;jwt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;bearer&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;client_assertion&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Agent&lt;/span&gt; &lt;span class="no"&gt;B&lt;/span&gt;&lt;span class="s1"&gt;'s own Entra token, issued for the CIAM&amp;gt;
&lt;/span&gt;&lt;span class="na"&gt;&amp;amp;subject_token&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="s1"&gt;'s token Agent B received&amp;gt;
&lt;/span&gt;&lt;span class="na"&gt;&amp;amp;subject_token_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;urn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;ietf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;oauth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;access_token&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;requested_token_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;urn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;ietf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;oauth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;access_token&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;audience&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is no &lt;code&gt;actor_token&lt;/code&gt;. The client that authenticated &lt;em&gt;is&lt;/em&gt; the actor. The CIAM refuses a request that carries one.&lt;/p&gt;

&lt;p&gt;The client assertion is the identity from the first post, pointed at a new audience. Agent B gets an Entra token for the CIAM's own application, the same way it gets one for a gateway. That application requires a role assignment: an agent without the role gets &lt;code&gt;AADSTS501051&lt;/code&gt; from Entra and never reaches the CIAM. The CIAM checks the token's signature against Entra's keys, and checks that its subject is the agent's identity. No client secret exists anywhere in this chain. Services do the same with their own platform identity: the accounts API, on Cloud Run, presents a Google identity token issued for the CIAM.&lt;/p&gt;

&lt;p&gt;Before it answers, the CIAM checks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The client is a registered agent or service, enabled to act for customers, and it authenticated with its platform identity.&lt;/li&gt;
&lt;li&gt;The customer's token is valid, and the customer's session is still open.&lt;/li&gt;
&lt;li&gt;The customer's token was addressed to this client. For a service, it was addressed to that service's business domain. Nobody can exchange a token that was not given to them.&lt;/li&gt;
&lt;li&gt;The requested destination is one this client may reach.&lt;/li&gt;
&lt;li&gt;The chain of actors is not longer than the configured limit.&lt;/li&gt;
&lt;li&gt;The scope rules hold (next sections).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the entry, the gateway sends the same request with its own client and its own platform identity: Apigee's service account, or API Management's managed identity. The CIAM accepts only the customer's sign-in token there, addressed to that gateway and with nobody acting yet. A gateway that presents an actor is refused.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the gateway does on the other hops
&lt;/h2&gt;

&lt;p&gt;When Agent B calls Agent A through API Management, it sends two things: its Entra token, which authenticates the call as in the first post, and the token it just obtained from the CIAM for Agent A. The gateway does not exchange. It checks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the customer token was issued by the CIAM, is signed and still valid;&lt;/li&gt;
&lt;li&gt;it is addressed to this destination;&lt;/li&gt;
&lt;li&gt;the caller is the actor written in it: the &lt;code&gt;act&lt;/code&gt; claim names Agent B, and the Entra token says the caller is Agent B;&lt;/li&gt;
&lt;li&gt;for a service, the scope covers the operation being called;&lt;/li&gt;
&lt;li&gt;the customer has not signed out since the token was issued.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first four checks are local. The last one is a question to the CIAM: the gateway asks, as itself, whether the token is still active (&lt;a href="https://www.rfc-editor.org/rfc/rfc7662.html" rel="noopener noreferrer"&gt;RFC 7662&lt;/a&gt; token introspection). A signature cannot answer that, because a token stays correctly signed after the customer signs out. If the CIAM does not clearly answer "active", the request stops there.&lt;/p&gt;

&lt;p&gt;A token handed on without a new exchange fails the second check. A token presented by someone other than its actor fails the third. A token obtained before the customer signed out fails the last. Both gateways answer with the reason, in the same shape:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"customer_context_refused"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"reason"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"presenter_is_not_the_actor"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Four tokens, claim by claim
&lt;/h2&gt;

&lt;p&gt;One question produces four tokens. This is what each party sees:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faoe69poz0ztlhzqfhwzq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faoe69poz0ztlhzqfhwzq.png" alt="Figure 2: the four tokens" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Claim&lt;/th&gt;
&lt;th&gt;What it says&lt;/th&gt;
&lt;th&gt;Along the chain&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sub&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The customer&lt;/td&gt;
&lt;td&gt;Never changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;aud&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The one place that accepts it&lt;/td&gt;
&lt;td&gt;Changes at every exchange&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;azp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Who asked for this token&lt;/td&gt;
&lt;td&gt;The gateway at the entry, then whoever left&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;scope&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What may be done for the customer&lt;/td&gt;
&lt;td&gt;Can only shrink&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;act&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Who is acting for the customer&lt;/td&gt;
&lt;td&gt;Grows by one actor per hop&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;exp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;When it stops working&lt;/td&gt;
&lt;td&gt;Never later than the sign-in token&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The token the accounts API receives:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"sub"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"customer-7f3a…"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"aud"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"accounts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"azp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"agent-a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"scope"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"accounts.read"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"act"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"client_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"agent-a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"agent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"act"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"client_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"agent-b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"agent"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"sid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0kSezak1…"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"exp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1795563127&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few details matter more than they seem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;sub&lt;/code&gt; is always the customer.&lt;/strong&gt; No agent ever becomes the subject. The API answers for the customer in &lt;code&gt;sub&lt;/code&gt; and for nobody else, so an invented customer number in the request body has no effect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;act&lt;/code&gt; is empty at the entry.&lt;/strong&gt; When the customer calls Agent B through Apigee, nobody is acting for them yet. Agent B appears in &lt;code&gt;act&lt;/code&gt; one hop later, when it asks for something in the customer's name. The claim is nested, newest actor first, and says which kind of actor each one is, an agent or a service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;aud&lt;/code&gt; is a business domain, not a microservice.&lt;/strong&gt; The token for the accounts API is addressed to the domain &lt;code&gt;accounts&lt;/code&gt;. Another service of the same domain accepts the same token as it is, with no exchange. Leaving the domain, for example to a payments service, means a new exchange by the service that leaves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;exp&lt;/code&gt; is inherited.&lt;/strong&gt; Tokens last five minutes at most, and an exchanged token never outlives the one it came from. The whole chain expires with the sign-in token, so an agent cannot extend its own authorisation by exchanging again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;sid&lt;/code&gt; ties everything to the session.&lt;/strong&gt; When the customer signs out, the CIAM refuses every further exchange, and the gateways refuse every token that was issued before. We tested both. An agent received a request, the customer signed out, and eight seconds later the agent asked for the next token while its own still had four minutes left: the CIAM refused, and nothing left the agent. In the other case the agent had already exchanged its token for the next hop and was holding it when the customer signed out. API Management refused it with &lt;code&gt;customer_session_ended&lt;/code&gt;, nine times in a row.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scopes: the customer may, the agent may not
&lt;/h2&gt;

&lt;p&gt;The customer in our demo may read accounts and order transfers. The agents may only read.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;ciam&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;domains&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;accounts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;read&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;agents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agent-a&lt;/span&gt;
    &lt;span class="na"&gt;delegation_scopes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;accounts:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;read&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;agent-b&lt;/span&gt;
    &lt;span class="na"&gt;delegation_scopes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;accounts:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;read&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The scope of each token is an intersection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;token scope = what the customer may do
            ∩ the ceiling of every actor on the path
            ∩ what was asked for
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A token for a service carries exactly the scope that was asked for, and the gateway checks it against the operation, taken from the service's own OpenAPI contract:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;/accounts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;security&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;ciam:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;accounts.read&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="na"&gt;/transfers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;post&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;security&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;ciam:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;accounts.transfer&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the same transfer has two outcomes. Ordered by the customer, the gateway exchanges the sign-in token at the entry for one with &lt;code&gt;accounts.transfer&lt;/code&gt; and no &lt;code&gt;act&lt;/code&gt;, and the API accepts it. Asked through the agents, the CIAM refuses Agent A the token it needs, because &lt;code&gt;accounts.transfer&lt;/code&gt; is above its ceiling. The request never leaves the agent.&lt;/p&gt;

&lt;p&gt;The model can decide to try a transfer as often as it likes. It has no say in the outcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three places decide
&lt;/h2&gt;

&lt;p&gt;No single component enforces all of this, and that is on purpose.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnej1q5ef057bp0vo7tmc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnej1q5ef057bp0vo7tmc.png" alt="Figure 3: three places decide" width="800" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The CIAM, at every exchange.&lt;/strong&gt; It sets the upper bound and signs it into the token: destination, scope, actors, lifetime.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The gateway, at every hop of a customer's request.&lt;/strong&gt; At the entry it exchanges the sign-in token. On the other hops it checks that the token is addressed to this destination, presented by its actor, and still backed by an open session. It also refuses operations that are not in the service's contract.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The service.&lt;/strong&gt; It checks the audience and the scope again, answers only for the customer in &lt;code&gt;sub&lt;/code&gt;, and applies its own business rules. Ours refuses any transfer with an agent anywhere in &lt;code&gt;act&lt;/code&gt;, whatever the scope says. A service acting for the customer can still order it.&lt;/p&gt;

&lt;p&gt;All three write down what they decided. A reader of the second post asked how to answer "which agent sent this?" after the fact. The token now carries both halves: &lt;code&gt;act&lt;/code&gt; lists who acted, and &lt;code&gt;azp&lt;/code&gt; says who asked for each token.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this sits among the standards
&lt;/h2&gt;

&lt;p&gt;We kept to what published documents say, and we do not claim more than that.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;RFC 8693&lt;/strong&gt; (Proposed Standard) defines the request, the response and the &lt;code&gt;act&lt;/code&gt; claim. It does not say who the client of an exchange should be. That is left to the authorisation server's policy. Its examples show the service that received a token exchanging it, which is what agents and services do here. It also says that prior actors in a nested &lt;code&gt;act&lt;/code&gt; are informational only, and must not be used for access control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NIST SP 800-204&lt;/strong&gt; (final, 2019) recommends that user session tokens are not passed beyond the gateway, and that a token exchange service sits between gateways. That is the entry exchange.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The IETF WIMSE architecture&lt;/strong&gt; (&lt;a href="https://www.ietf.org/archive/id/draft-ietf-wimse-arch-09.txt" rel="noopener noreferrer"&gt;draft-ietf-wimse-arch-09&lt;/a&gt;, working group draft, informational, 17 November 2026) says that in chains of agents, each hop must explicitly scope and re-bind the security context.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The IETF AIMS draft&lt;/strong&gt; (&lt;a href="https://www.ietf.org/archive/id/draft-ietf-wimse-aims-01.txt" rel="noopener noreferrer"&gt;draft-ietf-wimse-aims-01&lt;/a&gt;, working group draft, informational, 2 November 2026) calls token forwarding an anti-pattern, and says the language model must not have access to an agent's credentials.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The MCP specification&lt;/strong&gt; forbids token passthrough.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of these documents compares "exchange at the gateway" with "exchange in the agent" and declares a winner. Where the exchange happens is a design choice. This post explains ours, and the next sections say what it costs.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we learned the hard way
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Keycloak's standard delegation needs consent.&lt;/strong&gt; Delegation with an actor depends on a &lt;code&gt;may_act&lt;/code&gt; claim, which only comes from the customer's consent. Agents acting for customers by organisation policy needed a token exchange extension, on an interface that is internal to Keycloak.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The entry needed its own rule.&lt;/strong&gt; Keycloak lets the party a token was issued to exchange it again. Without an extra check, a gateway could re-exchange a token it had obtained for an agent and point it somewhere else. Our tests found it. At the entry the CIAM now accepts only a sign-in token addressed to that gateway, with no &lt;code&gt;act&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exchanges can widen scope by default.&lt;/strong&gt; In Keycloak the scope comes from the client that asks, not from the token presented. A built-in client policy makes exchanges narrow-only. Turn it on. It also filters the client's own audience mappers, which the extension had to put back.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent platforms decide what reaches the agent.&lt;/strong&gt; Foundry passes only &lt;code&gt;x-client-*&lt;/code&gt; headers, and only on its Responses endpoint. Agent Runtime strips custom headers, so the gateway puts the customer's token in the A2A message metadata and removes anything the caller planted there.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A gateway's own token can be too old.&lt;/strong&gt; API Management reuses its managed-identity token for about a day. Keycloak accepted client assertions for two hours after they were issued. Everything worked in every test, and failed in the third hour.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Introspection is limited to the token's audience.&lt;/strong&gt; Keycloak only lets a client introspect tokens addressed to it, and the token on an internal hop is addressed to the next agent, not to the gateway. A per-client setting lifts that. We turned it on for the gateways only, and checked that an agent still cannot introspect someone else's token.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure before you blame the identity layer.&lt;/strong&gt; Requests that took four to five seconds felt slow, and the exchanges looked like the obvious suspect. Measured hop by hop, the entry exchange took 50 to 100 ms, each agent's own request to the CIAM 35 to 130 ms, and the checks at API Management about 50 ms, almost all of it the session check. Most of the time went to the model calls.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What this design asks of you
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The agents and services hold an exchange credential.&lt;/strong&gt; Each one can ask the CIAM for tokens, so its credential needs the same care as any other. Ours is not stored: it is the platform identity, issued on demand. The Entra token an agent presents to the CIAM lives for about an hour. On its own it is useless. It only exchanges tokens addressed to that same agent, which last five minutes. The exchange runs in the agent's deterministic code. The model never sees a token, in prompts, in history or in logs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The CIAM is on every hop that acts for a customer.&lt;/strong&gt; Calls with no customer behind them, agent to agent with their own identity as in the first post, never touch it. A customer's request touches it twice at every handover: the exchange, and the gateway's session check. For those requests the CIAM's availability becomes the chain's availability, and the gateways fail closed when it does not answer. We have not load-tested it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The &lt;code&gt;act&lt;/code&gt; chain is an audit trail, not proof.&lt;/strong&gt; The CIAM copies the prior actors from a token it signed itself. Services decide with &lt;code&gt;sub&lt;/code&gt;, &lt;code&gt;aud&lt;/code&gt;, &lt;code&gt;scope&lt;/code&gt; and the current actor, as RFC 8693 says. The full chain is for the audit record.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A ceiling limits damage, not misuse.&lt;/strong&gt; A manipulated agent can still do everything its ceiling allows, for the customer in front of it. Reading a balance is one thing. Operations that move money need the customer's explicit confirmation for that operation, which we have not built. Until then our service refuses them whenever an agent is in the chain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;These are bearer tokens.&lt;/strong&gt; A stolen token works for at most five minutes, at one destination, and only for a caller that matches its actor at the gateway. The current OAuth security best practice (&lt;a href="https://www.rfc-editor.org/rfc/rfc9700.html" rel="noopener noreferrer"&gt;RFC 9700&lt;/a&gt;) recommends binding tokens to their holder. We have not done that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The rules are our own code.&lt;/strong&gt; They live in a Keycloak extension that nobody outside the project has reviewed, on an interface Keycloak does not promise to keep stable. Before production, confirm that your CIAM can express the same rules by configuration, and run the same negative tests against it. Ours has 64 checks, from a gateway presenting an actor to a token used after sign-out.&lt;/p&gt;

&lt;h2&gt;
  
  
  And people inside the organisation?
&lt;/h2&gt;

&lt;p&gt;Not everyone who talks to these agents is a customer. Operators, such as a contact centre, sign in with Entra ID, not at the customer CIAM, and reach the same agents and the same services. The same rules apply to them: every actor named in the token, and a scope that only shrinks. They also bring questions of their own, such as how quickly a person's access can be cut off. That is the next post.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The customer signs in once and never hears about agents.&lt;/li&gt;
&lt;li&gt;The sign-in token stops at the gateway. Every later hop gets its own token: same customer, one destination, five minutes at most.&lt;/li&gt;
&lt;li&gt;Whoever hands the request on asks for the next token, as itself, with no secret. A token can only be exchanged by the party it was given to.&lt;/li&gt;
&lt;li&gt;The token names every actor, says who asked for it, and its scope only shrinks.&lt;/li&gt;
&lt;li&gt;When the customer signs out, the chain stops, including the tokens already issued.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>googlecloud</category>
      <category>azure</category>
      <category>security</category>
      <category>ai</category>
    </item>
    <item>
      <title>One model gateway across clouds: LiteLLM on Cloud Run and Azure with zero API keys</title>
      <dc:creator>Miguel Moreno</dc:creator>
      <pubDate>Sun, 15 Nov 2026 22:23:05 +0000</pubDate>
      <link>https://dev.to/gde/one-model-gateway-across-clouds-litellm-on-cloud-run-and-azure-with-zero-api-keys-3ma7</link>
      <guid>https://dev.to/gde/one-model-gateway-across-clouds-litellm-on-cloud-run-and-azure-with-zero-api-keys-3ma7</guid>
      <description>&lt;p&gt;&lt;em&gt;As of November 2026. All identifiers in this post are examples.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We built a proof of concept with two AI agents: one on Google Cloud, in Agent Runtime, and one on Azure, in Microsoft Foundry. Each agent has its own identity in Microsoft Entra Agent ID and stores no secret.&lt;/p&gt;

&lt;p&gt;Agents call models. This post covers how ours reach them: a model gateway that runs in both clouds, serves Gemini and Azure OpenAI from either side, and holds no API key for any of it.&lt;/p&gt;

&lt;p&gt;During a demo we switched off the gateway in one cloud. The agent's next answer came through the other one, and we barely noticed the switch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F89w4gwr9kg6pjhpvr22p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F89w4gwr9kg6pjhpvr22p.png" alt="Figure 1: the architecture map" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why put a gateway between agents and models
&lt;/h2&gt;

&lt;p&gt;An agent can call a model directly. With two agents that is fine. With fifty it gets uncomfortable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every agent needs credentials for every model provider it uses.&lt;/li&gt;
&lt;li&gt;There is no single place that says which agent may use which model.&lt;/li&gt;
&lt;li&gt;Usage is spread across two clouds and two billing consoles.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A model gateway fixes the three at once. Agents talk to one endpoint, and the rules and the usage records live there. We used &lt;a href="https://docs.litellm.ai/" rel="noopener noreferrer"&gt;LiteLLM&lt;/a&gt; because it speaks to both Vertex AI and Azure OpenAI behind one OpenAI-compatible API.&lt;/p&gt;

&lt;p&gt;The catch is that a gateway usually introduces two new kinds of secret: the keys it holds for the model providers, and the keys it hands out to its callers. We wanted neither.&lt;/p&gt;

&lt;h2&gt;
  
  
  The design
&lt;/h2&gt;

&lt;p&gt;There is one LiteLLM in each cloud, with the same configuration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On Google Cloud it runs on &lt;strong&gt;Cloud Run&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On Azure it runs on &lt;strong&gt;Container Apps&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Each one has a Redis sidecar in the same service, for its own short-lived state.&lt;/li&gt;
&lt;li&gt;Both use one shared Postgres database, on &lt;strong&gt;Cloud SQL&lt;/strong&gt;, for agents, allowed models and usage.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each gateway is connected to both model families. The one on Azure can call Gemini, and the one on Google Cloud can call Azure OpenAI. An agent uses the gateway of its own cloud and gets the same catalogue either way.&lt;/p&gt;

&lt;p&gt;The model list is the same file on both sides:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;model_list&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;model_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gpt-4.1-mini&lt;/span&gt;
    &lt;span class="na"&gt;litellm_params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;azure/gpt-4.1-mini&lt;/span&gt;
      &lt;span class="na"&gt;api_base&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://&amp;lt;your-resource&amp;gt;.openai.azure.com/&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;model_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gemini-3.1-flash-lite&lt;/span&gt;
    &lt;span class="na"&gt;litellm_params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;vertex_ai/gemini-3.1-flash-lite&lt;/span&gt;
      &lt;span class="na"&gt;vertex_project&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;your-project&amp;gt;&lt;/span&gt;
      &lt;span class="na"&gt;vertex_location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;global&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is no &lt;code&gt;api_key&lt;/code&gt; line anywhere in it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Agents sign in as themselves
&lt;/h2&gt;

&lt;p&gt;LiteLLM normally gives each caller a virtual key. That is one more secret per agent, which is exactly what we wanted to avoid.&lt;/p&gt;

&lt;p&gt;Each agent already has an identity in Microsoft Entra Agent ID and can get a token for any audience it has a role on. So the gateway is one more audience, &lt;code&gt;a2a-llm-gateway&lt;/code&gt;, with one role, &lt;code&gt;LLM.Invoke&lt;/code&gt;. The agent sends its own Entra token as the bearer.&lt;/p&gt;

&lt;p&gt;On the LiteLLM side, a custom auth hook replaces the key lookup. Its core is short:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_verify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_JWKS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_signing_key_from_jwt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;algorithms&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"RS256"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="n"&gt;audience&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;AUDIENCES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;issuer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;ISSUER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"require"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"exp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"iss"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"aud"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;user_api_key_auth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;claims&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_thread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_verify&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"LLM.Invoke"&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"roles"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"forbidden: missing app role LLM.Invoke"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;team&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;get_team_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;team_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"azp"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# the agent's ID&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;_requested_model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;team&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;team&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"forbidden: model '{model}' not allowed for this agent"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;UserAPIKeyAuth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;team_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"azp"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;team_models&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;team&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is wired in with one line of configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;general_settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;custom_auth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;custom_auth.user_api_key_auth&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftmkpup2iyvrb5s1bibf9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftmkpup2iyvrb5s1bibf9.png" alt="Figure 2: the checks" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The caller ID in the token is the agent's identity, and LiteLLM's "team" is keyed by that same ID. So usage is recorded per agent without anyone inventing a second naming scheme.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which agent may use which model
&lt;/h2&gt;

&lt;p&gt;The allow-list comes from the inventory file we use to onboard agents:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gcp-agent&lt;/span&gt;
  &lt;span class="na"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;gateway&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gcp&lt;/span&gt;
    &lt;span class="na"&gt;models&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;gemini-3.1-flash-lite&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The onboarding pipeline assigns the &lt;code&gt;LLM.Invoke&lt;/code&gt; role in Entra and creates the team in LiteLLM with those models. An agent that asks for a model outside its list is refused before any provider is called.&lt;/p&gt;

&lt;h2&gt;
  
  
  The gateway holds no model keys either
&lt;/h2&gt;

&lt;p&gt;This is the part that makes the design hold together. Every link from the gateway outwards uses the identity of the workload.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffx4fgci2xlxiof5urrtl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffx4fgci2xlxiof5urrtl.png" alt="Figure 3: the links" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Google Cloud to Gemini.&lt;/strong&gt; The Cloud Run service account has the Vertex AI role. Nothing to configure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Google Cloud to Azure OpenAI.&lt;/strong&gt; LiteLLM asks Google for an OIDC token and presents it to Entra, where a federated credential on an app registration accepts it. In the model entry it is one line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;      &lt;span class="na"&gt;azure_ad_token&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;oidc/google/api://AzureADTokenExchange&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;From Azure to Azure OpenAI.&lt;/strong&gt; The Container App's managed identity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Azure to Gemini.&lt;/strong&gt; This is the reverse federation. The managed identity's token is exchanged at a Google workload identity pool, which lets it act as the same service account the Cloud Run side uses. Google's client libraries do the exchange when they find this credential file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"external_account"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"audience"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"//iam.googleapis.com/projects/&amp;lt;NUMBER&amp;gt;/locations/global/workloadIdentityPools/azure-workloads/providers/&amp;lt;PROVIDER&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"subject_token_type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"urn:ietf:params:oauth:token-type:jwt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"token_url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://sts.googleapis.com/v1/token"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"credential_source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"file"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/var/run/fed/azure-token"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"service_account_impersonation_url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/litellm-runtime@&amp;lt;PROJECT&amp;gt;.iam.gserviceaccount.com:generateAccessToken"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A small sidecar keeps the Azure token in that file fresh. The pool accepts only that one managed identity as a subject.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To the database.&lt;/strong&gt; Both gateways reach Cloud SQL through the Cloud SQL Auth Proxy, as a sidecar, with IAM database authentication:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cloud-sql-proxy --auto-iam-authn --port=5432 &amp;lt;project&amp;gt;:&amp;lt;region&amp;gt;:&amp;lt;instance&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The database user is the service account. There is no password in the connection string.&lt;/p&gt;

&lt;h2&gt;
  
  
  When a gateway goes down
&lt;/h2&gt;

&lt;p&gt;Once every agent in a cloud depends on that cloud's gateway, the gateway is a single point of failure for all of them. So one thing has to be guaranteed: &lt;strong&gt;an agent keeps getting answers when the gateway of its own cloud is unavailable.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Two properties of this design make that possible:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The same token works on both gateways.&lt;/strong&gt; They share the audience, the role and the database. An agent needs nothing new to be served by the other cloud.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Either gateway reaches both model families.&lt;/strong&gt; A model provider being down and a gateway being down are separate failures, and neither one strands an agent.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is also a rule worth stating: &lt;strong&gt;a refusal is not an outage.&lt;/strong&gt; A 401, a 403 or a 429 means the gateway is working and said no. Moving to the other cloud must never be a way around that answer.&lt;/p&gt;

&lt;p&gt;In our test, with the Azure gateway switched off, the Azure agent's next answer came through the Google Cloud gateway. Nobody touched anything, and the switch was barely noticeable.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we learned the hard way
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Let one side own the schema.&lt;/strong&gt; Two LiteLLM instances migrating the same database at startup is a race. One runs the migration. The other starts with &lt;code&gt;DISABLE_SCHEMA_UPDATE=true&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom auth failures come back as 401.&lt;/strong&gt; LiteLLM maps exceptions from the hook that way, even for what is logically a 403. Clients should read the message, not only the code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pin the image version.&lt;/strong&gt; The custom auth hook imports LiteLLM internals. An unpinned upgrade can break sign-in for every agent at once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Turn off message logging.&lt;/strong&gt; With &lt;code&gt;turn_off_message_logging: true&lt;/code&gt; the database keeps who called what and how much, and never the prompts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What this design asks of you
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Per-minute limits are per cloud.&lt;/strong&gt; Rate counters live in Redis, and each cloud has its own. A limit of 60 requests a minute is 60 on each side.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The shared database lives in one cloud.&lt;/strong&gt; Both gateways depend on it. It is the first thing to look at when taking this to production.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The gateway still has an admin key.&lt;/strong&gt; LiteLLM needs a master key for its own administration. It stays in each cloud's secret manager, read by the gateway's identity. No agent ever sees it, and it is not part of any request between an agent and a model.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;One gateway per cloud, same configuration, same catalogue.&lt;/li&gt;
&lt;li&gt;Agents authenticate with the identity they already have.&lt;/li&gt;
&lt;li&gt;The gateway reaches both model providers and its database with workload identity.&lt;/li&gt;
&lt;li&gt;An agent can be served from either cloud with the same token.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Between an agent and a model there is no API key to rotate.&lt;/p&gt;

</description>
      <category>googlecloud</category>
      <category>azure</category>
      <category>ai</category>
      <category>security</category>
    </item>
    <item>
      <title>Google Agent Platform across clouds with SPIFFE: zero secrets between Google Cloud and Microsoft Entra</title>
      <dc:creator>Miguel Moreno</dc:creator>
      <pubDate>Sun, 15 Nov 2026 21:53:40 +0000</pubDate>
      <link>https://dev.to/gde/google-agent-platform-across-clouds-with-spiffe-zero-secrets-between-google-cloud-and-microsoft-1hjg</link>
      <guid>https://dev.to/gde/google-agent-platform-across-clouds-with-spiffe-zero-secrets-between-google-cloud-and-microsoft-1hjg</guid>
      <description>&lt;p&gt;&lt;em&gt;As of November 2026. All identifiers in this post are examples.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We built a proof of concept with two AI agents. Agent A runs on Azure, in Microsoft Foundry. Agent B runs on Google Cloud, in Agent Runtime. They talk to each other over the A2A protocol, in both directions.&lt;/p&gt;

&lt;p&gt;Neither agent stores a password, a service account JSON key or a client secret. This post shows how that works, with the actual requests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3soj8u68zfgvlb1jej3g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3soj8u68zfgvlb1jej3g.png" alt="Figure 1: the architecture map" width="800" height="558"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with the usual approach
&lt;/h2&gt;

&lt;p&gt;The quick way to connect agents across clouds looks like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Google Cloud agent gets an Azure client secret, so it can ask Entra for a token.&lt;/li&gt;
&lt;li&gt;The Azure agent gets a Google service account key, so it can call Google APIs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now each cloud holds a long-lived credential for the other one. Someone has to rotate them. Each one can leak through a log, a repository or a container image. And with a hundred agents you have a few hundred secrets.&lt;/p&gt;

&lt;p&gt;We wanted a design where there is nothing to rotate, because nothing is stored.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea
&lt;/h2&gt;

&lt;p&gt;Two rules carry the whole design.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Each cloud proves who the workload is.&lt;/strong&gt; The agent never holds a credential. The platform it runs on vouches for it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One authority decides what the workload may do.&lt;/strong&gt; We chose Microsoft Entra. People sign in with Entra ID. Agents get identities in Entra Agent ID.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The piece that joins the two rules is &lt;strong&gt;workload identity federation&lt;/strong&gt;. Entra is told: "trust tokens signed by this Google issuer, for exactly this subject". If you have connected GitHub Actions to a cloud without a secret, this is the same pattern.&lt;/p&gt;

&lt;p&gt;What makes it work for agents is that Google gives every agent in Agent Runtime its own identity, expressed as a SPIFFE ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;spiffe://agents.global.org-123456789012.system.id.goog/resources/aiplatform/
  projects/987654321098/locations/europe-west1/reasoningEngines/7300112233445566778
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That ID names one agent, in one project, in one region. Google signs tokens that carry it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Entra side: a blueprint and one federated credential
&lt;/h2&gt;

&lt;p&gt;In Entra Agent ID, an agent identity is created from a &lt;strong&gt;blueprint&lt;/strong&gt;. The blueprint is where credentials live. The agent identity itself cannot hold one, which is a useful property: nobody can attach a password to it later.&lt;/p&gt;

&lt;p&gt;On the blueprint we add a single federated identity credential:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"gcp-agent-spiffe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"issuer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://sts.googleapis.com/v1/organizations/123456789012/locations/global/workloadIdentityPools/agents.global.org-123456789012.system.id.goog"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"subject"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"spiffe://agents.global.org-123456789012.system.id.goog/resources/aiplatform/projects/987654321098/locations/europe-west1/reasoningEngines/7300112233445566778"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"audiences"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"api://AzureADTokenExchange"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Entra will accept a token as proof of identity only if the issuer, the subject and the audience match this record exactly, and the signature checks out against Google's public keys. There are no wildcards.&lt;/p&gt;

&lt;h2&gt;
  
  
  The exchange, hop by hop
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F63fjl7ire0murvqkxr60.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F63fjl7ire0murvqkxr60.png" alt="Figure 2: the token exchange" width="799" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Hop 1: Google proves who the agent is
&lt;/h3&gt;

&lt;p&gt;Inside the agent, one call to the Google auth library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transport&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;requests&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;oauth2&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;id_token&lt;/span&gt;

&lt;span class="n"&gt;google_jwt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;id_token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetch_id_token&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"api://AzureADTokenExchange"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent asked for nothing secret. The runtime returns a JWT signed by Google, with the SPIFFE ID as its subject and the audience we requested.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hop 2: the blueprint vouches for the agent
&lt;/h3&gt;

&lt;p&gt;The agent sends that JWT to Entra in place of a client secret:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//login.microsoftonline.com/&amp;lt;TENANT_ID&amp;gt;/oauth2/v2.0/token&lt;/span&gt;

&lt;span class="na"&gt;grant_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;client_credentials&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;client_id&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;BLUEPRINT_APP_ID&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;client_assertion_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;urn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;ietf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;oauth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;assertion&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;jwt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;bearer&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;client_assertion&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;google_jwt&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;scope&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//AzureADTokenExchange/.default&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;fmi_path&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;AGENT_IDENTITY_ID&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Entra finds the federated credential, validates the Google signature, and checks that the agent identity in &lt;code&gt;fmi_path&lt;/code&gt; belongs to this blueprint. It returns an intermediate token that is only good for the next hop.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hop 3: the agent gets a token for one gateway
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//login.microsoftonline.com/&amp;lt;TENANT_ID&amp;gt;/oauth2/v2.0/token&lt;/span&gt;

&lt;span class="na"&gt;grant_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;client_credentials&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;client_id&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;AGENT_IDENTITY_ID&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;client_assertion_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;urn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;ietf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;oauth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;assertion&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;jwt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;bearer&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;client_assertion&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;intermediate&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="na"&gt;&amp;amp;scope&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//a2a-azure-gateway/.default&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where authorization starts. The gateway application in Entra requires a role assignment. If the agent has no role there, Entra answers &lt;code&gt;AADSTS501051&lt;/code&gt; and issues nothing.&lt;/p&gt;

&lt;p&gt;If it has one, the access token looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"iss"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://login.microsoftonline.com/&amp;lt;TENANT_ID&amp;gt;/v2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"aud"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;a2a-azure-gateway app id&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"azp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;AGENT_IDENTITY_ID&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"roles"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"A2A.Invoke.agent-a"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One audience, one role, valid for about an hour. The agent caches it and calls the gateway with it.&lt;/p&gt;

&lt;p&gt;Each token in the chain is narrower than the one before it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frkxdi3hb9l2pv8nwtf9b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frkxdi3hb9l2pv8nwtf9b.png" alt="Figure 3: what each token says" width="800" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Python this is about twenty lines of plain HTTP. We did not use MSAL, because it does not expose &lt;code&gt;fmi_path&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Authorization: three locks
&lt;/h2&gt;

&lt;p&gt;Authenticating is not enough to get in. A request has to pass three independent checks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flxfzuafwhuqlvo6nebt2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flxfzuafwhuqlvo6nebt2.png" alt="Figure 4: three locks" width="800" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lock 1, Entra.&lt;/strong&gt; Each target agent has its own role on the gateway application, such as &lt;code&gt;A2A.Invoke.agent-a&lt;/code&gt;. The role is assigned only to the agents allowed to call that target. No role, no token.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lock 2, the gateway.&lt;/strong&gt; API Management on Azure and Apigee on Google Cloud both validate the signature, the tenant, the audience and the expiry. Then they check that the token carries the role for the route being called, that the caller is on the allow-list for that route, and that it is not on the deny-list. The Apigee version of that check is small:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;roles&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                 &lt;span class="c1"&gt;// the role for THIS target&lt;/span&gt;
      &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;allowed_callers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;azp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;        &lt;span class="c1"&gt;// the caller is expected here&lt;/span&gt;
      &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;isolated&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                           &lt;span class="c1"&gt;// and nobody pulled the plug&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A role for agent X gives no access to agent Y behind the same gateway.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lock 3, the backend.&lt;/strong&gt; The gateway drops the caller's token and calls the agent with its own identity. On Azure, only the gateway's managed identity may invoke the Foundry agent. On Google Cloud, only the Apigee service account may query the Agent Runtime engine. A call that goes around the gateway bounces, even with a valid Entra token.&lt;/p&gt;

&lt;h2&gt;
  
  
  The other direction
&lt;/h2&gt;

&lt;p&gt;Agent A calling Agent B is the same design with less visible plumbing. Foundry already holds a federated credential for its agents, so the code is one line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;DefaultAzureCredential&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_token&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"api://a2a-gcp-gateway/.default"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apigee validates that Entra token with the same three checks, then calls Agent B with its own service account.&lt;/p&gt;

&lt;p&gt;Both directions end up symmetrical: an Entra token for the gateway of the other cloud, and a gateway that is the only door to its agent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pulling the plug
&lt;/h2&gt;

&lt;p&gt;Entra access tokens live for about an hour, so removing a role does not stop an agent right away. For that there is a deny-list in both gateways. It holds the agent's ID as a caller and its name as a target, so an isolated agent can neither call nor be called.&lt;/p&gt;

&lt;p&gt;In our rehearsals the first refusal arrived in under a second. The worst case is bounded by a ten-second cache in the gateway.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we learned the hard way
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Never delete and recreate the Google agent.&lt;/strong&gt; Its engine ID is part of the SPIFFE ID. A new agent has a new subject, and the federated credential stops matching. Update it in place.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;AADSTS70021&lt;/code&gt; means the federated credential does not match.&lt;/strong&gt; Check the issuer, subject and audience character by character, including a trailing slash. Also wait a little: new credentials take time to propagate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authorize on &lt;code&gt;azp&lt;/code&gt; and &lt;code&gt;roles&lt;/code&gt;.&lt;/strong&gt; Tokens also carry a claim for the parent blueprint. Do not use it for access decisions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quotas shape the design.&lt;/strong&gt; An application accepts at most 20 federated credentials, and a blueprint at most 250 agent identities. Subject patterns are not available for the Google issuer, so each agent needs its own exact credential.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automate onboarding.&lt;/strong&gt; In our setup an agent is one entry in an inventory file. A pipeline creates the blueprint, the federated credential, the agent identity, the roles and the gateway allow-lists. With the runtime already deployed, that run took 22.8 seconds.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What this design asks of you
&lt;/h2&gt;

&lt;p&gt;No stored secret does not mean no responsibility. Two things take the place of the secrets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The control planes become the credential.&lt;/strong&gt; Whoever can update the agent's code on Google Cloud can act as the agent. Whoever can edit the blueprint in Entra can add a federated credential of their own. Keep both permissions with very few identities, and alert on changes to federated credentials.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use one blueprint per agent.&lt;/strong&gt; The federated credential lives on the blueprint, and a workload that authenticates as the blueprint can ask for a token for any agent identity under it. With one blueprint per agent, a compromised agent can only ever be itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The result is a small set of moving parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The platform proves the workload.&lt;/li&gt;
&lt;li&gt;One federated credential connects that proof to Entra.&lt;/li&gt;
&lt;li&gt;One role per target says who may call whom.&lt;/li&gt;
&lt;li&gt;The gateway enforces it, and the backend trusts only the gateway.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nothing in that list has to be rotated.&lt;/p&gt;

</description>
      <category>googlecloud</category>
      <category>azure</category>
      <category>security</category>
      <category>ai</category>
    </item>
    <item>
      <title>Multi-Region Resilience on GKE: Combining Multi-Cluster Gateways with Istio Ambient Mesh</title>
      <dc:creator>Miguel Moreno</dc:creator>
      <pubDate>Tue, 30 Jun 2026 13:03:46 +0000</pubDate>
      <link>https://dev.to/gde/multi-region-resilience-on-gke-combining-multi-cluster-gateways-with-istio-ambient-mesh-3h44</link>
      <guid>https://dev.to/gde/multi-region-resilience-on-gke-combining-multi-cluster-gateways-with-istio-ambient-mesh-3h44</guid>
      <description>&lt;p&gt;In the current landscape of hyper-distributed systems, resilience is no longer an infrastructure checkbox—it is a competitive moat. As organizations scale across global boundaries, the challenge is to provide seamless connectivity while maintaining regional autonomy.&lt;/p&gt;

&lt;p&gt;A strong architectural pattern for regulated, multi-region platforms is the strategic fusion of &lt;strong&gt;GKE Multi-cluster Gateways&lt;/strong&gt; and &lt;strong&gt;Istio Ambient Mesh&lt;/strong&gt;. This combination creates a baseline for stability that is both operationally resilient and transparent to developers.&lt;/p&gt;




&lt;h2&gt;
  
  
  North-South: A Unified Entry Point Across Regions
&lt;/h2&gt;

&lt;p&gt;Managing disparate load balancers for every region creates operational debt. The modern North-South strategy requires a unified logical entry point that respects physical regional constraints.&lt;/p&gt;

&lt;p&gt;Using the &lt;code&gt;gke-l7-cross-regional-internal-managed-mc&lt;/code&gt; GatewayClass, architects can deploy a single internal Gateway resource that requests VIPs across multiple regions. While it provides a "single entry point" abstraction, traffic is intelligently directed by the Google Cloud backbone to the closest healthy backend GKE cluster.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdubrcbapc84jpof6ilt5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdubrcbapc84jpof6ilt5.png" alt="Global Internal Gateway Architecture" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Fleet Machinery:
&lt;/h3&gt;

&lt;p&gt;This resilience is not "magic"; it is powered by GKE’s &lt;strong&gt;Fleet&lt;/strong&gt; and &lt;strong&gt;Multi-cluster Services (MCS)&lt;/strong&gt;. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Config Cluster:&lt;/strong&gt; Gateway and HTTPRoute resources are applied once to a designated config cluster, acting as the control center for the entire fleet.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Service Discovery:&lt;/strong&gt; The Gateway controller leverages &lt;code&gt;ServiceImport&lt;/code&gt; resources to discover backends across different clusters, ensuring that routing is global while execution is regional.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  East-West: Zero Trust Without the Sidecar Tax
&lt;/h2&gt;

&lt;p&gt;Once traffic enters the VPC, the focus shifts to secure service-to-service communication. For years, sidecars were the only answer, but they came with a heavy "tax" on CPU and memory. &lt;strong&gt;Istio Ambient Mesh&lt;/strong&gt; provides a lower operational and resource overhead than per-pod sidecars by splitting the mesh into two layers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F814124lj72ik7yw8n4a8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F814124lj72ik7yw8n4a8.png" alt="Istio Ambient Mesh Multi-Primary" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Precise Policy Enforcement:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ztunnel (L4 Layer):&lt;/strong&gt; A per-node proxy focused strictly on L3/L4 connectivity, mTLS, authentication, and basic telemetry. It does not interpret HTTP, keeping the footprint minimal.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Waypoint Proxies (L7 Layer):&lt;/strong&gt; Waypoints are mandatory whenever L7 logic is required—such as header-based routing, HTTP-level authorization, or complex traffic splitting. By deploying Waypoints only where needed (per namespace or service account), resource consumption is optimized.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-Primary Resilience:&lt;/strong&gt; In a multi-primary topology, each cluster runs its own istiod control plane, reducing the risk of a single control-plane failure cascading across regions. Cross-cluster discovery is still explicitly configured, but control-plane ownership remains distributed.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  When to Use This Pattern
&lt;/h2&gt;

&lt;p&gt;This pattern is especially useful when you need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Private multi-region entry points&lt;/strong&gt; for internal workloads running on GKE.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Health-based routing&lt;/strong&gt; across multiple clusters without exposing each cluster independently.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regional autonomy&lt;/strong&gt; while keeping a centralized and declarative traffic entry model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;East-West mTLS&lt;/strong&gt; between workloads without deploying sidecars everywhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;L7 policy enforcement only where required&lt;/strong&gt;, using waypoint proxies selectively.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A stronger baseline for regulated platforms&lt;/strong&gt;, where resilience, segmentation, identity, and operational clarity are mandatory.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What This Architecture Does Not Solve Automatically
&lt;/h2&gt;

&lt;p&gt;It is critical to recognize that infrastructure-level resilience is a foundation, not a complete solution. Implementing GKE Gateways and Istio Ambient does not replace disciplined service design.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9pm6188gu26zo90g4w6h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9pm6188gu26zo90g4w6h.png" alt="The Boundary of Infrastructure Resilience" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This architecture improves connectivity, but &lt;strong&gt;the following challenges remain the responsibility of the application architect:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Application State &amp;amp; DB Replication:&lt;/strong&gt; Neither the Gateway nor the Mesh can solve for data consistency or replication lag across regions.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Health-check Design:&lt;/strong&gt; A shallow health check can lead to "zombie" backends that the Gateway continues to target.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;DNS &amp;amp; Failover Strategy:&lt;/strong&gt; Global DNS management and the testing of regional failover scenarios remain vital for total business continuity.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Result: A Stronger Baseline
&lt;/h2&gt;

&lt;p&gt;The synergy between Google Cloud’s managed networking and the efficiency of Istio Ambient Mesh represents a significant evolution. By removing the sidecar tax and unifying regional entry points, we reduce the blast radius of failures and the cost of security.&lt;/p&gt;

&lt;p&gt;The result is not a silver bullet, but a stronger baseline for regulated, multi-region platforms. It allows engineering teams to focus on the high-value application resilience patterns, knowing that the underlying network fabric is both robust and transparent.&lt;/p&gt;




&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://cloud.google.com/kubernetes-engine/docs/how-to/deploy-internal-multi-cluster-gateway" rel="noopener noreferrer"&gt;GKE Gateway API: Precise Implementation Guide&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://istio.io/latest/docs/ops/ambient/architecture/" rel="noopener noreferrer"&gt;Istio Ambient Mesh: Ztunnel and Waypoint Architecture&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://cloud.google.com/kubernetes-engine/docs/concepts/multi-cluster-services" rel="noopener noreferrer"&gt;Google Cloud MCS: Multi-cluster Service Discovery&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gcp</category>
      <category>gke</category>
      <category>istio</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
