Skip to content

Commit

Permalink
GitLab provider: honor explicit --scope option when using groups
Browse files Browse the repository at this point in the history
and default to "openid" instead of "api" when using groups
  • Loading branch information
ploxiln committed Apr 29, 2019
1 parent 84d761c commit 297362b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions providers/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ func NewGitLabProvider(p *ProviderData) *GitLabProvider {
Path: "/api/v4/user",
}
}
if p.Scope == "" {
p.Scope = "read_user"
}
return &GitLabProvider{ProviderData: p}
}

func (p *GitLabProvider) SetGroups(groups []string) {
p.Groups = groups
if len(groups) > 0 {
p.Scope = "api"

if p.Scope == "" {
if len(groups) > 0 {
p.Scope = "openid"
} else {
p.Scope = "read_user"
}
}
}

Expand Down
1 change: 1 addition & 0 deletions providers/gitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func testGitLabProvider(hostname string) *GitLabProvider {
updateURL(p.Data().ProfileURL, hostname)
updateURL(p.Data().ValidateURL, hostname)
}
p.SetGroups([]string{})
return p
}

Expand Down

0 comments on commit 297362b

Please sign in to comment.