A. B. Khan

Identity propagation across hops — keeping the user alive

The Mesh Series · Article 17

On-behalf-of flowMicrosoft Entra IDScopes & app rolesWorkload identitymTLS

Cover: Identity propagation across hops

The Mesh Series · Article 17 · Where Entra meets Istio

Article 10 said the user's identity terminates at the edge and rides inward as context. Article 16 wrote policy against it. We've been quietly assuming the user survives the trip. Now the uncomfortable detail: a user token is minted for exactly one audience — the first service it hits. The moment that service needs to call a second one on the user's behalf, the token it's holding is the wrong token for the next hop. So how does the user identity cross the hop without either being lost or being abused?

There are three things a service can do when it needs to call downstream, and two of them are traps.

Diagram: obo

Re-sending the raw token is the instinct, and it's wrong twice. The token's audience is payment-api, not ledger — so a correctly-configured ledger (Article 12) rejects it, and an incorrectly-configured one accepts it, which is the confused-deputy hole. Either way you're also spraying the user's bearer token across your service graph, multiplying the places it can leak. Calling as the workload only — the ledger authenticates the payment service over mTLS and nothing more — is safe but amnesiac: the ledger knows a trusted service called, but the user has vanished, and your "service X acting for user Y" audit line is now just "service X." The right move is the On-Behalf-Of exchange: the payment service asks Entra to swap the user's token for a new one, correctly scoped to the ledger, that still carries the user's identity.

Why regulated enterprises should care

The whole audit thesis of this series lives or dies on the user surviving the call chain.

Article 10 promised the auditor a two-part answer: which service and which user. Article 14 delivered the service half on the wire; the user half only holds if identity propagates. Lose the user at the first hop and a request three services deep is attributable to a workload but not a human — you can say "the ledger service wrote this" but not "acting for branch operator Y." Under CERT-In's incident timeline or a SAMA assessment, "a trusted internal service did it, we're not sure on whose behalf" is the answer that becomes a finding. The propagated user identity is what keeps the human accountable all the way to the data.

And the trap has teeth. Naive header pass-through — copy the incoming Authorization header onto the outbound call — feels like propagation but is the confused-deputy pattern wearing a helpful face. It only "works" when the downstream service isn't validating audience properly, which means the day someone fixes the downstream validation (as they should), your call chain breaks — or, until they do, any service can replay a user's token laterally. Propagation done right narrows authority at each hop; pass-through widens it.

How the pieces come together

The On-Behalf-Of flow is an OAuth2 token exchange, and Microsoft.Identity.Web makes it a one-liner. The incoming user token isn't forwarded; it's presented back to Entra along with the service's own credential (its federated workload identity, Article 15 — no secret), and Entra returns a fresh access token whose audience is the downstream API and whose subject is still the original user. The user's oid survives; the audience is corrected; the service's own identity vouches for the exchange.

Two identities now ride every hop, exactly as Article 10 framed it: the workload identity secures the transport (mTLS, the mesh) and the user identity — the OBO-minted token — travels as the L7 credential the next service validates (Article 12) and authorizes against (Article 16, the requestPrincipals). The mesh moves the bytes and proves the service; the OBO token proves the human. Neither substitutes for the other.

Show the code

Wire the service to acquire downstream tokens, then ask for one scoped to the next hop — Entra does the exchange. You never touch the incoming token:

Code: obo

The anti-pattern, for contrast — never do this:

Code: antipattern

The ledger then validates its OBO token exactly as Article 12 described — audience api://ledger, pinned — and reads oid to know the human. Two hops, two correctly-scoped tokens, one continuous user identity.

Security · Audit · Integration

Security property gained. Authority narrows at each hop instead of spreading. Each downstream token is scoped to exactly the next service and the exact permission needed, and the user's original bearer token never leaves the first service — so there's no token to lift from three services deep, and no service holds more authority than the specific call requires.

Audit evidence produced. The user identity is present and verifiable at every hop, so "service X, acting for user Y, wrote to the ledger" is true at hop three, not just hop one. The two-identity audit line the series has been building toward holds across the whole call chain — the human stays accountable all the way to the data.

How it integrates. OBO is the propagation mechanism for the user plane (Article 10) across the service graph; it rides on top of the mTLS workload plane (Article 14), reuses the federated workload identity for the exchange (Article 15), is validated at each hop (Article 12), and authorized against the propagated requestPrincipals (Article 16). The scopes it requests — Ledger.Write above — are the subject of the next article.

Alternatives, and when you'd actually pick them

Client-credentials (call as the workload, no user). Legitimate — and correct — when there is no user: a batch job, a scheduled reconciliation, a system-to-system call that isn't on anyone's behalf. The service authenticates as itself with its federated identity and the downstream authorizes the workload. Use it precisely when the honest answer to "on whose behalf?" is "nobody's." Don't use it to paper over a user context you dropped.

Raw token pass-through. Not an alternative — the anti-pattern named above. It's the confused-deputy pattern, it only works against a broken downstream, and it sprays bearer tokens across the graph. If you see Authorization headers being copied onto outbound calls, that's the thing to fix.

Generic token exchange (RFC 8693) / non-Entra IdP. If your identity provider isn't Entra, the same shape — exchange the inbound token for a correctly-scoped downstream token — is standardised as RFC 8693 token exchange, and Keycloak and others implement it. The principle is identical; only the library and endpoint change. Reach for it when the IdP isn't Entra; the "narrow authority per hop" rule doesn't.

There's a payoff to doing this properly that goes beyond authorization. Because every hop carries the real user identity rather than an anonymous service call, you can trace a single user's action end to end across the whole chain and log the complete lifecycle of what they did — which is exactly the visibility a regulator asks for when they want to see not just that a system acted, but who it acted for. That end-to-end user trace is a later article in its own right; propagation done right is what makes it possible at all.

From the toy to the standard

The toy is one OBO exchange between two services. The industry-standard version keeps the user identity verifiable at every hop of every user-initiated call chain, each downstream token minted fresh and scoped to exactly the next service and the exact permission, no raw bearer token ever forwarded, and system-initiated calls using workload identity honestly instead of pretending a user is present. Two identities per hop — the workload on the wire, the user in the token — all the way to the data, so the human never disappears from the audit trail.

The OBO call above asked for a very specific thing: api://ledger/Ledger.Write. Not "a token for the ledger" — a token for writing to it. That string is a scope, and the difference between a scope and an app role, and how each becomes an enforceable authorization decision, is the next article.

That's Article 18: scopes, roles, and app roles.


Next in the series — Article 18: Scopes, roles, and app roles.

Key skills & topics in this article

On-behalf-of flowMicrosoft Entra IDScopes & app rolesWorkload identitymTLS

  • #ServiceMesh
  • #Istio
  • #Azure
  • #dotnet
  • #ZeroTrust
  • #Kubernetes

Also on LinkedIn.