-
Notifications
You must be signed in to change notification settings - Fork 210
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
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
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.
Still a little confused on how this ends up working. From your screenshot, it looks like you did the right thing, but I'm confused on how it works with the current diff.
My belief is that when you are logged in with a service principal, the call to readUserProperties in auth/manager is going to return a user properties struct that has a nil HomeAccountID and so GetSignedInAccount will return (nil, nil). I think that will cause a panic when we try to dereference the PerferredUsername.
Were there additional commits that fixed this up that you just missed pushing? Or is my mental model on how this code works incorrect?
This comment was marked as outdated.
This comment was marked as outdated.
azd auth login --check-status
azd auth login
and azd auth login --check-status
azd auth login
and azd auth login --check-status
azd auth login
and azd auth login --check-status
@ellismg @vhvb1989 are we still looking into this enhancement and is the PR still valid? @john0isaac can we close this and open a new one incorporating feedback? |
@john0isaac Thanks for keeping this PR alive, our maintainers will push on this to get this merged. @SophCarp Thoughts on this from a UX perspective? I have some suggestions below:
For service principals, I feel like we should display name and the ID:
^ For the App ID, we might benefit from grey / less emphasized text -- the italics is meant to demonstrate this. |
@weikanglim can you help me with the service principle display name? as i'm not sure where to obtain it from. And I changed it for the email to make it bold and use the same wording you suggested. @vhvb1989 I applied your suggestion as it's way much better that what i did i think i was being lazy when i said to wait for Matt 😆 but internally I just wanted to avoid rework as he may have wanted something different. |
0020bd3
to
5ccd731
Compare
1282f52
to
a9b3ae3
Compare
a9b3ae3
to
1507cc2
Compare
Can you try using the claims from the access token returned by I'd recommend not making any changes to I was able to print out what's available from the claims using the code below: claims, err := auth.GetClaimsFromAccessToken(token.Token)
log.Printf("claims: %+v", claims) I think |
cli/azd/cmd/auth_login.go
Outdated
details, err := la.authManager.LogInDetails(ctx) | ||
|
||
// error getting user account, successful log in | ||
if err != nil { | ||
log.Printf("error: getting signed in account: %v", err) | ||
la.console.Message(ctx, cLoginSuccessMessage+".") | ||
return nil, nil | ||
} | ||
|
||
switch details.LoginType { | ||
case auth.EmailLoginType: | ||
fmt.Fprintf(la.console.Handles().Stdout, "%s as %s.", cLoginSuccessMessage, output.WithBold("%s", details.Account)) | ||
return nil, nil | ||
case auth.ClientIdLoginType: | ||
fmt.Fprintf( | ||
la.console.Handles().Stdout, | ||
"%s as (%s).", | ||
cLoginSuccessMessage, | ||
output.WithGrayFormat("%s", details.Account)) | ||
return nil, nil | ||
default: | ||
la.console.Message(ctx, cLoginSuccessMessage+".") | ||
return nil, nil | ||
} |
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.
Is this code the same as the one above?
Here's a PR with how you can use UX items to describe and re-use output in azd: john0isaac#2
Ux items let us keep track of indentation and have some single source to define the output elements that can be used from different packages.
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.
kinda the difference is that this only triggers on successful login from auth login
while the above added lines are for auth login --check-status
which have to outputs either logged in or not logged in.
Thanks for the PR i will work on it.
use ux struct item
For my personal account these are the claims: {PreferredUsername: UniqueName:live.com#[email protected] GivenName:John FamilyName:Aziz MiddleName: Name: Oid: TenantId:f8cdef31-a31e-****-****-**** Subject:************ Upn: Email:[email protected] AlternativeId: Issuer:https://sts.windows.net/f8cdef31-****-****-****/ Audience:https://management.azure.com/ ExpirationTime:1737228383 IssuedAt:1737223568 NotBefore:1737223568} For my Ambassadors (Consider it a work account.. kinda) these are the claims: {PreferredUsername: UniqueName:[email protected] GivenName:John FamilyName:Aziz MiddleName: Name:John Aziz Oid:d27c9994-*****-*****-***** TenantId:84c31ca0-*****-*****-***** Subject:************* Upn:[email protected] Email: AlternativeId: Issuer:https://sts.windows.net/84c31ca0-************/ Audience:https://management.azure.com/ ExpirationTime:1737229048 IssuedAt:1737223774 NotBefore:1737223774} For service principal login these are the claims: {PreferredUsername: UniqueName: GivenName: FamilyName: MiddleName: Name: Oid:81b42351-f2f7-******-****-***** TenantId:80c273e6-*****-*****-**** Subject:******-******-*****-***** Upn: Email: AlternativeId: Issuer:https://sts.windows.net/80c273e6-*****-*****-******/ Audience:https://management.azure.com/ ExpirationTime:1737227895 IssuedAt:1737223995 NotBefore:1737223995} There isn't a single property for the claims we can use as for the personal account it's |
This pull request updates to the login functionality in the Azure CLI. The main changes involve improving the login status messaging and adding detailed account information after a successful login.
closes #1745
azd auth login
andazd auth login --check-status
with normal accountazd auth login --check-status
with service principal