-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Panic with GitLab project repository auth #1113
Conversation
@@ -331,7 +331,7 @@ func (p *GitLabProvider) addProjectsToSession(ctx context.Context, s *sessions.S | |||
perms = projectInfo.Permissions.GroupAccess | |||
} | |||
|
|||
if perms.AccessLevel >= project.AccessLevel { | |||
if perms != nil && perms.AccessLevel >= project.AccessLevel { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mixed with the above if perms == nil
fallback handling is slightly confusing. Can we check for nil
on line 331 on projectInfo.Permissions.GroupAccess
and log + continue
if it is?
Can you also add a scenario for this case to the test table here:
oauth2-proxy/providers/gitlab_test.go
Line 189 in 4d9de06
Context("when filtering on gitlab entities (groups and projects)", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - I have reformatted it as suggested.
* /api/v4/projects/:id can return nil permissions Signed-off-by: Piers Harding <piers@ompka.net>
@piersharding can you also add a test case for this ? Thanks ! |
Signed-off-by: Piers Harding <piers@ompka.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
We are releasing in a couple of hours, we'll take care of adding a CHANGELOG entry in the release PR. |
Thanks - sorry, I was learning the process as I was going along. |
No worries! Thanks for the finding the issue & submitting the fix! |
* panic with GitLab project repository auth * /api/v4/projects/:id can return nil permissions Signed-off-by: Piers Harding <piers@ompka.net> * Add GitLab test for group no access Signed-off-by: Piers Harding <piers@ompka.net>
* panic with GitLab project repository auth * /api/v4/projects/:id can return nil permissions Signed-off-by: Piers Harding <piers@ompka.net> * Add GitLab test for group no access Signed-off-by: Piers Harding <piers@ompka.net>
Co-authored-by: 澄潭 <zty98751@alibaba-inc.com> Co-authored-by: Kent Dong <ch3cho@qq.com>
Signed-off-by: Piers Harding piers@ompka.net
Description
Check project API payload for
nil
in GroupAccess value.fixes #1111
Motivation and Context
This PR addresses #1111 - where the GitLab projects API (https://docs.gitlab.com/ee/api/projects.html) does not necessarily return a GroupAccess value. The resulting permissions are now checked for
nil
to mitigate this.How Has This Been Tested?
The change has been tested with setting
--gitlab-project=ska-telescope/ska-tango-images=30
, and running against the patched image registry.gitlab.com/piersharding/oauth2-proxy:latest .Checklist:
(not too sure about these settings)