Skip to content

Update OnBeforeTokenAcquisitionForOnBehalfOf event to construct ClaimsPricipal from token#3714

Merged
trwalke merged 7 commits intomasterfrom
rayluo/UpdateOboEvent
Feb 11, 2026
Merged

Update OnBeforeTokenAcquisitionForOnBehalfOf event to construct ClaimsPricipal from token#3714
trwalke merged 7 commits intomasterfrom
rayluo/UpdateOboEvent

Conversation

@rayluo
Copy link
Contributor

@rayluo rayluo commented Feb 9, 2026

This pull request introduces a new OnBehalfOfEventArgs class to provide richer context for on-behalf-of token acquisition events and updates the related public API signatures to use this new class instead of passing a ClaimsPrincipal directly. This change improves extensibility and clarity for event handlers involved in token acquisition flows.

Key changes:

API Enhancements:

  • Introduced new OnBehalfOfEventArgs class, which encapsulates the user (ClaimsPrincipal) and the user assertion token, providing additional context for on-behalf-of token acquisition operations. (src/Microsoft.Identity.Web.TokenAcquisition/OnBehalfOfEventArgs.cs, src/Microsoft.Identity.Web.TokenAcquisition/OnBehalfOfEventArgs.csR1-R27)
  • Updated the public API surface for all supported frameworks to include the new OnBehalfOfEventArgs class and its properties. (src/Microsoft.Identity.Web.TokenAcquisition/PublicAPI/net8.0/PublicAPI.Unshipped.txt, src/Microsoft.Identity.Web.TokenAcquisition/PublicAPI/net9.0/PublicAPI.Unshipped.txt, src/Microsoft.Identity.Web.TokenAcquisition/PublicAPI/net10.0/PublicAPI.Unshipped.txt, src/Microsoft.Identity.Web.TokenAcquisition/PublicAPI/net462/PublicAPI.Unshipped.txt, src/Microsoft.Identity.Web.TokenAcquisition/PublicAPI/net472/PublicAPI.Unshipped.txt, src/Microsoft.Identity.Web.TokenAcquisition/PublicAPI/net10.0/PublicAPI.Unshipped.txtR4-R13)

Breaking Changes to Event Handler Signatures:

  • Changed the signatures of BeforeTokenAcquisitionForOnBehalfOf.Invoke and its async counterpart to accept an OnBehalfOfEventArgs instance instead of a ClaimsPrincipal, across all relevant API files. This affects both synchronous and asynchronous event hooks.
  • Updated internal API declarations for TokenAcquisitionExtensionOptions.InvokeOnBeforeTokenAcquisitionForOnBehalfOf and its async version to use OnBehalfOfEventArgs instead of ClaimsPrincipal.

These changes collectively make the token acquisition event handling more robust and future-proof by encapsulating relevant data in a dedicated event args class.PR #3712 changed the usage of user to userHint, but based on the logic at the beginning of the affected method, the single source of truth in terms of OBO shall be derived from tokenUsedToCallTheWebApi. This change constructs a ClaimsPrincipal from the token string.

…ipal from token

In PR #3712 changed the usage of user to userHint, but based on the logic at the beginning of the changed method, the single source of truth in terms of OBO shall be derived from tokenUsedToCallTheWebApi. This change constructs a ClaimsPrincipal from the token string and preserves the BootstrapContext for use in event handlers.
@rayluo rayluo requested a review from a team as a code owner February 9, 2026 07:33
@trwalke trwalke closed this Feb 10, 2026
@trwalke trwalke reopened this Feb 10, 2026
@trwalke trwalke closed this Feb 10, 2026
@trwalke trwalke reopened this Feb 10, 2026
github-actions bot pushed a commit to EelcoLos/nx-tinkering that referenced this pull request Mar 3, 2026
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

Rebasing might not happen immediately, so don't worry if this takes some
time.

Note: if you make any changes to this PR yourself, they will take
precedence over the rebase.

---

