kabanero-io / kabanero-command-line-services

This repo will be archived soon.
Apache License 2.0
3 stars 7 forks source link

CLI call to GitHub not returning all teams which results in failed authentication #192

Closed alohr51 closed 4 years ago

alohr51 commented 4 years ago

Not all teams are returned from the call to GitHub. I was recently added to a GHE team and tried logging into the CLI via the /login endpoint and it was rejected even tho configured is set up properly.

I get back a 400 with

{ “message”: “An error occurred. An error occurred during authentication for user Error while building a JWT for user [ajlohr]. kabasec.KabaneroSecurityException: The user is not a member of any defined teams.” }

I made sure that team was configured correctly in the kabanero CR.

I believe the problem to be the fact that the GitHub API has a pagination feature that limits the returned teams to 30 by default. CLI is probably not doing pagination requests which results in a truncated team list.

From the CLI logs, I confirmed the above because the logs listed the teams its looking through and it only listed 30 of my teams when I am apart of more than 30. The team that would have authenticated me is on the 2nd or greater page of returned results from the GitHub API.

https://developer.github.com/enterprise/2.19/v3/#pagination

alohr51 commented 4 years ago

A quick bandaid fix may be to just add the query param?per_page=100 to the end of the GitHub team request API URL. It may be rare users are apart of more than 100 teams.

The true solution and fix is to properly implement pagination requests to the GitHub API.

davco01a commented 4 years ago

sure

davco01a commented 4 years ago

added pagination up to 100

alohr51 commented 4 years ago

To be extra clear- pagination wasn't added to the CLI yet, just a flag was added to show 100 results per page instead of the default 30. CLI is still only looking at the first page.

davco01a commented 4 years ago

since Java CLI Code is being frozen for the most part and we added pagination to 100, closing out this issue