-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
GitHub Pagination #1804
GitHub Pagination #1804
Conversation
8a9a318
to
5265384
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.
have a couple of comments, otherwise lgtm
lib/auth/github.go
Outdated
@@ -274,6 +274,8 @@ func populateGithubClaims(client githubAPIClientI) (*services.GithubClaims, erro | |||
if err != nil { | |||
return nil, trace.Wrap(err, "failed to query Github user teams") | |||
} | |||
log.Debugf("Retrieved %v teams for GitHub user %v", len(teams), user.Login) |
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.
missing dot. Also you can use structured logging to list teams:
log.WithFields(log.Fields{"teams:" teams, "user": user.Login})
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.
The full list of teams is printed a few lines below. I added this line as a quick sanity check when we are debugging things for customers. For example maybe pagination breaks at some point in the future, this is a good diagnostic line to tell at a glance something is wrong.
lib/auth/github.go
Outdated
|
||
// If the response returned a next page link, continue following the next | ||
// page links until all teams have been retrieved. | ||
for nextPage != "" { |
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.
can you limit the number of pages to some reasonably high number? E.g. if github API goes crazy and will start returning circular link, this logic will hang forever.
5265384
to
1a62aca
Compare
1a62aca
to
e06521d
Compare
Purpose
Teleport was only returning the first page of results when querying the
GET /user/teams
endpoint. This results in aUnable to process callback from Github
error for users with more than 30 teams.Implementation
When processing the response to a GET request, extract any pagination links from the response header. Use the next link to paginate over all teams and return the full result set.
Related Issues
Fixes #1734