From 7cca2eb773f69ab06e73830399d0030577096b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B8=D0=BD=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=20?= =?UTF-8?q?=D0=A2=D0=B8=D0=BC=D1=83=D1=80=20=D0=A0=D0=BE=D0=BC=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=B8=D1=87?= Date: Wed, 1 Apr 2026 10:16:03 +0300 Subject: [PATCH] MSP-7470 Add skip app auth log --- assembly/locator.go | 2 +- domain/auth.go | 2 +- middleware/user_authenticate.go | 12 ++++++++++-- service/user_authentication.go | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/assembly/locator.go b/assembly/locator.go index a69b1d5..0e92bd0 100644 --- a/assembly/locator.go +++ b/assembly/locator.go @@ -132,7 +132,7 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha ), middleware.RequestId(), middleware.ErrorHandler(l.logger), - middleware.UserAuthenticate(userAuthentication), + middleware.UserAuthenticate(userAuthentication, l.logger), middleware.Authenticate(authentication), middleware.AdminAuthenticate(adminService), middleware.ClientRequestId(config.EnableClientRequestIdForwarding, forwardReqIdByAppId), diff --git a/domain/auth.go b/domain/auth.go index d9c5452..94b107a 100644 --- a/domain/auth.go +++ b/domain/auth.go @@ -25,7 +25,7 @@ type UserToken struct { type AuthenticateUserResponse struct { Authenticated bool - ShouldSkip bool + SkipUserAuth bool ErrorReason string AuthData *UserAuthData } diff --git a/middleware/user_authenticate.go b/middleware/user_authenticate.go index 8fab85f..7e03a45 100644 --- a/middleware/user_authenticate.go +++ b/middleware/user_authenticate.go @@ -8,20 +8,21 @@ import ( "isp-gate-service/request" "github.com/pkg/errors" + "github.com/txix-open/isp-kit/log" ) type UserAuthenticator interface { Authenticate(ctx *request.Context) (*domain.AuthenticateUserResponse, error) } -func UserAuthenticate(authenticator UserAuthenticator) Middleware { +func UserAuthenticate(authenticator UserAuthenticator, logger log.Logger) Middleware { return func(next Handler) Handler { return HandlerFunc(func(ctx *request.Context) error { resp, err := authenticator.Authenticate(ctx) if err != nil { return errors.WithMessage(err, "authenticate user: authenticator error") } - if resp.ShouldSkip { + if resp.SkipUserAuth { return next.Handle(ctx) } @@ -34,6 +35,13 @@ func UserAuthenticate(authenticator UserAuthenticator) Middleware { } ctx.AuthenticateUser(*resp.AuthData) + + if ctx.SkipAppAuth() { + logger.Debug( + ctx.Context(), + "skip app auth is set. All steps that require app auth data are skipped", + ) + } return next.Handle(ctx) }) } diff --git a/service/user_authentication.go b/service/user_authentication.go index 4a3c22f..3a779b3 100644 --- a/service/user_authentication.go +++ b/service/user_authentication.go @@ -120,7 +120,7 @@ func (s UserAuthentication) Authenticate(ctx *request.Context) (*domain.Authenti } return &domain.AuthenticateUserResponse{ - ShouldSkip: true, + SkipUserAuth: true, }, nil }