-
Notifications
You must be signed in to change notification settings - Fork 253
Add comprehensive authority configuration and precedence documentation #3617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
6
commits into
master
Choose a base branch
from
copilot/update-docs-for-authority-precedence
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+35,285
−1,627
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d4c1360
Fix Authority-only configuration: Parse to Instance/TenantId for AAD,…
Copilot 64139f1
Add high-performance warning logging for Authority + Instance/TenantI…
Copilot bab62bd
Initial plan
Copilot 28e7e5b
Add comprehensive authority configuration documentation
Copilot 4491701
Remove PreserveAuthority from documentation and add sovereign cloud link
Copilot 0927e20
Sync branch with master to resolve conflicts
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,239 @@ | ||||||
| # Authority Configuration & Precedence in Microsoft.Identity.Web | ||||||
|
|
||||||
| ## Overview | ||||||
|
|
||||||
| Microsoft.Identity.Web provides flexible options for configuring authentication authority URLs. Understanding how these configuration options interact is crucial for proper application setup, especially when working with Azure Active Directory (AAD), Azure AD B2C, and Customer Identity and Access Management (CIAM). | ||||||
|
|
||||||
| This guide explains: | ||||||
| - How authority-related configuration properties work together | ||||||
| - The precedence rules when multiple properties are set | ||||||
| - Best practices for different authentication scenarios | ||||||
| - How to interpret and resolve configuration warnings | ||||||
|
|
||||||
| ## Terminology | ||||||
|
|
||||||
| ### Core Configuration Properties | ||||||
|
|
||||||
| - **Authority**: A complete URL to the authentication endpoint, including the instance and tenant identifier. Examples: | ||||||
| - `https://login.microsoftonline.com/common` | ||||||
| - `https://login.microsoftonline.com/contoso.onmicrosoft.com` | ||||||
| - `https://contoso.b2clogin.com/contoso.onmicrosoft.com/B2C_1_susi` | ||||||
|
|
||||||
| - **Instance**: The base URL of the authentication service without tenant information. Examples: | ||||||
| - `https://login.microsoftonline.com/` | ||||||
| - `https://login.microsoftonline.us/` (Azure Government) | ||||||
| - `https://contoso.b2clogin.com/` | ||||||
|
|
||||||
jmprieur marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| - **TenantId**: The tenant identifier, which can be: | ||||||
| - A GUID (e.g., `12345678-1234-1234-1234-123456789012`) | ||||||
| - A tenant domain (e.g., `contoso.onmicrosoft.com`) | ||||||
| - Special values (`common`, `organizations`, `consumers`) | ||||||
|
|
||||||
| - **Domain**: The primary domain of your tenant (e.g., `contoso.onmicrosoft.com`). Used primarily with B2C configurations. | ||||||
|
|
||||||
| - **PreserveAuthority**: A boolean flag (default: `false`) that prevents parsing of the Authority URL into Instance and TenantId components. This is particularly important for CIAM scenarios with custom domains. | ||||||
|
|
||||||
| - **Policy IDs**: B2C-specific identifiers for user flows: | ||||||
| - `SignUpSignInPolicyId` (e.g., `B2C_1_susi`) | ||||||
| - `ResetPasswordPolicyId` (e.g., `B2C_1_reset`) | ||||||
| - `EditProfilePolicyId` (e.g., `B2C_1_edit_profile`) | ||||||
|
|
||||||
| ## Authority Resolution Decision Tree | ||||||
|
|
||||||
| The following flowchart illustrates how Microsoft.Identity.Web resolves the authority configuration: | ||||||
|
|
||||||
| ```mermaid | ||||||
| flowchart TD | ||||||
| A[Configuration Provided] --> B{Instance & TenantId set?} | ||||||
| B -- Yes --> C[Use Instance & TenantId<br/>Ignore Authority if present] | ||||||
| B -- No --> D{Authority Provided?} | ||||||
| D -- No --> E[Configuration Invalid<br/>Requires Instance+TenantId] | ||||||
| D -- Yes --> F{PreserveAuthority True?} | ||||||
| F -- Yes --> G[Use full Authority as Instance<br/>TenantId = null] | ||||||
| F -- No --> H[Parse Authority<br/>Extract Instance + TenantId] | ||||||
| H --> I{Is B2C?} | ||||||
| I -- Yes --> J[Normalize /tfp/ if present<br/>Derive PreparedInstance] | ||||||
| I -- No --> K[Derive PreparedInstance] | ||||||
| C --> K | ||||||
| G --> K | ||||||
| K --> L[Pass PreparedInstance to MSAL] | ||||||
| ``` | ||||||
|
|
||||||
| ## Precedence Rules | ||||||
|
|
||||||
| The following table summarizes how different configuration combinations are resolved: | ||||||
|
|
||||||
| | Authority Set | Instance Set | TenantId Set | PreserveAuthority | Result | Warning | | ||||||
| |---------------|--------------|--------------|-------------------|--------|---------| | ||||||
| | ✅ | ❌ | ❌ | `false` | Authority is parsed → Instance + TenantId | No | | ||||||
| | ✅ | ❌ | ❌ | `true` | Full Authority used as Instance, TenantId = null | No | | ||||||
| | ✅ | ✅ | ❌ | any | Instance used, Authority **ignored** | ⚠️ Yes (EventId 408) | | ||||||
| | ✅ | ❌ | ✅ | any | TenantId used, Authority **ignored** | ⚠️ Yes (EventId 408) | | ||||||
| | ✅ | ✅ | ✅ | any | Instance + TenantId used, Authority **ignored** | ⚠️ Yes (EventId 408) | | ||||||
| | ❌ | ✅ | ✅ | any | Instance + TenantId used | No | | ||||||
| | ❌ | ✅ | ❌ | any | Instance used, tenant resolved at runtime | No* | | ||||||
| | ❌ | ❌ | ✅ | any | Invalid configuration | Error | | ||||||
|
|
||||||
| \* For single-tenant apps, this may cause issues. Always specify TenantId when using Instance. | ||||||
|
||||||
| \* For single-tenant apps, this may cause issues. Always specify TenantId when using Instance. | |
| For single-tenant apps, this may cause issues. Always specify TenantId when using Instance. |
Contributor
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the footnote text as suggested in commit 4491701.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.