Merge branch 'rename_authenticateMethodPath' into 'main'

Rename authenticatemethodpath

See merge request isp/isp-gate-service!35
This commit is contained in:
Синельник Тимур Романович committed 2026-04-08 18:34:57 +03:00
commit cca6ce0ad1
5 files changed
+30 -28

No files matched your search

+1 -1
View File
@@ -1 +1 @@
5.10.0
5.10.1
+2
View File
@@ -1,3 +1,5 @@
### v5.10.1
* Изменен нейминг настройки `customAuth.userAuthSettings.authenticateMethodPath` на `customAuth.userAuthSettings.authenticateEndpoint`
### v5.10.0
* Добавлена конфигурируемая аутентификация/авторизация пользователя
### v5.9.3
+5 -5
View File
@@ -92,9 +92,9 @@ type CookieTokenProvider struct {
}
type UserAuthSetting struct {
ModuleNameList []string `schema:"Название модулей,для которых настраивается аутентификация/авторизация" validate:"required"`
TokenProvider string `schema:"Название метода получения токена из запроса" validate:"required"`
AuthenticateMethodPath string `schema:"Путь до метода аутентификации,метод вызывается через isp-router-service" validate:"required"`
CacheDataInSec int `schema:"Время кеширования данных аутентификации/авторизации пользователя,отключен при значениях <=0,в секундах"`
SkipAppAuth bool `schema:"Пропустить аутентификацию и авторизацию приложения"`
ModuleNameList []string `schema:"Название модулей,для которых настраивается аутентификация/авторизация,название модулей должно быть уникальным" validate:"required"`
TokenProvider string `schema:"Название метода получения токена из запроса" validate:"required"`
AuthenticateEndpoint string `schema:"Endpoint для аутентификации пользователя,вызывается через isp-router-service" validate:"required"`
CacheDataInSec int `schema:"Время кеширования данных аутентификации/авторизации пользователя,отключен при значениях <=0,в секундах"`
SkipAppAuth bool `schema:"Пропустить аутентификацию и авторизацию приложения"`
}
+9 -9
View File
@@ -15,12 +15,12 @@ import (
)
type UserAuthenticationCache interface {
Get(ctx context.Context, authMethodPath string, token string) (*entity.UserAuthData, error)
Set(ctx context.Context, authMethodPath string, token string, data entity.UserAuthData, duration time.Duration) error
Get(ctx context.Context, authEndpoint string, token string) (*entity.UserAuthData, error)
Set(ctx context.Context, authEndpoint string, token string, data entity.UserAuthData, duration time.Duration) error
}
type UserAuthenticationRepo interface {
Authenticate(ctx context.Context, methodPath string, token string) (*entity.UserAuthenticateResponse, error)
Authenticate(ctx context.Context, authEndpoint string, token string) (*entity.UserAuthenticateResponse, error)
}
type TokenProvider interface {
@@ -29,7 +29,7 @@ type TokenProvider interface {
type userAuthSetting struct {
tokenProvider string
authenticatePath string
authEndpoint string
authCacheDuration time.Duration
skipAppAuth bool
}
@@ -82,7 +82,7 @@ func NewUserAuthentication(
}
settingsByModuleName[moduleName] = userAuthSetting{
tokenProvider: setting.TokenProvider,
authenticatePath: setting.AuthenticateMethodPath,
authEndpoint: setting.AuthenticateEndpoint,
authCacheDuration: cacheDuration,
skipAppAuth: setting.SkipAppAuth,
}
@@ -141,17 +141,17 @@ func (s UserAuthentication) authenticate(
token string,
) (*domain.AuthenticateUserResponse, error) {
if setting.authCacheDuration <= 0 {
resp, err := s.repo.Authenticate(ctx, setting.authenticatePath, token)
resp, err := s.repo.Authenticate(ctx, setting.authEndpoint, token)
if err != nil {
return nil, errors.WithMessage(err, "auth repo authenticate")
}
return s.convertAuthReponse(resp, setting.skipAppAuth), nil
}
authData, err := s.cache.Get(ctx, setting.authenticatePath, token)
authData, err := s.cache.Get(ctx, setting.authEndpoint, token)
switch {
case errors.Is(err, domain.ErrAuthenticationCacheMiss):
resp, err := s.repo.Authenticate(ctx, setting.authenticatePath, token)
resp, err := s.repo.Authenticate(ctx, setting.authEndpoint, token)
if err != nil {
return nil, errors.WithMessage(err, "auth repo authenticate")
}
@@ -160,7 +160,7 @@ func (s UserAuthentication) authenticate(
}
err = s.cache.Set(
ctx,
setting.authenticatePath,
setting.authEndpoint,
token,
*resp.AuthData,
setting.authCacheDuration,
+13 -13
View File
@@ -379,14 +379,14 @@ func (s *HappyPathTestSuite) TestUserAuthorization() { // nolint:funlen
},
UserAuthSettings: []conf.UserAuthSetting{
{
ModuleNameList: []string{"target"},
TokenProvider: "test_provider",
AuthenticateMethodPath: "test-user-auth/authenticate",
ModuleNameList: []string{"target"},
TokenProvider: "test_provider",
AuthenticateEndpoint: "test-user-auth/authenticate",
},
{
ModuleNameList: []string{"target2"},
TokenProvider: "test_provider",
AuthenticateMethodPath: "failed-user-auth/authenticate",
ModuleNameList: []string{"target2"},
TokenProvider: "test_provider",
AuthenticateEndpoint: "failed-user-auth/authenticate",
},
},
}
@@ -518,15 +518,15 @@ func (s *HappyPathTestSuite) TestUserAuthorization_SkipAppAuth() { // nolint:fun
},
UserAuthSettings: []conf.UserAuthSetting{
{
ModuleNameList: []string{"target"},
TokenProvider: "test_provider",
AuthenticateMethodPath: "test-user-auth/authenticate",
SkipAppAuth: true,
ModuleNameList: []string{"target"},
TokenProvider: "test_provider",
AuthenticateEndpoint: "test-user-auth/authenticate",
SkipAppAuth: true,
},
{
ModuleNameList: []string{"target2"},
TokenProvider: "test_provider",
AuthenticateMethodPath: "test-user-auth/authenticate",
ModuleNameList: []string{"target2"},
TokenProvider: "test_provider",
AuthenticateEndpoint: "test-user-auth/authenticate",
},
},
}