diff --git a/internal/config/config.go b/internal/config/config.go index d1370081..ce944230 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -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) { diff --git a/main.go b/main.go index dbca2b9c..2fcd15bd 100644 --- a/main.go +++ b/main.go @@ -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