Skip to content

Commit 9a9e49f

Browse files
committed
add noAuthServiceName. skip OAuth for testing.
1 parent 4d0dd19 commit 9a9e49f

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

authenticator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package main
22

33
import (
44
"encoding/json"
5+
"fmt"
56
"github.com/go-martini/martini"
67
gooauth2 "github.com/golang/oauth2"
78
"github.com/martini-contrib/oauth2"
89
"io/ioutil"
910
"log"
1011
"net/http"
1112
"strings"
12-
"fmt"
1313
)
1414

1515
type Authenticator interface {
@@ -53,7 +53,7 @@ func GithubGeneral(opts *gooauth2.Options, conf *Conf) martini.Handler {
5353

5454
type BaseAuth struct {
5555
handler martini.Handler
56-
conf *Conf
56+
conf *Conf
5757
}
5858

5959
func (b *BaseAuth) Handler() martini.Handler {

conf.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import (
66
"io/ioutil"
77
)
88

9+
const (
10+
noAuthServiceName = "nothing" // for testing only (undocumented)
11+
)
12+
913
type Conf struct {
1014
Addr string `yaml:"address"`
1115
SSL SSLConf `yaml:"ssl"`

httpd.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,19 @@ func NewServer(conf *Conf) *Server {
4242

4343
func (s *Server) Run() error {
4444
m := martini.Classic()
45-
a := NewAuthenticator(s.Conf)
4645

4746
cookieStore := sessions.NewCookieStore([]byte(s.Conf.Auth.Session.Key))
4847
if domain := s.Conf.Auth.Session.CookieDomain; domain != "" {
4948
cookieStore.Options(sessions.Options{Domain: domain})
5049
}
5150
m.Use(sessions.Sessions("session", cookieStore))
52-
m.Use(a.Handler())
5351

54-
m.Use(loginRequired())
55-
m.Use(restrictRequest(s.Conf.Restrictions, a))
52+
if s.Conf.Auth.Info.Service != noAuthServiceName {
53+
a := NewAuthenticator(s.Conf)
54+
m.Use(a.Handler())
55+
m.Use(loginRequired())
56+
m.Use(restrictRequest(s.Conf.Restrictions, a))
57+
}
5658

5759
backendsFor := make(map[string][]Backend)
5860
backendIndex := make([]string, len(s.Conf.Proxies))

0 commit comments

Comments
 (0)