-
Notifications
You must be signed in to change notification settings - Fork 268
Add azd auth status command
#6377
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: kristenwomack <5034778+kristenwomack@users.noreply.github.com>
Co-authored-by: kristenwomack <5034778+kristenwomack@users.noreply.github.com>
azd auth status command
wbreza
left a comment
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.
Love the idea - just have some open questions about the flags.
@copilot - Please review token caching and if we support multiple tokens with different tenants/scopes.
…text output Addresses review feedback: - Removed tenant-id and scope flags as they don't make sense for status checking - The command now checks the current user's credentials without allowing tenant/scope overrides - Added credential expiration time to text output (already present in JSON) - Simplified the implementation to always use default login scopes Co-authored-by: wbreza <6540159+wbreza@users.noreply.github.com>
Reviewed the auth system in commit bb9541f. The system stores a single "current user" credential (not multiple tokens). When Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
For consistency with azd auth status, the --check-status flag now also displays the credential expiration time in the text output format. Co-authored-by: JeffreyCA <9157833+JeffreyCA@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
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.
Pull request overview
This PR adds a new azd auth status command to provide a more intuitive way to check authentication status, replacing the previously required azd auth login --check-status flag. The implementation maintains backward compatibility while improving user experience by following CLI conventions used by tools like the GitHub CLI.
Key Changes
- New dedicated
azd auth statuscommand with support for both text and JSON output formats - Enhanced credential expiration display in both
azd auth statusandazd auth login --check-status - Updated command autocomplete and help documentation
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
cli/azd/cmd/auth_status.go |
New command implementation with authentication status checking, credential verification, and output formatting |
cli/azd/cmd/auth.go |
Registers the new status subcommand under the auth command group with JSON and text output format support |
cli/azd/cmd/auth_login.go |
Updates --check-status flag behavior to display credential expiration time for consistency |
cli/azd/cmd/testdata/TestUsage-azd-auth.snap |
Adds status subcommand to auth command help output |
cli/azd/cmd/testdata/TestUsage-azd-auth-status.snap |
New snapshot test for auth status command help text |
cli/azd/cmd/testdata/TestFigSpec.ts |
Updates Fig autocomplete specification to include the new status subcommand |
|
@copilot apply changes based on the comments in this thread |
- Extract common status display logic into displayAuthStatus helper function in util.go - Update both auth_status.go and auth_login.go to use the shared helper - Fix misleading comment in auth_status.go about "check status mode" - Add comprehensive unit tests for auth_status command covering: - Authenticated user scenario with expiration - Unauthenticated user scenario - Text output format validation - JSON output format validation - ReLoginRequired error scenario - Define authStatusAuthManager interface to make auth_status testable - Addresses DRY principle violation and test coverage concerns from PR review Co-authored-by: JeffreyCA <9157833+JeffreyCA@users.noreply.github.com>
JeffreyCA
left a comment
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.
/azp run azure-dev - cli
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
/azp run azure-dev - cli |
|
Azure Pipelines successfully started running 1 pipeline(s). |
weikanglim
left a comment
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.
Expiry time shows "access token" expiry time NOT ID token expiry token
@copilot check this comment and update if needed |
Reviewed @weikanglim's comment. The current implementation shows the access token expiry time (which is short-lived, typically ~15 minutes and auto-refreshed). As @weikanglim noted, this could be confusing since the user's auth session remains valid longer. However, showing the ID token expiry instead might also be misleading since it can be revoked independently. Options for addressing this:
Please clarify which approach is preferred and I'll implement it. |
|
Hi @@copilot. Thank you for your interest in helping to improve the Azure Developer CLI experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days. |
Users had to discover
azd auth login --check-statusto check authentication status, which is unintuitive compared to CLIs likeghthat useauth statussubcommands.Changes
azd auth statuschecks authentication status and displays user information--output jsonfor structured outputsuccessorunauthenticatedwith expiration timeazd auth login --check-statuscontinues to work unchangedazd auth statusdisplayAuthStatushelper function to eliminate code duplication (DRY principle)azd auth statuscommand covering authenticated/unauthenticated scenarios, output formats, and error casesUsage
Implementation
Created
auth_status.gowith dedicated command registration in the auth command group. The command checks the current user's authentication status using default login scopes, without allowing tenant or scope overrides (since azd stores only one current user credential at a time). Both text and JSON output formats now include credential expiration information.To ensure code maintainability, the status display logic was extracted into a shared
displayAuthStatushelper function inutil.go, which is used by bothazd auth statusandazd auth login --check-statuscommands. This eliminates code duplication and ensures consistency.Added comprehensive unit tests in
auth_status_test.gocovering authenticated/unauthenticated users, JSON/text output formats, and error scenarios likeReLoginRequiredErrorandErrNoCurrentUser.Original prompt
azd auth status#2898💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.