diff --git a/api/config.go b/api/config.go index 20db480..5759f0c 100644 --- a/api/config.go +++ b/api/config.go @@ -56,6 +56,7 @@ func configParse() error { "GITLAB_KEY": "", "GITLAB_SECRET": "", + "GITLAB_URL": "https://gitlab.com", } if os.Getenv("COMMENTO_CONFIG_FILE") != "" { diff --git a/api/oauth_gitlab.go b/api/oauth_gitlab.go index 495ba58..33fb54a 100644 --- a/api/oauth_gitlab.go +++ b/api/oauth_gitlab.go @@ -35,6 +35,8 @@ func gitlabOauthConfigure() error { }, Endpoint: gitlab.Endpoint, } + gitlabConfig.Endpoint.AuthURL = os.Getenv("GITLAB_URL") + "/oauth/authorize" + gitlabConfig.Endpoint.TokenURL = os.Getenv("GITLAB_URL") + "/oauth/token" gitlabConfigured = true diff --git a/api/oauth_gitlab_callback.go b/api/oauth_gitlab_callback.go index 112c0a6..5058290 100644 --- a/api/oauth_gitlab_callback.go +++ b/api/oauth_gitlab_callback.go @@ -6,6 +6,7 @@ import ( "golang.org/x/oauth2" "io/ioutil" "net/http" + "os" ) func gitlabCallbackHandler(w http.ResponseWriter, r *http.Request) { @@ -24,7 +25,7 @@ func gitlabCallbackHandler(w http.ResponseWriter, r *http.Request) { return } - resp, err := http.Get("https://gitlab.com/api/v4/user?access_token=" + token.AccessToken) + resp, err := http.Get(os.Getenv("GITLAB_URL") + "/api/v4/user?access_token=" + token.AccessToken) if err != nil { fmt.Fprintf(w, "Error: %s", err.Error()) return