Skip to content

Conversation

rsgowman
Copy link
Member

@rsgowman rsgowman commented Jan 15, 2020

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() and DeleteUsers() APIs for retrieving and deleting user accounts in bulk.

@rsgowman rsgowman self-assigned this Jan 15, 2020
@rsgowman rsgowman requested a review from hiranya911 January 16, 2020 20:16
@rsgowman rsgowman assigned hiranya911 and unassigned rsgowman Jan 16, 2020
Copy link
Contributor

@hiranya911 hiranya911 left a 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.

@hiranya911 hiranya911 assigned rsgowman and unassigned hiranya911 Jan 18, 2020
@rsgowman rsgowman assigned hiranya911 and unassigned rsgowman Jan 22, 2020
Copy link
Contributor

@hiranya911 hiranya911 left a 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.

Copy link
Contributor

@hiranya911 hiranya911 left a 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.

@hiranya911 hiranya911 assigned rsgowman and unassigned hiranya911 Jan 27, 2020
@rsgowman rsgowman assigned hiranya911 and unassigned rsgowman Jan 28, 2020
Copy link
Contributor

@hiranya911 hiranya911 left a 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.

@hiranya911 hiranya911 removed their assignment Jan 28, 2020
Copy link
Contributor

@hiranya911 hiranya911 left a 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.

Copy link

@egilmorez egilmorez left a 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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest omitting this comma.

Copy link
Member Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest "A maximum..."

Copy link
Member Author

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.

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."

Copy link
Member Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest "are considered"

Copy link
Member Author

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

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 :)

Copy link
Member Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest "are considered"

Copy link
Member Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest "are counted"

Copy link
Member Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest "A maximum..."

Copy link
Member Author

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.

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"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

hiranya911 and others added 4 commits February 19, 2020 13:10
* 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
Copy link
Collaborator

@cbonnie cbonnie left a 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.
Copy link
Collaborator

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"

Copy link
Member Author

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.
Copy link
Collaborator

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."

Copy link
Member Author

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.
Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link

@egilmorez egilmorez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor

@hiranya911 hiranya911 left a 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 @@

Copy link
Contributor

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.

Copy link
Member Author

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"
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@rsgowman rsgowman assigned hiranya911 and unassigned egilmorez and rsgowman May 20, 2020
Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. LGTM 👍

@hiranya911 hiranya911 assigned rsgowman and unassigned hiranya911 May 20, 2020
@rsgowman rsgowman merged commit 96a7111 into dev May 20, 2020
@rsgowman rsgowman deleted the rsgowman/bulk_get branch May 20, 2020 20:48
@hiranya911 hiranya911 changed the title Add bulk get/delete methods feat(auth): Add bulk get/delete methods May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants