Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Place1 committed Feb 20, 2020
1 parent 8e629af commit 70bc176
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 2 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,8 @@ func Read() *AppConfig {
return &config
}

func IsAuthEnabled(config *AppConfig) bool {
if config.Auth == nil {
return false
}
return config.Auth.OIDC != nil || config.Auth.Gitlab != nil
func (config *AppConfig) IsAuthEnabled() bool {
return config.Auth != nil
}

func defaultInterface() (string, error) {
Expand Down
11 changes: 10 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,17 @@ func main() {
}
})

if conf.Auth != nil {
if conf.IsAuthEnabled() {
handler = auth.New(conf.Auth).Wrap(handler)
} else {
base := handler
handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
base.ServeHTTP(w, r.WithContext(authsession.SetIdentityCtx(r.Context(), &authsession.AuthSession{
Identity: &authsession.Identity{
Subject: "default",
},
})))
})
}

// Listen
Expand Down

0 comments on commit 70bc176

Please sign in to comment.