Skip to content

Test + doc: x-ms-tokenboundauth header for AKV mTLS PoP via ExtraHeaderParameters#3864

Merged
gladjohn merged 1 commit into
masterfrom
gladjohn/msi-mtls-akv-tokenboundauth-header
Jun 17, 2026
Merged

Test + doc: x-ms-tokenboundauth header for AKV mTLS PoP via ExtraHeaderParameters#3864
gladjohn merged 1 commit into
masterfrom
gladjohn/msi-mtls-akv-tokenboundauth-header

Conversation

@gladjohn

@gladjohn gladjohn commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Azure Key Vault requires x-ms-tokenboundauth: true on mTLS PoP requests to trigger TLS renegotiation for client certificate binding. Without it, AKV returns 401: Client certificate required for using MTLS_POP token.

This PR validates and documents that IdWeb's existing ExtraHeaderParameters config surface handles this correctly — no production code changes needed.

Changes

  • 16 unit tests covering:
    • Happy path (commercial + sovereign clouds)
    • MSI system-assigned and user-assigned full config shape
    • FIC full config shape
    • Duplicate prevention (case-insensitive)
    • Reserved header filtering
    • CustomizeHttpRequestMessage dynamic approach
    • Non-AKV resources correctly omit the header
  • Updated daemon-app-msi-mtls sample with ExtraHeaderParameters in appsettings.json
  • Documented the AKV requirement in Program.cs header comment

Developer configuration

{
  "AzureKeyVault": {
    "BaseUrl": "https://myvault.vault.azure.net/",
    "RequestAppToken": true,
    "ProtocolScheme": "MTLS_POP",
    "Scopes": ["https://vault.azure.net/.default"],
    "AcquireTokenOptions": {
      "ManagedIdentity": { "UserAssignedClientId": "<your-client-id>" }
    },
    "ExtraHeaderParameters": { "x-ms-tokenboundauth": "true" }
  }
}

Why not a DelegatingHandler?

Per reviewer feedback: hardcoding vault host strings is brittle. ExtraHeaderParameters is the IdWeb-native extensibility point — it's declarative, JSON-configurable, and lets each developer control which services get the header.

@gladjohn gladjohn requested a review from a team as a code owner June 16, 2026 02:52
Comment thread src/Microsoft.Identity.Web.TokenAcquisition/TokenBoundAuthHeaderHandler.cs Outdated
@bgavrilMS bgavrilMS requested a review from MZOLN June 16, 2026 10:46

@bgavrilMS bgavrilMS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No hardcoding of resource strings. Brittle solution. Ppl should use extra header API

@gladjohn gladjohn force-pushed the gladjohn/msi-mtls-akv-tokenboundauth-header branch from 68fa462 to dc25a93 Compare June 17, 2026 13:35
@gladjohn gladjohn changed the title Add x-ms-tokenboundauth header for AKV mTLS PoP renegotiation Test + doc: x-ms-tokenboundauth header for AKV mTLS PoP via ExtraHeaderParameters Jun 17, 2026
@gladjohn gladjohn requested a review from bgavrilMS June 17, 2026 13:36
@gladjohn gladjohn force-pushed the gladjohn/msi-mtls-akv-tokenboundauth-header branch from dc25a93 to 2d8733d Compare June 17, 2026 13:37
…ters

Azure Key Vault requires 'x-ms-tokenboundauth: true' on mTLS PoP requests to
trigger TLS renegotiation for client cert binding. Without it, AKV returns 401.

Instead of hardcoding vault host detection in a DelegatingHandler, this uses
IdWeb's existing ExtraHeaderParameters config surface — letting developers
declare the header per-service in appsettings.json.

Changes:
- Add 16 unit tests proving ExtraHeaderParameters correctly applies the header
  for MSI (user-assigned + system-assigned), FIC, and sovereign cloud scenarios
- Update daemon-app-msi-mtls sample with ExtraHeaderParameters config
- Document the AKV requirement in Program.cs header comment

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@gladjohn gladjohn force-pushed the gladjohn/msi-mtls-akv-tokenboundauth-header branch from 2d8733d to e393115 Compare June 17, 2026 13:38
@gladjohn gladjohn merged commit 2015a3b into master Jun 17, 2026
4 checks passed
@gladjohn gladjohn deleted the gladjohn/msi-mtls-akv-tokenboundauth-header branch June 17, 2026 13:52
This was referenced Jun 24, 2026
This was referenced Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants