-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
GitLab OAuth not setting the right permissions on RemoteRepository #7743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We can filter This should only return projects where the user has at least maintainer level permission. Ref: https://docs.gitlab.com/ee/api/groups.html#list-a-groups-projects I think by doing this here the issue should be solved as we will import only those projects that the user has permission to. readthedocs.org/readthedocs/oauth/services/gitlab.py Lines 111 to 120 in 2d64328
@humitos What do you think? |
If we filter that response, will we still be importing projects where the user has We need to keep importing them, since they are shown in the list of "importable repositories" in the "Import Project" page with a message saying that you may need to ask for permissions to be able to import it. |
I don't think so, according to their documentation, I am not able to test it as I am not in any organization on GitLab :( |
#7753 was merged |
If a user belongs to a group on GitLab and have admin access to a particular repository via that group, the
RemoteRepository.admin
is not properly set toTrue
. This makes that repository to not being able to import by that user.We are using 3 different API endpoints to sync
RemoteRepository
on GitLab:In
GitLabService.sync_repositories
:{url}/api/v4/projects
: to get all the projects the user has access to (docs)In
GitLabService.sync_organizations
:{url}/api/v4/groups
: to get all the groups the user belongs to (docs){url}/api/v4/groups/{id}/projects
: to get all the projects for a particular group the user belongs to (docsThe main problem here is that the API response from
/groups/{id}/projects
is not the same than/projects
. In particular the later comes with thepermissions
field that is key for us to know if the user is admin or not.So, the first time that
sync_repositories
is called, we create theRemoteRepository
properly for this repository but then whensync_organizations
is called, we overwrite it with the new updated data (response withoutpermissions
) and link it to theRemoteOrganization
. The next time this remote repository is updated viasync_repositories
will be skipped as mentioned in the note.The quickest solution is to make a new API call to get a single project with all its fields including
permissions
, hitting https://docs.gitlab.com/ee/api/projects.html#get-single-project for each item returned in{url}/api/v4/groups/{id}/projects
,readthedocs.org/readthedocs/oauth/services/gitlab.py
Lines 111 to 120 in 2d64328
This will work, but we are adding extra calls to the API to re-fetch data that we already asked for while syncing repositories (before syncing organizations). We could find a way to share this data, but the code will more complex.
The text was updated successfully, but these errors were encountered: