Restore CustomizeHttpRequestMessage to run after the authorization header#3943
Merged
bgavrilMS merged 1 commit intoJul 14, 2026
Merged
Conversation
…ader CustomizeHttpRequestMessage is documented to run after the message is formed, including the Authorization header, and just before it is sent. #3902 moved it before authorization-header creation (to flow the finalized request for request-binding), which regressed callers that read the header in the callback - they saw a null Authorization header. This moves only the CustomizeHttpRequestMessage invocation back to after the header is set, leaving the request-flow plumbing (options material + SetHttpRequestMessage) untouched. Adds a regression test asserting the callback observes the Authorization header. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
neha-bhargava
force-pushed
the
nebharg/fix-customizehttprequestmessage-regression
branch
from
July 14, 2026 04:35
5de5090 to
9f8e174
Compare
neha-bhargava
added a commit
that referenced
this pull request
Jul 14, 2026
…ownstreamApi Honor the new AuthorizationHeaderProviderOptions hooks from Microsoft.Identity.Abstractions 12.5.0: - OnBeforeAuthHeaderCreation runs before the authorization header is created and signed, so callers can shape the request that request-binding protocols (SignedHttpRequest q/h/b) sign, ensuring the signature covers the finalized request. - OnAfterAuthHeaderCreation runs after the header is attached, alongside CustomizeHttpRequestMessage. Also declare IAuthorizationHeaderProvider2 only on the Base/Default header providers (it already extends IAuthorizationHeaderProvider). Stacked on the regression fix (#3943). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
neha-bhargava
added a commit
that referenced
this pull request
Jul 14, 2026
…ownstreamApi Honor the new AuthorizationHeaderProviderOptions hooks from Microsoft.Identity.Abstractions 12.5.0: - OnBeforeAuthHeaderCreation runs before the authorization header is created and signed, so callers can shape the request that request-binding protocols (SignedHttpRequest q/h/b) sign, ensuring the signature covers the finalized request. Also propagated through MicrosoftIdentityMessageHandler. - OnAfterAuthHeaderCreation runs after the header is attached. It is a symmetric alias of the pre-existing CustomizeHttpRequestMessage (same delegate), so the "after" callback is invoked exactly once. Also declare IAuthorizationHeaderProvider2 only on the Base/Default header providers (it already extends IAuthorizationHeaderProvider). Stacked on the regression fix (#3943). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pmaytak
approved these changes
Jul 14, 2026
bgavrilMS
approved these changes
Jul 14, 2026
bgavrilMS
approved these changes
Jul 14, 2026
neha-bhargava
added a commit
that referenced
this pull request
Jul 14, 2026
…ownstreamApi Honor the new AuthorizationHeaderProviderOptions hooks from Microsoft.Identity.Abstractions 12.5.0: - OnBeforeAuthHeaderCreation runs before the authorization header is created and signed, so callers can shape the request that request-binding protocols (SignedHttpRequest q/h/b) sign, ensuring the signature covers the finalized request. - OnAfterAuthHeaderCreation runs after the header is attached. The pre-existing CustomizeHttpRequestMessage is still invoked at the same point for backwards compatibility. Both hooks are propagated through MicrosoftIdentityMessageHandler. Also declare IAuthorizationHeaderProvider2 only on the Base/Default header providers (it already extends IAuthorizationHeaderProvider), and type the Base provider's delegate field as IAuthorizationHeaderProvider2 to avoid upcasting at the metadata delegation sites. Stacked on the regression fix (#3943). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
neha-bhargava
added a commit
that referenced
this pull request
Jul 14, 2026
…ownstreamApi Honor the new AuthorizationHeaderProviderOptions hooks from Microsoft.Identity.Abstractions 12.5.0: - OnBeforeAuthHeaderCreation runs before the authorization header is created and signed, so callers can shape the request that request-binding protocols (SignedHttpRequest q/h/b) sign, ensuring the signature covers the finalized request. - OnAfterAuthHeaderCreation runs after the header is attached. The pre-existing CustomizeHttpRequestMessage is still invoked at the same point for backwards compatibility. Both hooks are propagated through MicrosoftIdentityMessageHandler. Also declare IAuthorizationHeaderProvider2 only on the Base/Default header providers (it already extends IAuthorizationHeaderProvider), and type the Base provider's delegate field as IAuthorizationHeaderProvider2 to avoid upcasting at the metadata delegation sites. Stacked on the regression fix (#3943). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
neha-bhargava
added a commit
that referenced
this pull request
Jul 14, 2026
…ownstreamApi Honor the new AuthorizationHeaderProviderOptions hooks from Microsoft.Identity.Abstractions 12.5.0: - OnBeforeAuthHeaderCreation runs before the authorization header is created and signed, so callers can shape the request that request-binding protocols (SignedHttpRequest q/h/b) sign, ensuring the signature covers the finalized request. - OnAfterAuthHeaderCreation runs after the header is attached. The pre-existing CustomizeHttpRequestMessage is still invoked at the same point for backwards compatibility. Both hooks are propagated through MicrosoftIdentityMessageHandler. Also declare IAuthorizationHeaderProvider2 only on the Base/Default header providers (it already extends IAuthorizationHeaderProvider), and type the Base provider's delegate field as IAuthorizationHeaderProvider2 to avoid upcasting at the metadata delegation sites. Stacked on the regression fix (#3943). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
neha-bhargava
added a commit
that referenced
this pull request
Jul 14, 2026
…ownstreamApi Honor the new AuthorizationHeaderProviderOptions hooks from Microsoft.Identity.Abstractions 12.5.0: - OnBeforeAuthHeaderCreation runs before the authorization header is created and signed, so callers can shape the request that request-binding protocols (SignedHttpRequest q/h/b) sign, ensuring the signature covers the finalized request. - OnAfterAuthHeaderCreation runs after the header is attached. The pre-existing CustomizeHttpRequestMessage is still invoked at the same point for backwards compatibility. Both hooks are propagated through MicrosoftIdentityMessageHandler. Also declare IAuthorizationHeaderProvider2 only on the Base/Default header providers (it already extends IAuthorizationHeaderProvider), and type the Base provider's delegate field as IAuthorizationHeaderProvider2 to avoid upcasting at the metadata delegation sites. Stacked on the regression fix (#3943). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
neha-bhargava
added a commit
that referenced
this pull request
Jul 14, 2026
…ownstreamApi Honor the new AuthorizationHeaderProviderOptions hooks from Microsoft.Identity.Abstractions 12.5.0: - OnBeforeAuthHeaderCreation runs before the authorization header is created and signed, so callers can shape the request that request-binding protocols (SignedHttpRequest q/h/b) sign, ensuring the signature covers the finalized request. - OnAfterAuthHeaderCreation runs after the header is attached. The pre-existing CustomizeHttpRequestMessage is still invoked at the same point for backwards compatibility. Both hooks are propagated through MicrosoftIdentityMessageHandler. Also declare IAuthorizationHeaderProvider2 only on the Base/Default header providers (it already extends IAuthorizationHeaderProvider), and type the Base provider's delegate field as IAuthorizationHeaderProvider2 to avoid upcasting at the metadata delegation sites. Stacked on the regression fix (#3943). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
gladjohn
pushed a commit
that referenced
this pull request
Jul 14, 2026
…ownstreamApi (#3942) Honor the new AuthorizationHeaderProviderOptions hooks from Microsoft.Identity.Abstractions 12.5.0: - OnBeforeAuthHeaderCreation runs before the authorization header is created and signed, so callers can shape the request that request-binding protocols (SignedHttpRequest q/h/b) sign, ensuring the signature covers the finalized request. - OnAfterAuthHeaderCreation runs after the header is attached. The pre-existing CustomizeHttpRequestMessage is still invoked at the same point for backwards compatibility. Both hooks are propagated through MicrosoftIdentityMessageHandler. Also declare IAuthorizationHeaderProvider2 only on the Base/Default header providers (it already extends IAuthorizationHeaderProvider), and type the Base provider's delegate field as IAuthorizationHeaderProvider2 to avoid upcasting at the metadata delegation sites. Stacked on the regression fix (#3943). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Jul 17, 2026
Merged
Closed
Open
This was referenced Jul 19, 2026
Closed
Open
Merged
github-actions Bot
pushed a commit
to EelcoLos/nx-tinkering
that referenced
this pull request
Jul 21, 2026
Pinned [Microsoft.Identity.Web](https://github.com/AzureAD/microsoft-identity-web) at 4.13.2. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Identity.Web's releases](https://github.com/AzureAD/microsoft-identity-web/releases)._ ## 4.13.2 ## What's Changed * Apply reserved-header handling on the request-clone path and cover all X-MS-TOKEN- headers by @iNinja in AzureAD/microsoft-identity-web#3915 * Restore independent PR pipeline + pool-aware MI identity + net462/472 unit tests by @iarekk in AzureAD/microsoft-identity-web#3935 * Post-release 4.13.0: changelog and public API shipped move by @neha-bhargava in AzureAD/microsoft-identity-web#3937 * Remove redundant 'Run unit tests' GitHub Action by @iarekk in AzureAD/microsoft-identity-web#3939 * Apply consistent redirect-URI validation on AccountController.SignIn by @iNinja in AzureAD/microsoft-identity-web#3940 * Fix duplicate logging of MsalUiRequiredException (in-repo copy of #3910) by @iarekk in AzureAD/microsoft-identity-web#3941 * Use MSAL's recent UserFIC API for agentic flows by @Avery-Dunn in AzureAD/microsoft-identity-web#3842 * Restore CustomizeHttpRequestMessage to run after the authorization header by @neha-bhargava in AzureAD/microsoft-identity-web#3943 * Bump Microsoft.IdentityModel.Tokens.Saml from 5.7.0 to 8.19.1 by @dependabot[bot] in AzureAD/microsoft-identity-web#3909 * Revert #3909: keep OWIN Saml/WsFederation on 5.7.0 by @iarekk in AzureAD/microsoft-identity-web#3944 * Bump Microsoft.Identity.Abstractions from 12.4.0 to 12.5.0 by @neha-bhargava in AzureAD/microsoft-identity-web#3947 * Add OnBeforeAuthHeaderCreation / OnAfterAuthHeaderCreation hooks to DownstreamApi by @neha-bhargava in AzureAD/microsoft-identity-web#3942 * Update IdentityModelV5Version and SamlPackageVersion to 5.7.1 in proj… by @trwalke in AzureAD/microsoft-identity-web#3950 * Rename retired MSALMSIV2 agent pool to MISEManagedIdentity by @gladjohn with @Copilot in AzureAD/microsoft-identity-web#3949 * Improve IDW10109 error handling for credential loading failures by @Avery-Dunn in AzureAD/microsoft-identity-web#3946 * Bump MSAL dependencies to 4.86.1 in central props by @gladjohn with @Copilot in AzureAD/microsoft-identity-web#3953 * Bump the notsecurity group with 3 updates by @dependabot[bot] in AzureAD/microsoft-identity-web#3954 **Full Changelog**: AzureAD/microsoft-identity-web@4.13.0...4.13.2 Commits viewable in [compare view](AzureAD/microsoft-identity-web@4.13.0...4.13.2). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Jul 21, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CustomizeHttpRequestMessageis documented to run after the message is formed — "including the Authorization header, and just before the message is sent." #3902 moved it before authorization-header creation (to flow the finalized request for request-binding), which violated that contract and regressed callers that read the header in the callback — they saw anullAuthorizationheader.Fix
Move only the
CustomizeHttpRequestMessageinvocation back to after the header is set. The request-flow plumbing that #3902/request-binding relies on (options material applied before header creation +SetHttpRequestMessage) is left untouched, so this is a minimal, targeted regression fix.Test
Adds
UpdateRequestAsync_CustomizeHttpRequestMessage_SeesAuthorizationHeaderAsync, asserting the callback observes theAuthorizationheader. Also updated the existing flow test, which had asserted the callback flowed to the provider (no longer true now that it runs after).Notes
OnBeforeAuthHeaderCreation/OnAfterAuthHeaderCreationhooks (Abstractions Add OnBeforeAuthHeaderCreation / OnAfterAuthHeaderCreation hooks microsoft-identity-abstractions-for-dotnet#262) so request-binding callers can shape the signed request without overloadingCustomizeHttpRequestMessage.