Validate scopes for importing collaborators
What does this MR do and why?
This change adds validation on the backend to check for correct scopes when a user wants to import collaborators during GitHub import.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- check out this branch and restart the gdk
- in a terminal window tail the importer log
tail -f log/importer.log
- log in to GitHub and ensure you have a project created there
- create a new token that only has a
user
scope. - in the gdk UI, visit New project > Import project > GitHub import
- enter the
user
scope token and wait for the page to load your GitHub repos - ensure the "Import collaborators" box is selected
- select a project to import
- observe the UI display an error: "Importing the project failed: Your GitHub access token does not have the correct scope to import collaborators." (see screenshot below)
- observe the Importer log display an error message:
{
"feature_category":"importers",
"import_type":"github",
"severity":"ERROR",
"time":"2024-01-10T15:51:21.764Z",
"correlation_id":"xxxxxxxxxxxxxxxx",
"meta.caller_id":"Import::GithubController#create",
"meta.remote_ip":"172.16.123.1",
"meta.feature_category":"importers",
"meta.user":"root","meta.user_id":1,
"meta.client_id":"user/1",
"message":"Error while attempting to import from GitHub",
"error":"Invalid scope"
}
Related to #434442 (closed)
Edited by Carla Drago