MSP-7470 Add skip app auth log

This commit is contained in:
Синельник Тимур Романович committed 2026-04-01 10:21:59 +03:00
1 parent eb6326c343
commit 7cca2eb773
4 files changed
+13 -5

No files matched your search

+1 -1
View File
@@ -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),
+1 -1
View File
@@ -25,7 +25,7 @@ type UserToken struct {
type AuthenticateUserResponse struct {
Authenticated bool
ShouldSkip bool
SkipUserAuth bool
ErrorReason string
AuthData *UserAuthData
}
+10 -2
View File
@@ -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)
})
}
+1 -1
View File
@@ -120,7 +120,7 @@ func (s UserAuthentication) Authenticate(ctx *request.Context) (*domain.Authenti
}
return &domain.AuthenticateUserResponse{
ShouldSkip: true,
SkipUserAuth: true,
}, nil
}