[Profile] az login: Add --redirect-port for browser authentication - #34061
Open
rta-kklints wants to merge 2 commits into
Open
rta-kklints wants to merge 2 commits into
rta-kklints wants to merge 2 commits into
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-01a08e60-b4ab-720c-8d72-21533bf0a4d2 Co-authored-by: Amp <amp@ampcode.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
microsoft-github-policy-service
Bot
requested a review
from Yong Zhang (yonzhan)
September 11, 2026 04:43
Contributor
|
Thank you for your contribution rta-kklints! We will review the pull request and get back to you soon. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
One or more issues must be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds az login --redirect-port for fixed-port browser authentication, including validation, WAM/fallback control, bind-error handling, documentation, and tests.
Changes:
- Adds the CLI argument and authentication-mode validation.
- Propagates the port through Profile, Identity, and MSAL.
- Adds documentation and unit tests.
File summaries
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/profile/tests/latest/test_profile_custom.py | Updated as part of this pull request. |
| src/azure-cli/azure/cli/command_modules/profile/custom.py | Updated as part of this pull request. |
| src/azure-cli/azure/cli/command_modules/profile/_help.py | Updated as part of this pull request. |
| src/azure-cli/azure/cli/command_modules/profile/init.py | Updated as part of this pull request. |
| src/azure-cli-core/azure/cli/core/tests/test_profile.py | Updated as part of this pull request. |
| src/azure-cli-core/azure/cli/core/auth/tests/test_identity.py | Updated as part of this pull request. |
| src/azure-cli-core/azure/cli/core/auth/identity.py | Updated as part of this pull request. |
| src/azure-cli-core/azure/cli/core/_profile.py | Updated as part of this pull request. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Author
|
@microsoft-github-policy-service agree |
Amp-Thread-ID: https://ampcode.com/threads/T-01a08e60-b4ab-720c-8d72-21533bf0a4d2 Co-authored-by: Amp <amp@ampcode.com>
Collaborator
|
az login |
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.
Related command
az loginFixes #21934
Fixes #26556
Description
Add
az login --redirect-port PORTto select the local callback port used by interactive browser authentication. This lets users configure SSH port forwarding before starting a browser login on a remote machine.When
--redirect-portis specified,az login:Default login behavior is unchanged when the option is omitted. Because browser launch failure is not reliably reported by all Python
webbrowserbackends, remote users can setBROWSER=echoto print the authorization URL.Testing Guide
From the machine running the browser, preconfigure forwarding to the remote machine:
On the remote machine, print the authorization URL and start login on that fixed callback port:
Open the printed URL in the local browser. After authentication, the callback is forwarded to Azure CLI on the remote machine and login completes.
To verify unavailable-port handling, occupy the port before login. The command exits with
Redirect port 40080 is unavailableand recommends freeing it or selecting another port.Automated validation:
azdev style profile azure-cli-coreazdev test profile core(400 passed, 23 skipped, 4 subtests passed)azdev linter --ci-exclusions --min-severity mediumazdev latest-index verifyazdev scanHistory Notes
Generated from the PR title.