-
Notifications
You must be signed in to change notification settings - Fork 268
feat(auth): Add bulk get/delete methods #325
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
1a9b43f
to
2c9da85
Compare
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.
I've provided some high-level feedback on the implementation and unit tests. The implementation looks correct, just needs a bit polishing to fit Go conventions. Will look at the integration tests in the next round.
And inline the implementation.
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 pretty good. I added some comments on how we can improve the implementation and reduce some of the repetition. Also added comments on integration tests.
This reverts commit ae498f7.
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 for making the changes. Implementation looks pretty solid. Just a few comments on error reporting in the test cases.
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 great. Just a comment on godoc convention.
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 👍
If the API proposal is in an approved state, feel free to merge.
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.
Some style things to look at. Thanks!
auth/user_mgt.go
Outdated
|
||
// A GetUsersResult represents the result of the GetUsers() API. | ||
type GetUsersResult struct { | ||
// Set of UserRecords, corresponding to the set of users that were requested. |
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 omitting this comma.
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
// result list is not guaranteed to correspond to the nth entry in the input | ||
// parameters list. | ||
// | ||
// Only a maximum of 100 identifiers may be supplied. If more than 100 |
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 "A maximum..."
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
// parameters list. | ||
// | ||
// Only a maximum of 100 identifiers may be supplied. If more than 100 | ||
// identifiers are supplied, this method will immediately return an error. |
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 "method returns an error."
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
// A DeleteUsersResult represents the result of the DeleteUsers() call. | ||
type DeleteUsersResult struct { | ||
// The number of users that were deleted successfully (possibly zero). Users | ||
// that did not exist prior to calling DeleteUsers() will be considered to be |
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 "are considered"
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
// The number of users that failed to be deleted (possibly zero). | ||
FailureCount int | ||
|
||
// A list of describing the errors that were encountered |
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.
Delete "of" if this list actually describes the errors. Otherwise, just "A list of errors encountered..."
Suggest checking whether this was copied into similar comment in other SDKs, and we just missed it :)
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.
Oh; the type somehow got dropped. (Which is mildly redundant info in most ports since you can get it from the type signature; python being the obvious exception.) The other ports seem ok.
I've added the type to match the other ports. Alternatively, we could just remove the type everywhere (except python).
auth/user_mgt.go
Outdated
// DeleteUsers deletes the users specified by the given identifiers. | ||
// | ||
// Deleting a non-existing user won't generate an error. (i.e. this method is | ||
// idempotent.) Non-existing users will be considered to be successfully |
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 "are considered"
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
// | ||
// Deleting a non-existing user won't generate an error. (i.e. this method is | ||
// idempotent.) Non-existing users will be considered to be successfully | ||
// deleted, and will therefore be counted in the DeleteUsersResult.SuccessCount |
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 "are counted"
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
// deleted, and will therefore be counted in the DeleteUsersResult.SuccessCount | ||
// value. | ||
// | ||
// Only a maximum of 1000 identifiers may be supplied. If more than 1000 |
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 "A maximum..."
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
// value. | ||
// | ||
// Only a maximum of 1000 identifiers may be supplied. If more than 1000 | ||
// identifiers are supplied, this method will immediately return an error. |
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 "method returns an error"
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.
* 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
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.
Left minor comments, otherwise LGTM (reviewing on behalf of egilmore@).
auth/user_mgt.go
Outdated
// Maximum allowed number of users to batch get at one time. | ||
maxGetAccountsBatchSize = 100 | ||
|
||
// Maximum allowed numberof users to batch delete at one time. |
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.
Add space between "number" and "of"
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
@@ -34,6 +34,12 @@ const ( | |||
maxLenPayloadCC = 1000 | |||
defaultProviderID = "firebase" | |||
idToolkitV1Endpoint = "https://identitytoolkit.googleapis.com/v1" | |||
|
|||
// Maximum allowed number of users to batch get at one time. |
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: "Maximum number of users allowed to batch get at a time."
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. I've also applied this to the maxDeleteAccountsBatchSize comment immediately below.
@@ -57,6 +63,9 @@ type UserInfo struct { | |||
type UserMetadata struct { | |||
CreationTimestamp int64 | |||
LastLogInTimestamp int64 | |||
// The time at which the user was last active (ID token refreshed), or 0 if | |||
// the user was never active. | |||
LastRefreshTimestamp int64 | |||
} | |||
|
|||
// UserRecord contains metadata associated with a Firebase user account. |
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.
UserRecord
? Not familiar with the style guide for GO, please add back ticks if necessary.
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.
It doesn't seem to be a thing; or at least, they don't do it here: https://blog.golang.org/godoc-documenting-go-code or here: https://golang.org/doc/effective_go.html#commentary
Nonetheless, we do seem to use backticks occasionally... though seemingly only when referring to some other function (and I suspect inconsistently at that.)
I've left this alone.
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!
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 clean ups needed.
@@ -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.
Let's remove this along with stage.yml
and publish.yml
from the PR. They are no longer in the dev branch.
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
@@ -331,6 +340,7 @@ const ( | |||
unauthorizedContinueURI = "unauthorized-continue-uri" | |||
unknown = "unknown-error" | |||
userNotFound = "user-not-found" | |||
maximumUserCountExceeded = "maximum-user-count-exceeded" |
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 shouldn't be needed. We don't use error codes for developer errors.
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 👍
This PR allows callers to retrieve a list of users by unique identifier (uid, email, phone, federated provider uid) as well as to delete a list of users.
Resolves #138
RELEASE NOTE: Added
GetUsers()
andDeleteUsers()
APIs for retrieving and deleting user accounts in bulk.