Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
48bb61cf
Commit
48bb61cf
authored
Aug 15, 2017
by
Eric Stroczynski
Committed by
GitHub
Aug 15, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1028 from estroz/gitlab-scopes
connector/gitlab: correct scope strings, better default
parents
e361bc6c
ca75470a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
gitlab.go
connector/gitlab/gitlab.go
+10
-5
No files found.
connector/gitlab/gitlab.go
View file @
48bb61cf
...
...
@@ -17,8 +17,9 @@ import (
)
const
(
scopeEmail
=
"user:email"
scopeOrgs
=
"read:org"
// https://docs.gitlab.com/ee/integration/oauth_provider.html#authorized-applications
scopeUser
=
"read_user"
scopeAPI
=
"api"
)
// Config holds configuration options for gilab logins.
...
...
@@ -78,7 +79,11 @@ type gitlabConnector struct {
}
func
(
c
*
gitlabConnector
)
oauth2Config
(
scopes
connector
.
Scopes
)
*
oauth2
.
Config
{
gitlabScopes
:=
[]
string
{
"api"
}
gitlabScopes
:=
[]
string
{
scopeUser
}
if
scopes
.
Groups
{
gitlabScopes
=
[]
string
{
scopeAPI
}
}
gitlabEndpoint
:=
oauth2
.
Endpoint
{
AuthURL
:
c
.
baseURL
+
"/oauth/authorize"
,
TokenURL
:
c
.
baseURL
+
"/oauth/token"
}
return
&
oauth2
.
Config
{
ClientID
:
c
.
clientID
,
...
...
@@ -198,7 +203,7 @@ func (c *gitlabConnector) Refresh(ctx context.Context, s connector.Scopes, ident
// a bearer token as part of the request.
func
(
c
*
gitlabConnector
)
user
(
ctx
context
.
Context
,
client
*
http
.
Client
)
(
gitlabUser
,
error
)
{
var
u
gitlabUser
req
,
err
:=
http
.
NewRequest
(
"GET"
,
c
.
baseURL
+
"/api/v
3
/user"
,
nil
)
req
,
err
:=
http
.
NewRequest
(
"GET"
,
c
.
baseURL
+
"/api/v
4
/user"
,
nil
)
if
err
!=
nil
{
return
u
,
fmt
.
Errorf
(
"gitlab: new req: %v"
,
err
)
}
...
...
@@ -229,7 +234,7 @@ func (c *gitlabConnector) user(ctx context.Context, client *http.Client) (gitlab
// which inserts a bearer token as part of the request.
func
(
c
*
gitlabConnector
)
groups
(
ctx
context
.
Context
,
client
*
http
.
Client
)
([]
string
,
error
)
{
apiURL
:=
c
.
baseURL
+
"/api/v
3
/groups"
apiURL
:=
c
.
baseURL
+
"/api/v
4
/groups"
reNext
:=
regexp
.
MustCompile
(
"<(.*)>; rel=
\"
next
\"
"
)
reLast
:=
regexp
.
MustCompile
(
"<(.*)>; rel=
\"
last
\"
"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment