From 436ded0704f0cac1b108f1e33c1dc703a38e113e Mon Sep 17 00:00:00 2001 From: Idan Novogroder Date: Wed, 31 Jul 2024 14:02:17 +0300 Subject: [PATCH] WIP --- pkg/api/auth_middleware.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/api/auth_middleware.go b/pkg/api/auth_middleware.go index 7fb9c7989a6..923ccf53539 100644 --- a/pkg/api/auth_middleware.go +++ b/pkg/api/auth_middleware.go @@ -99,11 +99,15 @@ func AuthMiddleware(logger logging.Logger, swagger *openapi3.Swagger, authentica writeError(w, r, http.StatusBadRequest, err) return } - _, err = checkSecurityRequirements(r, securityRequirements, logger, authenticator, authService, sessionStore, oidcConfig, cookieAuthConfig) + user, err := checkSecurityRequirements(r, securityRequirements, logger, authenticator, authService, sessionStore, oidcConfig, cookieAuthConfig) if err != nil { writeError(w, r, http.StatusUnauthorized, err) return } + if user != nil { + ctx := r.Context() + r = r.WithContext(auth.WithUser(ctx, user)) + } next.ServeHTTP(w, r) }) }