-
Notifications
You must be signed in to change notification settings - Fork 264
feat(auth): GetUserByProviderID() #339
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
Conversation
And inline the implementation.
This reverts commit ae498f7.
* chore: Added Actions-based release workflow * Set GOPATH * Fixed working directory for tests * Decrypting credentials into the testdata directory * Added preflight and post check scripts
Note the diffbase. I'll merge+retarget to dev once the bulk_get stuff lands. |
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.
Looks good. Just a couple of suggestions on unit tests.
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.
LGTM with a suggestion.
auth/user_mgt_test.go
Outdated
defer s.Close() | ||
for _, tc := range cases { | ||
t.Run(tc.providerID+":"+tc.providerUID, func(t *testing.T) { | ||
// The resulting user isn't parsed, so it just needs to exist (even if it's empty). |
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.
Move server initialization and defer close out of the main loop.
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.
Done.
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.
Implementation and tests look pretty good. Lets remove the redundant CI config bits, and we should be good to go.
@@ -0,0 +1,105 @@ | |||
|
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.
This file no longer exists in source. Can be dropped from this PR.
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.
Ah, that's what caused this bad merge. (I mean, I should've caught it anyways, but this is making more sense now.)
@@ -92,6 +92,8 @@ fi | |||
echo_info "Tag v${RELEASE_VERSION} does not exist." | |||
|
|||
|
|||
<<<<<<< HEAD |
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.
Please revert.
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.
Done.
.github/workflows/publish.yml
Outdated
@@ -0,0 +1,64 @@ | |||
# Copyright 2020 Google Inc. |
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.
Not needed.
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.
Done.
.github/workflows/stage.yml
Outdated
@@ -0,0 +1,74 @@ | |||
# Copyright 2020 Google Inc. |
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.
Not needed.
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.
Done.
auth/user_mgt_test.go
Outdated
|
||
userRecord, err := s.Client.GetUserByProviderID(context.Background(), "google.com", "google_uid1") | ||
want := "cannot find user from providerID: { google.com, google_uid1 }" | ||
if userRecord != nil || err == nil || err.Error() != want { |
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.
Might want to also check for IsUserNotFoundError(err)
here
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.
Done.
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.
Thanks! LGTM 👍
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.
Just some minor nits. See what you think, and I'm happy to approve in any case. Thanks!
auth/user_mgt.go
Outdated
@@ -498,6 +499,47 @@ func (c *baseClient) GetUserByPhoneNumber(ctx context.Context, phone string) (*U | |||
}) | |||
} | |||
|
|||
// GetUserByProviderID gets the user data for the user corresponding to a given provider id. |
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.
Unless this is a literal, capped "ID" would probably be preferred.
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.
Done.
auth/user_mgt.go
Outdated
// [Retrieve user data](https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data) | ||
// for code samples and detailed documentation. | ||
// | ||
// `providerID` indicates the provider, e.g. 'google.com' for the Google provider. |
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.
Suggest "such as" instead of "e.g."
My sense is that if we want to say "For example," it should come after a hard stop like a period or semicolon after "provider." Internal style guide: https://developers.google.com/style/abbreviations#dont-use
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.
Done.
auth/user_mgt.go
Outdated
// `providerUID` is the user identifier for the given provider. | ||
func (c *baseClient) GetUserByProviderID(ctx context.Context, providerID string, providerUID string) (*UserRecord, error) { | ||
// Although we don't really advertise it, we want to also handle non-federated | ||
// idps with this call. So if we detect one of them, we'll reroute this |
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.
Should this be IDPs, with the acronym in caps?
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.
Actually, this may not be a public-facing comment I guess :)
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.
Not a public facing comment; but still a valid point, so done anyways.
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.
LG, thanks!
No description provided.