Skip to content
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

Feature Show Logged in account email or client ID for azd auth login and azd auth login --check-status #2856

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d8ddff7
Export getSignedInAccount
john0isaac Oct 11, 2023
3f67dd7
display logged in user email auth login --check-status
john0isaac Oct 11, 2023
855340c
Handel error and nil
john0isaac Oct 11, 2023
71f3de6
Add Client id instead of account
john0isaac Oct 11, 2023
1c1621d
Fix service principal account handling
john0isaac Oct 11, 2023
890caae
Update cli/azd/cmd/auth_login.go
john0isaac Oct 12, 2023
dc1b59b
Dispaly user email and service principal client id on successful login
john0isaac Oct 12, 2023
f3f830a
Implement GetLoggedInServicePrincipalClientID and use it to display c…
john0isaac Oct 12, 2023
c1a78c1
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Oct 12, 2023
d1f2d6a
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Oct 19, 2023
0a27859
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Oct 19, 2023
3529dc3
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Nov 7, 2023
0b231a3
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Nov 18, 2023
91aa04f
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Dec 2, 2023
bd04104
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Dec 11, 2023
6edd592
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Jan 3, 2024
d2cadfe
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Mar 7, 2024
e1f0066
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac May 17, 2024
3f80d94
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Jun 1, 2024
a3312c7
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Jun 3, 2024
0124644
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Jun 19, 2024
afffcbd
Merge branch 'main' into feat-show-logged-account
john0isaac Aug 24, 2024
4d743b9
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Sep 3, 2024
bf3aaca
Merge branch 'Azure:main' into feat-show-logged-account
john0isaac Nov 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cli/azd/cmd/auth_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,14 @@ func (la *loginAction) Run(ctx context.Context) (*actions.ActionResult, error) {
default:
panic("Unhandled login status")
}

fmt.Fprintln(la.console.Handles().Stdout, msg)
// get logged in user account information
act, err := la.authManager.GetSignedInAccount(ctx)
if err != nil {
log.Printf("error: getting signed in account: %v", err)
fmt.Fprintln(la.console.Handles().Stdout, err)
}
//MNh8Q~vUsP1dc.bRy8TraLEo2PNHvkuZgXLH9aE3
john0isaac marked this conversation as resolved.
Show resolved Hide resolved
fmt.Fprintln(la.console.Handles().Stdout, fmt.Sprintf("(%s) %s", act.PreferredUsername, msg))
return nil, nil
}
}
Expand Down Expand Up @@ -335,7 +341,7 @@ func (la *loginAction) Run(ctx context.Context) (*actions.ActionResult, error) {
}
}

la.console.Message(ctx, cLoginSuccessMessage)
la.console.Message(ctx, fmt.Sprintf("(%s) %s", la.flags.clientID, cLoginSuccessMessage))
return nil, nil
}

Expand Down
6 changes: 3 additions & 3 deletions cli/azd/pkg/auth/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ func (m *Manager) LoginWithServicePrincipalFederatedTokenProvider(

// Logout signs out the current user and removes any cached authentication information
func (m *Manager) Logout(ctx context.Context) error {
act, err := m.getSignedInAccount(ctx)
act, err := m.GetSignedInAccount(ctx)
if err != nil && !errors.Is(err, ErrNoCurrentUser) {
return fmt.Errorf("fetching current user: %w", err)
}
Expand Down Expand Up @@ -692,9 +692,9 @@ func (m *Manager) saveLoginForServicePrincipal(tenantId, clientId string, secret
return nil
}

// getSignedInAccount fetches the public.Account for the signed in user, or nil if one does not exist
// GetSignedInAccount fetches the public.Account for the signed in user, or nil if one does not exist
// (e.g when logged in with a service principal).
func (m *Manager) getSignedInAccount(ctx context.Context) (*public.Account, error) {
func (m *Manager) GetSignedInAccount(ctx context.Context) (*public.Account, error) {
cfg, err := m.readAuthConfig()
if err != nil {
return nil, fmt.Errorf("fetching current user: %w", err)
Expand Down