aboutsummaryrefslogtreecommitdiff
path: root/server/auth/gitlab
diff options
context:
space:
mode:
Diffstat (limited to 'server/auth/gitlab')
-rw-r--r--server/auth/gitlab/gitlab.go5
-rw-r--r--server/auth/gitlab/gitlab_test.go13
2 files changed, 6 insertions, 12 deletions
diff --git a/server/auth/gitlab/gitlab.go b/server/auth/gitlab/gitlab.go
index 27edafa..f76b2e8 100644
--- a/server/auth/gitlab/gitlab.go
+++ b/server/auth/gitlab/gitlab.go
@@ -2,7 +2,6 @@ package gitlab
import (
"errors"
- "net/http"
"strconv"
"github.com/nsheridan/cashier/server/auth"
@@ -52,6 +51,7 @@ func New(c *config.Auth) (*Config, error) {
config: &oauth2.Config{
ClientID: c.OauthClientID,
ClientSecret: c.OauthClientSecret,
+ RedirectURL: c.OauthCallbackURL,
Endpoint: oauth2.Endpoint{
AuthURL: siteURL + "oauth/authorize",
TokenURL: siteURL + "oauth/token",
@@ -110,8 +110,7 @@ func (c *Config) Revoke(token *oauth2.Token) error {
}
// StartSession retrieves an authentication endpoint from Gitlab.
-func (c *Config) StartSession(state string, r *http.Request) *auth.Session {
- c.config.RedirectURL = auth.Oauth2RedirectURL(r)
+func (c *Config) StartSession(state string) *auth.Session {
return &auth.Session{
AuthURL: c.config.AuthCodeURL(state),
}
diff --git a/server/auth/gitlab/gitlab_test.go b/server/auth/gitlab/gitlab_test.go
index 676cda2..39c2701 100644
--- a/server/auth/gitlab/gitlab_test.go
+++ b/server/auth/gitlab/gitlab_test.go
@@ -2,7 +2,6 @@ package gitlab
import (
"fmt"
- "net/http"
"testing"
"github.com/nsheridan/cashier/server/auth"
@@ -26,6 +25,7 @@ func TestNew(t *testing.T) {
g := p.(*Config)
a.Equal(g.config.ClientID, oauthClientID)
a.Equal(g.config.ClientSecret, oauthClientSecret)
+ a.Equal(g.config.RedirectURL, oauthCallbackURL)
}
func TestNewBrokenSiteURL(t *testing.T) {
@@ -55,10 +55,7 @@ func TestGoodAllUsers(t *testing.T) {
a := assert.New(t)
p, _ := newGitlab()
- r := &http.Request{
- Host: oauthCallbackURL,
- }
- s := p.StartSession("test_state", r)
+ s := p.StartSession("test_state")
a.Contains(s.AuthURL, "exampleorg/oauth/authorize")
a.Contains(s.AuthURL, "state=test_state")
a.Contains(s.AuthURL, fmt.Sprintf("client_id=%s", oauthClientID))
@@ -80,10 +77,7 @@ func TestStartSession(t *testing.T) {
a := assert.New(t)
p, _ := newGitlab()
- r := &http.Request{
- Host: oauthCallbackURL,
- }
- s := p.StartSession("test_state", r)
+ s := p.StartSession("test_state")
a.Contains(s.AuthURL, "exampleorg/oauth/authorize")
a.Contains(s.AuthURL, "state=test_state")
a.Contains(s.AuthURL, fmt.Sprintf("client_id=%s", oauthClientID))
@@ -93,6 +87,7 @@ func newGitlab() (auth.Provider, error) {
c := &config.Auth{
OauthClientID: oauthClientID,
OauthClientSecret: oauthClientSecret,
+ OauthCallbackURL: oauthCallbackURL,
ProviderOpts: map[string]string{
"group": group,
"siteurl": siteurl,