Skip to content

Add OnBeforeAuthHeaderCreation / OnAfterAuthHeaderCreation hooks#262

Merged
neha-bhargava merged 1 commit into
mainfrom
nebharg/onbefore-onafter-authheader-hooks
Jul 14, 2026
Merged

Add OnBeforeAuthHeaderCreation / OnAfterAuthHeaderCreation hooks#262
neha-bhargava merged 1 commit into
mainfrom
nebharg/onbefore-onafter-authheader-hooks

Conversation

@neha-bhargava

Copy link
Copy Markdown
Contributor

What

Adds two Action<HttpRequestMessage>? hooks to AuthorizationHeaderProviderOptions, giving callers explicit, self-documenting control over request customization relative to authorization-header creation:

  • OnBeforeAuthHeaderCreation — runs before the header is created. The Authorization header is not yet present. Use it to shape the request that a request-binding protocol signs — e.g. a SignedHttpRequest that binds the query, headers, or body (q/h/b claims) to the token — so the signature covers the finalized request.
  • OnAfterAuthHeaderCreation — runs after the header (including Authorization) is set, just before the message is sent. Use it to observe or adjust the finalized request. Same timing as the existing CustomizeHttpRequestMessage.

Why

CustomizeHttpRequestMessage is documented to run after the header, but the request-binding (SHR q/h/b) work needs a before hook. Rather than overload one callback with ambiguous timing, this adds an explicit before/after pair; the timing is encoded in the name.

Notes

  • Additive and non-breaking; existing CustomizeHttpRequestMessage behavior is unchanged.
  • PublicAPI.Unshipped.txt updated across all 6 TFMs; version bumped to 12.5.0.
  • Consumed by Microsoft.Identity.Web (DownstreamApi) in a companion PR.

Comment thread Directory.Build.props Outdated
Add two Action<HttpRequestMessage>? hooks to AuthorizationHeaderProviderOptions:

- OnBeforeAuthHeaderCreation runs before the authorization header is created, so
  callers can shape the request that a request-binding protocol signs (for
  example a SignedHttpRequest binding the query, headers, or body via the q/h/b
  claims), ensuring the signature covers the finalized request.
- OnAfterAuthHeaderCreation runs after the header (including Authorization) is
  set, just before the message is sent. Symmetric with the before hook; shares
  timing with the existing CustomizeHttpRequestMessage (backwards compatible).

Both are copied by the copy constructor. Additive and non-breaking. Version bump
and changelog are left for the post-release PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@neha-bhargava
neha-bhargava force-pushed the nebharg/onbefore-onafter-authheader-hooks branch from dc8b4ca to 9391631 Compare July 14, 2026 18:29
@neha-bhargava
neha-bhargava merged commit a77dbf2 into main Jul 14, 2026
4 checks passed
@neha-bhargava
neha-bhargava deleted the nebharg/onbefore-onafter-authheader-hooks branch July 14, 2026 18:51
neha-bhargava added a commit that referenced this pull request Jul 14, 2026
Document the 12.5.0 changelog section (OnBeforeAuthHeaderCreation /
OnAfterAuthHeaderCreation hooks, #262), move those unshipped public API entries
to shipped, and bump the dev version to 12.5.1.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

3 participants