Skip to content

Validate scopes for importing collaborators

Carla Drago requested to merge 434442-validate-pat-scope into master

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

  1. check out this branch and restart the gdk
  2. in a terminal window tail the importer log tail -f log/importer.log
  3. log in to GitHub and ensure you have a project created there
  4. create a new token that only has a user scope.
  5. in the gdk UI, visit New project > Import project > GitHub import
  6. enter the user scope token and wait for the page to load your GitHub repos
  7. ensure the "Import collaborators" box is selected
  8. select a project to import
  9. 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)
  10. 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"
}

Screenshot_2024-01-10_at_16.51.36

Related to #434442 (closed)

Edited by Carla Drago

Merge request reports

Loading