From 9594156baff43a92c155f7e42764bd2484f26bd7 Mon Sep 17 00:00:00 2001 From: Sanne Raymaekers Date: Fri, 23 Jun 2023 00:37:01 +0200 Subject: [PATCH] internal/worker: use TenantChannelMiddleware --- internal/cloudapi/v2/v2_multi_tenancy_test.go | 1 + internal/worker/server.go | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/cloudapi/v2/v2_multi_tenancy_test.go b/internal/cloudapi/v2/v2_multi_tenancy_test.go index 3ff9f7bc2..452970cfc 100644 --- a/internal/cloudapi/v2/v2_multi_tenancy_test.go +++ b/internal/cloudapi/v2/v2_multi_tenancy_test.go @@ -176,6 +176,7 @@ func runNextJob(t *testing.T, jobs []uuid.UUID, workerHandler http.Handler, orgI Method: http.MethodPatch, Path: job.Location, RequestBody: test.JSONRequestBody(`{"result": {"job_result":{}}}`), + Context: reqContext(orgID), ExpectedStatus: http.StatusOK, }.Do(t) } diff --git a/internal/worker/server.go b/internal/worker/server.go index 422c2931b..f8aff3c60 100644 --- a/internal/worker/server.go +++ b/internal/worker/server.go @@ -100,8 +100,13 @@ func (s *Server) Handler() http.Handler { server: s, } - statusMW := prometheus.StatusMiddleware(prometheus.WorkerSubsystem) - api.RegisterHandlers(e.Group(api.BasePath, statusMW), &handler) + mws := []echo.MiddlewareFunc{ + prometheus.StatusMiddleware(prometheus.WorkerSubsystem), + } + if s.config.JWTEnabled { + mws = append(mws, auth.TenantChannelMiddleware(s.config.TenantProviderFields, api.HTTPError(api.ErrorTenantNotFound))) + } + api.RegisterHandlers(e.Group(api.BasePath, mws...), &handler) return e }