[//]: # (dependabot-end)

Updated
[Microsoft.Identity.Web](https://github.com/AzureAD/microsoft-identity-web)
from 4.3.0 to 4.4.0.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.Identity.Web's
releases](https://github.com/AzureAD/microsoft-identity-web/releases)._

## 4.4.0

### New features
- Add AOT-compatible web API authentication for .NET 10+. See
[#​3705](AzureAD/microsoft-identity-web#3705)
and
[#​3664](AzureAD/microsoft-identity-web#3664).
- Propagate long-running web API session key back to callers in user
token acquisition. See
[#​3728](AzureAD/microsoft-identity-web#3728).
- Add OBO event initialization for OBO APIs. See
[#​3724](AzureAD/microsoft-identity-web#3724).
- Add support for calling `WithClientClaims` flow for token acquisition.
See
[#​3623](AzureAD/microsoft-identity-web#3623).
- Add `OnBeforeTokenAcquisitionForOnBehalfOf` event. See
[#​3680](AzureAD/microsoft-identity-web#3680).

### Bug fixes
- Throw `InvalidOperationException` with actionable message when a
custom credential is not registered. See
[#​3626](AzureAD/microsoft-identity-web#3626).
- Fix event firing for
`InvokeOnBeforeTokenAcquisitionForOnBehalfOfAsync`. See
[#​3717](AzureAD/microsoft-identity-web#3717).
- Update `OnBeforeTokenAcquisitionForOnBehalfOf` to construct
`ClaimsPrincipal` from token. See
[#​3714](AzureAD/microsoft-identity-web#3714).
- Add a retry counter for acquire token and updated tests with a fake
secret. See
[#​3682](AzureAD/microsoft-identity-web#3682).
- Fix OBO user error handling. See
[#​3712](AzureAD/microsoft-identity-web#3712).
- Fix override merging for app token (and others). See
[#​3644](AzureAD/microsoft-identity-web#3644).
- Fix certificate reload logic to only trigger on certificate-specific
errors. See
[#​3653](AzureAD/microsoft-identity-web#3653).
- Update ROPC flow CCA to pass `SendX5C` to MSAL. See
[#​3671](AzureAD/microsoft-identity-web#3671).

### Dependencies updates
- Bump `qs` in `/tests/DevApps/SidecarAdapter/typescript`. See
[#​3725](AzureAD/microsoft-identity-web#3725).
- Downgrade Microsoft.Extensions.Configuration.Binder to 2.1.0 on .NET
Framework. See
[#​3730](AzureAD/microsoft-identity-web#3730).
- Update .NET SDK to 10.0.103 to address DOTNET-Security-10.0
vulnerability. See
[#​3726](AzureAD/microsoft-identity-web#3726).
- Upgrade to Microsoft.Identity.Abstractions 11 for AoT compatibility.
See
[#​3699](AzureAD/microsoft-identity-web#3699).
- Update to MSAL 4.81.0. See
[#​3665](AzureAD/microsoft-identity-web#3665).

### Documentation
- Add documentation for auto-generated session key for long-running OBO
session. See
[#​3729](AzureAD/microsoft-identity-web#3729).
- Improve the Aspire doc article and skills. See
[#​3695](AzureAD/microsoft-identity-web#3695).
- Add an article and agent skill to add Entra ID to an Aspire app. See
[#​3689](AzureAD/microsoft-identity-web#3689).
- Fix misleading comment in
`CertificatelessOptions.ManagedIdentityClientId`. See
[#​3667](AzureAD/microsoft-identity-web#3667).
- Add Copilot explore tool functionality. See
[#​3694](AzureAD/microsoft-identity-web#3694).

### Fundamentals
- Remove unnecessary warning suppression. See
[#​3715](AzureAD/microsoft-identity-web#3715).
- Migrate labs to Lab.API 2.x (first pass). See
[#​3710](AzureAD/microsoft-identity-web#3710).
- Update Sidecar E2E test constants. See
[#​3693](AzureAD/microsoft-identity-web#3693).
- Fix intermittent failures in `CertificatesObserverTests`. See
[#​3687](AzureAD/microsoft-identity-web#3687).
- Add validation baseline exclusions. See
[#​3684](AzureAD/microsoft-identity-web#3684).
- Add dSTS integration tests. See
[#​3677](AzureAD/microsoft-identity-web#3677).
- Fix FIC test. See
[#​3663](AzureAD/microsoft-identity-web#3663).
- Update IdentityWeb version, build logic, and validation. See
[#​3659](AzureAD/microsoft-identity-web#3659).

### New Contributors
* @​XiaoxinMS2 made their first contribution in
AzureAD/microsoft-identity-web#3677
* @​RyAuld made their first contribution in
AzureAD/microsoft-identity-web#3687
* @​agocke made their first contribution in
AzureAD/microsoft-identity-web#3664
* @​MZOLN made their first contribution in
AzureAD/microsoft-identity-web#3700
* @​christian-posta made their first contribution in
AzureAD/microsoft-identity-web#3644
* @​4gust made their first contribution in
AzureAD/microsoft-identity-web#3682
* @​rayluo made their first contribution in
AzureAD/microsoft-identity-web#3714

Commits viewable in [compare
view](AzureAD/microsoft-identity-web@4.3.0...4.4.0).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Microsoft.Identity.Web&package-manager=nuget&previous-version=4.3.0&new-version=4.4.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Mar 3, 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.

4 participants