Add -LoginHint parameter to Connect-MgGraph (closes #3605)#3662
Open
gavinbarron wants to merge 3 commits into
Open
Add -LoginHint parameter to Connect-MgGraph (closes #3605)#3662gavinbarron wants to merge 3 commits into
gavinbarron wants to merge 3 commits into
Conversation
Adds a new optional -LoginHint parameter to Connect-MgGraph (UserParameterSet) that pre-populates the account (login_hint) shown during interactive browser / WAM sign-in. This lets callers go straight to the preferred sign-in method for a known account instead of navigating the WAM account picker. - Flow the login hint through IAuthContext / AuthContext and onto InteractiveBrowserCredentialOptions.LoginHint. - Persist a per-account AuthenticationRecord (keyed by a hashed, normalized login hint) so repeat sign-ins for the same account are picker-free, while never silently reusing a different user's record. Existing shared records are migrated to per-account records only when the username matches the supplied hint. - Scope cache clearing and auth-record deletion on Disconnect-MgGraph to the correct per-account record. - Add unit tests and parameter-set tests, plus docs and an example. Closes #3605 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 04338979-a6b1-4abe-9ffe-42eb16b07442
Add the missing -LoginHint parameter block to the Connect-MgGraph markdown docs and generated MAML help (syntax + parameter list), which the earlier docs regeneration omitted because the module DLL predated the new parameter. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 04338979-a6b1-4abe-9ffe-42eb16b07442
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an optional -LoginHint parameter to Connect-MgGraph to pre-populate the account during interactive sign-in (browser/WAM) and introduces per-account persisted AuthenticationRecord handling so records aren’t silently reused across different users. The PR also includes regenerated help/docs artifacts and version metadata updates.
Changes:
- Add
-LoginHinttoConnect-MgGraph(UserParameterSet) and flow it throughIAuthContext/AuthContexttoInteractiveBrowserCredentialOptions.LoginHint. - Introduce per-account auth record persistence keyed by a normalized+hashed login hint, with legacy-record migration logic and scoped sign-out behavior.
- Add/extend tests and regenerate documentation/help metadata.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Authentication/examples/Connect-MgGraph.md | Adds a usage example for -LoginHint. |
| src/Authentication/docs/Connect-MgGraph.md | Documents -LoginHint and updates examples/syntax (plus regenerated content). |
| src/Authentication/Authentication/Cmdlets/ConnectMgGraph.cs | Adds -LoginHint parameter and maps it into the auth context. |
| src/Authentication/Authentication.Core/Interfaces/IAuthContext.cs | Extends auth context contract with LoginHint. |
| src/Authentication/Authentication/Models/AuthContext.cs | Implements LoginHint on the concrete auth context. |
| src/Authentication/Authentication.Core/Utilities/AuthenticationHelpers.cs | Applies LoginHint to interactive credential options and introduces per-account auth record resolution/scoped logout. |
| src/Authentication/Authentication.Test/Helpers/AuthenticationHelpersTests.cs | Adds unit tests for per-account auth record resolution and login-hint behavior. |
| src/Authentication/Authentication/test/Connect-MgGraph.Tests.ps1 | Adds parameter-set coverage for LoginHint. |
| src/Authentication/docs/Disconnect-MgGraph.md | Regenerated help content (e.g., parameter ordering/ProgressAction). |
| src/Authentication/docs/Get-MgContext.md | Regenerated help content (ProgressAction). |
| src/Authentication/docs/Get-MgEnvironment.md | Regenerated help content and updated environment table. |
| src/Authentication/docs/Get-MgGraphOption.md | Regenerated help content (ProgressAction and notes). |
| src/Authentication/docs/Get-MgRequestContext.md | Regenerated help content (ProgressAction). |
| src/Authentication/docs/Invoke-MgGraphRequest.md | Regenerated help content (ProgressAction). |
| src/Authentication/docs/Set-MgEnvironment.md | Regenerated help content (ProgressAction). |
| src/Authentication/docs/Remove-MgEnvironment.md | Regenerated help content (ProgressAction/formatting). |
| src/Authentication/docs/Add-MgEnvironment.md | Regenerated help content (ProgressAction/formatting). |
| src/Authentication/docs/Set-MgGraphOption.md | Regenerated help content and new sovereign-cloud example. |
| src/Authentication/docs/Set-MgRequestContext.md | Regenerated help content (ProgressAction/formatting). |
| src/Authentication/docs/Microsoft.Graph.Authentication.md | Regenerated module landing page metadata/content. |
| src/Authentication/Authentication/Constants.cs | Adds help message text for LoginHint. |
| src/Authentication/Authentication/Microsoft.Graph.Authentication-help.xml | Regenerated cmdlet help XML (formatting and content updates). |
| src/Authentication/Authentication/Microsoft.Graph.Authentication.dll-Help.xml | Regenerated external help XML (includes new params and examples). |
| src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 | Regenerated module manifest metadata/version. |
| src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec | Updates package version. |
| src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj | Updates assembly/package version. |
| src/Authentication/Authentication.Test/Microsoft.Graph.Authentication.Test.csproj | Updates test assembly version/metadata formatting. |
| src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj | Updates core library version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Summary
Adds a new optional
-LoginHintparameter toConnect-MgGraph(UserParameterSet) that pre-populates the account (login_hint) shown during interactive browser / WAM sign-in. This lets callers go straight to the preferred sign-in method for a known account instead of navigating the WAM account picker.Closes #3605
Changes
-LoginHintparameter onConnect-MgGraph, flowed throughIAuthContext/AuthContextontoInteractiveBrowserCredentialOptions.LoginHint.AuthenticationRecordis keyed by a hashed, normalized login hint so repeat sign-ins for the same account are picker-free, while a different user's record is never silently reused. An existing shared record is migrated to a per-account record only when its username matches the supplied hint.Disconnect-MgGraphare scoped to the correct per-account record.AuthenticationHelpersunit tests andConnect-MgGraphparameter-set tests.Connect-MgGraphdocs/help (plus regenerated help/docs metadata).Behavior notes
On Windows, WAM may still display the account picker on the first sign-in for an account; later sign-ins with the same
-LoginHintare silent.Validation
dotnet test(net8.0) onMicrosoft.Graph.Authentication.Test, filtered toAuthenticationHelpers: 26 passed, 0 failed.Notes for reviewers
.psd1date, unrelated cmdlet doc regeneration) that were produced by the local build tooling and are part of the current working tree.autorest.powershellsubmodule pointer change was intentionally excluded from this PR.