Open jdfresser opened 1 year ago
I have the same error with Gitlab and project import. This is the error I get
error_json
{'error': 'insufficient_scope',
'error_description': 'The request requires higher privileges than provided by '
'the access token.',
'scope': 'api read_api'}
I have given my Gitlab application read_user
, read_repository
and openapi
scopes, which are correctly setup and requested from defect dojo when redirecting to Gitlab. But when redirecting back to the callback I get the following error and import fails in
projects = gl.projects.list(membership=True, min_access_level=settings.GITLAB_PROJECT_MIN_ACCESS_LEVEL, all=True)
Removing auto import option and gitlab authentication works.
I had the same issue.
Here is how I solved it:
DD_SOCIAL_AUTH_GITLAB_SCOPE: "read_api, read_user, openid, read_repository"
Same problem, still not solved. And settings.dist.py now has sha256 checksum.
@Ma1tobiose The sha256sum is quite on purpose.
If you look at the top of settings.dist.py, you'll see this:
#########################################################################################################
# It is not allowed to edit file 'settings.dist.py', for production deployemnts. #
# Any customization of variables need to be done via environmental variables or in 'local_settings.py'. #
# For more information check https://documentation.defectdojo.com/getting_started/configuration/ #
#########################################################################################################
DefectDojo have local_settings.py to specifically allow customization local to your DefectDojo install in a way that makes upgrades safe as settings.dist.py can be overwritten on upgrades.
There's an example of a local_settings.py file at https://github.com/DefectDojo/django-DefectDojo/blob/master/dojo/settings/template-local_settings
If you create a local_settings.py and make the changes you want there, you'll be safe from upgrades and the sha256sum check.
@mtesauro Thanks for reply. Yes, I agree with the behavior of sha256, and it is a very reliable solution. I mention it here because the previous fix solution failed, and I want to warn people who come across the same problem later. So I think the login 403 problem of GITLAB_PROJECT_AUTO_IMPORT should be fixed. Maybe we can merge this part of the code instead of setting it as a local setting?
@Ma1tobiose Got it. If you'd like to put in a PR to add that to settings.dist.py, I don't have a problem with that.
Problem description I tried to the Gitlab Oauth, I managed to connect. When I tried to use the DD_SOCIAL_AUTH_GITLAB_PROJECT_AUTO_IMPORT option, login fails.
So it seems the issue is a right issue when the gl.projects.list function, I understand it is a right/scope related issue. I tried to activate all Scopes but not changes. I sticked to the minimum rights:
The annoying thing is that if this function fails, the login fails too.
I asked to Gitlab about the scope issue but I was wondering if somebody else faced this issue.
Steps to reproduce Steps to reproduce the behavior:
read_repository
right so that PROJECT_AUTO_IMPORT will failExpected behavior While login in & GITLAB_PROJECT_AUTO_IMPORT option activated, if there are troubles with the Gitlab API, login should still work.
Deployment method (select with an
X
)Environment information