From a185cb0878cac155b232ac67479224497c4f5b92 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 13:14:22 +0300 Subject: [PATCH] MSP-7470 UserAuth->CustomAuth --- assembly/locator.go | 2 +- conf/remote.go | 8 ++++---- service/user_authentication.go | 6 +++--- tests/acceptance_test.go | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/assembly/locator.go b/assembly/locator.go index 0e92bd0..7e44244 100644 --- a/assembly/locator.go +++ b/assembly/locator.go @@ -65,7 +65,7 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha userAuthenticationCache := repository.NewUserAuthenticationCache(time.Duration(config.Caching.AuthenticationDataInSec) * time.Second) userAuthRepo := repository.NewUserAuth(l.routerLb) userAuthentication, err := service.NewUserAuthentication( - config.UserAuth, + config.CustomAuth, userAuthenticationCache, userAuthRepo, ) diff --git a/conf/remote.go b/conf/remote.go index 8a139f7..b48b5bc 100644 --- a/conf/remote.go +++ b/conf/remote.go @@ -29,7 +29,7 @@ type Remote struct { Throttling []Throttling `schema:"Настройки пропускной способности"` EnableClientRequestIdForwarding bool `schema:"Включить проброс requestId из заголовка запроса"` ForwardReqIdClientSettings []ForwardReqIdClientSettings `schema:"Настройки проброcа requestId для приложений"` - UserAuth UserAuth `schema:"Настройка аутентификации/авторизации пользователя"` + CustomAuth CustomAuth `schema:"Настройка кастомной аутентификации/авторизации"` } type ForwardReqIdClientSettings struct { @@ -65,9 +65,9 @@ type Throttling struct { RequestsPerSeconds int `validate:"required,min=1,max=1000" schema:"Запросов в секунду,не конфликтует с суточными ограничениями, алгоритм не работает на значениях больше 1000"` } -type UserAuth struct { - TokenProviders []TokenProvider `schema:"Настройки получения токена из запроса"` - AuthSettings []UserAuthSetting `schema:"Настройка пользовательской аутентификации/авторизации"` +type CustomAuth struct { + TokenProviders []TokenProvider `schema:"Настройки получения токена из запроса"` + UserAuthSettings []UserAuthSetting `schema:"Настройка пользовательской аутентификации/авторизации"` } type AuthProvider struct { diff --git a/service/user_authentication.go b/service/user_authentication.go index 50e4735..29e0ae8 100644 --- a/service/user_authentication.go +++ b/service/user_authentication.go @@ -41,7 +41,7 @@ type UserAuthentication struct { } func NewUserAuthentication( - cfg conf.UserAuth, + cfg conf.CustomAuth, cache UserAuthenticationCache, repo UserAuthenticationRepo, ) (UserAuthentication, error) { @@ -59,8 +59,8 @@ func NewUserAuthentication( tokenProviders[provider.Name] = tokenProvider } - endpointsSettings := make([]userAuthSetting, 0, len(cfg.AuthSettings)) - for _, setting := range cfg.AuthSettings { + endpointsSettings := make([]userAuthSetting, 0, len(cfg.UserAuthSettings)) + for _, setting := range cfg.UserAuthSettings { for i := range setting.EndpointPrefixes { setting.EndpointPrefixes[i] = strings.TrimPrefix(setting.EndpointPrefixes[i], "/") } diff --git a/tests/acceptance_test.go b/tests/acceptance_test.go index ee8576b..2849574 100644 --- a/tests/acceptance_test.go +++ b/tests/acceptance_test.go @@ -366,7 +366,7 @@ func (s *HappyPathTestSuite) TestUserAuthorization() { // nolint:funlen Protocol: "grpc", TargetModule: "target", }} - config.UserAuth = conf.UserAuth{ + config.CustomAuth = conf.CustomAuth{ TokenProviders: []conf.TokenProvider{ { Name: "test_provider", @@ -376,7 +376,7 @@ func (s *HappyPathTestSuite) TestUserAuthorization() { // nolint:funlen }, }, }, - AuthSettings: []conf.UserAuthSetting{ + UserAuthSettings: []conf.UserAuthSetting{ { EndpointPrefixes: []string{"endpoint"}, TokenProviders: []string{"test_provider"}, @@ -493,7 +493,7 @@ func (s *HappyPathTestSuite) TestUserAuthorization_SkipAppAuth() { // nolint:fun Protocol: "grpc", TargetModule: "target", }} - config.UserAuth = conf.UserAuth{ + config.CustomAuth = conf.CustomAuth{ TokenProviders: []conf.TokenProvider{ { Name: "test_provider", @@ -503,7 +503,7 @@ func (s *HappyPathTestSuite) TestUserAuthorization_SkipAppAuth() { // nolint:fun }, }, }, - AuthSettings: []conf.UserAuthSetting{ + UserAuthSettings: []conf.UserAuthSetting{ { EndpointPrefixes: []string{"endpoint"}, TokenProviders: []string{"test_provider"},