From 687ffb4a0c0533992addf272ab1932374d17816a Mon Sep 17 00:00:00 2001 From: Karl Persson Date: Wed, 29 Nov 2023 15:55:39 +0100 Subject: [PATCH] Authn: Only resolve org id once (#78811) --- pkg/services/authn/authnimpl/service.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/services/authn/authnimpl/service.go b/pkg/services/authn/authnimpl/service.go index ce7d6f13455..b72fc43600a 100644 --- a/pkg/services/authn/authnimpl/service.go +++ b/pkg/services/authn/authnimpl/service.go @@ -191,6 +191,8 @@ func (s *Service) Authenticate(ctx context.Context, r *authn.Request) (*authn.Id ctx, span := s.tracer.Start(ctx, "authn.Authenticate") defer span.End() + r.OrgID = orgIDFromRequest(r) + var authErr error for _, item := range s.clientQueue.items { if item.v.Test(ctx, r) { @@ -223,7 +225,6 @@ func (s *Service) Authenticate(ctx context.Context, r *authn.Request) (*authn.Id } func (s *Service) authenticate(ctx context.Context, c authn.Client, r *authn.Request) (*authn.Identity, error) { - r.OrgID = orgIDFromRequest(r) identity, err := c.Authenticate(ctx, r) if err != nil { s.errorLogFunc(ctx, err)("Failed to authenticate request", "client", c.Name(), "error", err) @@ -268,6 +269,8 @@ func (s *Service) Login(ctx context.Context, client string, r *authn.Request) (i )) defer span.End() + r.OrgID = orgIDFromRequest(r) + defer func() { for _, hook := range s.postLoginHooks.items { hook.v(ctx, identity, r, err)