MSP-7470 UserAuth->CustomAuth
This commit is contained in:
1 parent
41762113e7
commit
a185cb0878
4 files changed
+12
-12
No files matched your search
+1
-1
@@ -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,
|
||||
)
|
||||
|
||||
+4
-4
@@ -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 {
|
||||
|
||||
@@ -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], "/")
|
||||
}
|
||||
|
||||
@@ -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"},
|
||||
|
||||
Reference in new issue
Block a user