Skip to content

Commit 7788749

Browse files
committed
allow gitlab urls to be configurable
1 parent 6836cea commit 7788749

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

providers/gitlab/gitlab.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,17 @@ import (
1414
"strconv"
1515
)
1616

17-
const (
18-
authURL string = "https://gitlab.com/oauth/authorize"
19-
tokenURL string = "https://gitlab.com/oauth/token"
20-
endpointProfile string = "https://gitlab.com/api/v3/user"
17+
// These vars define the Authentication, Token, and Profile URLS for Gitlab. If
18+
// using Gitlab CE or EE, you should change these values before calling New.
19+
//
20+
// Examples:
21+
// gitlab.AuthURL = "https://gitlab.acme.com/oauth/authorize
22+
// gitlab.TokenURL = "https://gitlab.acme.com/oauth/token
23+
// gitlab.ProfileURL = "https://gitlab.acme.com/api/v3/user
24+
var (
25+
AuthURL = "https://gitlab.com/oauth/authorize"
26+
TokenURL = "https://gitlab.com/oauth/token"
27+
ProfileURL = "https://gitlab.com/api/v3/user"
2128
)
2229

2330
// Provider is the implementation of `goth.Provider` for accessing Gitlab.
@@ -66,7 +73,7 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
6673
ExpiresAt: sess.ExpiresAt,
6774
}
6875

69-
response, err := http.Get(endpointProfile + "?access_token=" + url.QueryEscape(sess.AccessToken))
76+
response, err := http.Get(ProfileURL + "?access_token=" + url.QueryEscape(sess.AccessToken))
7077
if err != nil {
7178
if response != nil {
7279
response.Body.Close()
@@ -97,8 +104,8 @@ func newConfig(provider *Provider, scopes []string) *oauth2.Config {
97104
ClientSecret: provider.Secret,
98105
RedirectURL: provider.CallbackURL,
99106
Endpoint: oauth2.Endpoint{
100-
AuthURL: authURL,
101-
TokenURL: tokenURL,
107+
AuthURL: AuthURL,
108+
TokenURL: TokenURL,
102109
},
103110
Scopes: []string{},
104111
}

0 commit comments

Comments
 (0)