diff --git a/server/internal/app/app.go b/server/internal/app/app.go index 94790e08e..cb0c484ed 100644 --- a/server/internal/app/app.go +++ b/server/internal/app/app.go @@ -58,24 +58,22 @@ func initEcho(ctx context.Context, cfg *ServerConfig) *echo.Echo { } // auth + authConfig := cfg.Config.JWTProviders() + log.Infof("auth: config: %#v", authConfig) + var wrapHandler func(http.Handler) http.Handler if cfg.Config.UseMockAuth() { log.Infof("Using mock auth for local development") wrapHandler = func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() ctx = adapter.AttachMockAuth(ctx, true) next.ServeHTTP(w, r.WithContext(ctx)) }) } } else { - authConfig := cfg.Config.JWTProviders() - log.Infof("auth: config: %#v", authConfig) - if cfg.Config.AuthSrv.Disabled { - wrapHandler = lo.Must(AuthMiddlewareDummy()) - } else { - wrapHandler = lo.Must(appx.AuthMiddleware(authConfig, adapter.ContextAuthInfo, true)) - } + wrapHandler = lo.Must(appx.AuthMiddleware(authConfig, adapter.ContextAuthInfo, true)) } e.Use(echo.WrapMiddleware(wrapHandler)) @@ -161,12 +159,6 @@ func initEcho(ctx context.Context, cfg *ServerConfig) *echo.Echo { return e } -func AuthMiddlewareDummy() (func(http.Handler) http.Handler, error) { - return func(next http.Handler) http.Handler { - return next - }, nil -} - func errorHandler(next func(error, echo.Context)) func(error, echo.Context) { return func(err error, c echo.Context) { if c.Response().Committed {