Skip to content

feat(msal): read the B2C authority from configuration (backport #3189) - #3190

Merged
agneszitte merged 1 commit into
servicing/7.4from
mergify/bp/servicing/7.4/pr-3189
Oct 6, 2026
Merged

agneszitte merged 1 commit into
servicing/7.4from
mergify/bp/servicing/7.4/pr-3189

Conversation

@mergify

@mergify mergify Bot commented Sep 23, 2026

Copy link
Copy Markdown

What

MsalConfiguration gains B2CAuthority. When set, the provider calls WithB2CAuthority on the PublicClientApplicationBuilder right after CreateWithApplicationOptions, before the platform redirect URI and the app's Builder(...) callback (which still runs last and wins).

"MsalAuthentication": {
  "ClientId": "<client-id>",
  "B2CAuthority": "https://contoso.b2clogin.com/tfp/contoso.onmicrosoft.com/B2C_1_signupsignin",
  "Scopes": [ "https://contoso.onmicrosoft.com/api/tasks.read" ]
}

Why

MsalConfiguration derives from MSAL's PublicClientApplicationOptions, so ClientId, TenantId, Instance and RedirectUri already bind from configuration. The B2C authority did not: MSAL.NET's ResolveAuthority always types an Instance + TenantId pair as AuthorityType.Aad, so a /tfp/ user-flow path is only reachable through WithB2CAuthority. Apps ended up hard-coding it in a Builder(...) callback per head, which is what unoplatform/paragon-private#8 asks to avoid.

Also logs Using Authority '...' at Information next to the existing redirect URI line, so the effective authority is visible without Trace.

Verification

  • Given_MsalAuthentication.When_B2CAuthorityConfigured_Then_ClientUsesIt (UI.Tests): builds the provider from configuration with B2CAuthority and the usual TenantId, asserts the built client's authority via the new log line. MSAL keeps a B2C authority unchanged when TenantId is also set (B2CAuthority.GetTenantedAuthority), which is the real-app shape.
  • Desktop runtime tests, Given_MsalAuthentication filter: 20/20 pass locally (Windows, net9.0-desktop), including the 19 pre-existing cases.
  • Docs: B2C section of HowTo-MsalAuthentication.md updated; specs/012-msal-auth-fixes/progress.md addendum.

Backport to servicing/7.4 requested so it ships in the same 7.4.0-dev line as #3188.

🤖 Generated with Claude Code

https://claude.ai/code/session_015CwhNQC1BFcQiymU9GvsP1


This is an automatic backport of pull request #3189 done by [Mergify](https://mergify.com).

PublicClientApplicationOptions can only describe a Microsoft Entra
authority: MSAL's ResolveAuthority always types an Instance + TenantId
pair as AuthorityType.Aad, so an Azure AD B2C user flow was the one MSAL
setting an app could not keep in appsettings and had to hard-code in a
Builder(...) callback, per head.

- MsalConfiguration.B2CAuthority, applied through WithB2CAuthority right
  after CreateWithApplicationOptions; the app's Builder(...) still runs
  last and wins
- log the built client's authority at Information, next to the redirect
  URI, so the effective value is visible without Trace
- Given_MsalAuthentication.When_B2CAuthorityConfigured_Then_ClientUsesIt
- docs: the B2C section shows the JSON setting; RedirectUri noted as
  configurable in the WinAppSDK note

Motivated by unoplatform/paragon-private#8.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015CwhNQC1BFcQiymU9GvsP1
(cherry picked from commit 66e8399)
@agneszitte
agneszitte merged commit 94ea1bf into servicing/7.4 Oct 6, 2026
23 checks passed
@agneszitte
agneszitte deleted the mergify/bp/servicing/7.4/pr-3189 branch October 6, 2026 13:54
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