Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36699fdc72 | ||
|
|
a269de8e17 | ||
|
|
15cb2cadf2 | ||
|
|
76f88fd593 | ||
|
|
9ff0057014 | ||
|
|
71a1f0a04e | ||
|
|
394bbc82e2 | ||
|
|
7de248e63c | ||
|
|
011a1d7048 |
No files matched your search
@@ -1,3 +1,22 @@
|
||||
### v5.11.3
|
||||
* добавлена настройка для преопределения content-type в ответе с `application/json` на `application/json; charset=utf-8` для конкретных приложений
|
||||
### v5.11.2
|
||||
* обновлены зависимости
|
||||
### v5.11.1
|
||||
* Обновлен isp-kit
|
||||
### v5.11.0
|
||||
* Добавлена поддержка нескольких `tokenProvider` для `customAuth.userAuthSettings`: используется первый провайдер, вернувший токен
|
||||
### v5.10.2
|
||||
* Убрано дублирование поля `requestId` при логгировании
|
||||
### v5.10.1
|
||||
* Изменен нейминг настройки `customAuth.userAuthSettings.authenticateMethodPath` на `customAuth.userAuthSettings.authenticateEndpoint`
|
||||
### v5.10.0
|
||||
* Добавлена конфигурируемая аутентификация/авторизация пользователя
|
||||
### v5.9.3
|
||||
* Исправлена опечатка при вызове `strings.TrimPrefix`
|
||||
### v5.9.2
|
||||
* При проверке `logging.skipBodyLoggingEndpointPrefixes` игнорируется `/` в начале, путь для проверки берётся из `pathSchema`, если `pathSchema` пустая, берётся вызываемый `endpoint`
|
||||
* В логе `log request` из значения в поле `endpoint` удаляется `/` в начале, путь берётся из `pathSchema`, если `pathSchema` пустая, берётся вызываемый `endpoint`
|
||||
### v5.9.1
|
||||
* Добавлен `warn` лог на неизвестный endpoint
|
||||
### v5.9.0
|
||||
|
||||
+20
-1
@@ -2,20 +2,27 @@ package assembly
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"isp-gate-service/cache"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/routes"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/app"
|
||||
"github.com/txix-open/isp-kit/bootstrap"
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
"github.com/txix-open/isp-kit/http"
|
||||
"github.com/txix-open/isp-kit/lb"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
)
|
||||
|
||||
const (
|
||||
routerModuleName = "isp-router-service"
|
||||
usersAuthCachePurgeInterval = 5 * time.Second
|
||||
)
|
||||
|
||||
type Assembly struct {
|
||||
boot *bootstrap.Bootstrap
|
||||
server *http.Server
|
||||
@@ -24,10 +31,13 @@ type Assembly struct {
|
||||
systemCli *client.Client
|
||||
adminCli *client.Client
|
||||
lockerCli *client.Client
|
||||
routerLb *lb.RoundRobin
|
||||
|
||||
locations []conf.Location
|
||||
grpcClientByModuleName map[string]*client.Client
|
||||
httpHostManagerByModuleName map[string]*lb.RoundRobin
|
||||
|
||||
usersAuthCache *cache.Cache
|
||||
}
|
||||
|
||||
func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
||||
@@ -81,6 +91,8 @@ func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
||||
systemCli: systemCli,
|
||||
adminCli: adminCli,
|
||||
lockerCli: lockerCli,
|
||||
routerLb: lb.NewRoundRobin(nil),
|
||||
usersAuthCache: cache.New(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -103,6 +115,8 @@ func (a *Assembly) ReceiveConfig(ctx context.Context, remoteConfig []byte) error
|
||||
a.systemCli,
|
||||
a.adminCli,
|
||||
a.lockerCli,
|
||||
a.routerLb,
|
||||
a.usersAuthCache,
|
||||
)
|
||||
handler, err := locator.Handler(newCfg, a.locations)
|
||||
if err != nil {
|
||||
@@ -128,6 +142,7 @@ func (a *Assembly) Runners() []app.Runner {
|
||||
eventHandler.RequireModule("isp-system-service", a.systemCli)
|
||||
eventHandler.RequireModule("msp-admin-service", a.adminCli)
|
||||
eventHandler.RequireModule("isp-lock-service", a.lockerCli)
|
||||
eventHandler.RequireModule(routerModuleName, a.routerLb)
|
||||
|
||||
return []app.Runner{
|
||||
app.RunnerFunc(func(ctx context.Context) error {
|
||||
@@ -136,6 +151,10 @@ func (a *Assembly) Runners() []app.Runner {
|
||||
app.RunnerFunc(func(ctx context.Context) error {
|
||||
return a.boot.ClusterCli.Run(ctx, eventHandler)
|
||||
}),
|
||||
app.RunnerFunc(func(ctx context.Context) error {
|
||||
a.usersAuthCache.StartCleaner(ctx, usersAuthCachePurgeInterval)
|
||||
return nil
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+36
-2
@@ -2,11 +2,13 @@ package assembly
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/txix-open/isp-kit/metrics"
|
||||
"github.com/txix-open/isp-kit/metrics/http_metrics"
|
||||
|
||||
"isp-gate-service/cache"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/middleware"
|
||||
"isp-gate-service/proxy"
|
||||
@@ -15,7 +17,7 @@ import (
|
||||
"isp-gate-service/service"
|
||||
|
||||
mux2 "github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
"github.com/txix-open/isp-kit/lb"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
@@ -29,6 +31,8 @@ type Locator struct {
|
||||
systemCli *client.Client
|
||||
adminCli *client.Client
|
||||
lockerCli *client.Client
|
||||
routerLb *lb.RoundRobin
|
||||
usersAuthCache *cache.Cache
|
||||
}
|
||||
|
||||
func NewLocator(
|
||||
@@ -39,6 +43,8 @@ func NewLocator(
|
||||
systemCli *client.Client,
|
||||
adminCli *client.Client,
|
||||
lockerCli *client.Client,
|
||||
routerLb *lb.RoundRobin,
|
||||
usersAuthCache *cache.Cache,
|
||||
) Locator {
|
||||
return Locator{
|
||||
logger: logger,
|
||||
@@ -48,6 +54,8 @@ func NewLocator(
|
||||
systemCli: systemCli,
|
||||
adminCli: adminCli,
|
||||
lockerCli: lockerCli,
|
||||
routerLb: routerLb,
|
||||
usersAuthCache: usersAuthCache,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +66,17 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
authenticationCache := repository.NewAuthenticationCache(time.Duration(config.Caching.AuthenticationDataInSec) * time.Second)
|
||||
authentication := service.NewAuthentication(authenticationCache, systemRepo)
|
||||
|
||||
userAuthenticationCache := repository.NewUserAuthenticationCache(l.usersAuthCache)
|
||||
userAuthRepo := repository.NewUserAuth(l.routerLb)
|
||||
userAuthentication, err := service.NewUserAuthentication(
|
||||
config.CustomAuth,
|
||||
userAuthenticationCache,
|
||||
userAuthRepo,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "new user authentication")
|
||||
}
|
||||
|
||||
adminService := service.NewAdmin(
|
||||
repository.NewAuthorizationCache(time.Duration(config.Caching.AuthorizationDataInSec)*time.Second),
|
||||
adminRepo,
|
||||
@@ -72,6 +91,11 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
dailyLimitService := service.NewDailyLimit(lockRepo, config.DailyLimits)
|
||||
throttlingService := service.NewThrottling(lockRepo, config.Throttling)
|
||||
|
||||
skipBodyLoggingEndpointPrefixes := make([]string, 0, len(config.Logging.SkipBodyLoggingEndpointPrefixes))
|
||||
for _, prefix := range config.Logging.SkipBodyLoggingEndpointPrefixes {
|
||||
skipBodyLoggingEndpointPrefixes = append(skipBodyLoggingEndpointPrefixes, strings.TrimPrefix(prefix, "/"))
|
||||
}
|
||||
|
||||
mux := mux2.NewRouter()
|
||||
for _, location := range locations {
|
||||
var proxyFunc middleware.Handler
|
||||
@@ -83,6 +107,9 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
proxyFunc = proxy.NewGrpc(cli, location.SkipAuth, time.Duration(config.Http.ProxyTimeoutInSec)*time.Second)
|
||||
case conf.HttpProtocol:
|
||||
hostManager := l.httpHostManagerByModuleName[location.TargetModule]
|
||||
if location.TargetModule == routerModuleName {
|
||||
hostManager = l.routerLb
|
||||
}
|
||||
proxyFunc = proxy.NewHttp(hostManager, location.SkipAuth, time.Duration(config.Http.ProxyTimeoutInSec)*time.Second)
|
||||
case conf.WsProtocol:
|
||||
hostManager := l.httpHostManagerByModuleName[location.TargetModule]
|
||||
@@ -97,6 +124,11 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
forwardReqIdByAppId[setting.ApplicationId] = setting.ForwardRequestId
|
||||
}
|
||||
|
||||
enableUtf8JsonCharsetByApp := make(map[int]bool, len(config.ResponseContentTypeSettings))
|
||||
for _, setting := range config.ResponseContentTypeSettings {
|
||||
enableUtf8JsonCharsetByApp[setting.ApplicationId] = setting.AddJsonUtf8Charset
|
||||
}
|
||||
|
||||
metricsStorage := http_metrics.NewServerStorage(metrics.DefaultRegistry)
|
||||
|
||||
handler := middleware.Chain(
|
||||
@@ -109,9 +141,11 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
),
|
||||
middleware.RequestId(),
|
||||
middleware.ErrorHandler(l.logger),
|
||||
middleware.UserAuthenticate(userAuthentication, l.logger),
|
||||
middleware.Authenticate(authentication),
|
||||
middleware.AdminAuthenticate(adminService),
|
||||
middleware.ClientRequestId(config.EnableClientRequestIdForwarding, forwardReqIdByAppId),
|
||||
middleware.JsonResponseUtf8Charset(enableUtf8JsonCharsetByApp),
|
||||
middleware.Authorize(authorization, l.logger),
|
||||
middleware.AdminAuthorize(adminService),
|
||||
middleware.Throttling(throttlingService),
|
||||
@@ -126,7 +160,7 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
proxyFunc,
|
||||
middleware.Logger(l.logger, config.Logging.RequestLogEnable,
|
||||
enableBodyLog,
|
||||
config.Logging.SkipBodyLoggingEndpointPrefixes,
|
||||
skipBodyLoggingEndpointPrefixes,
|
||||
config.Logging.EnableForceUnescapingUnicode,
|
||||
),
|
||||
middleware.RequestId(),
|
||||
|
||||
Vendored
+29
@@ -1,6 +1,7 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
@@ -48,6 +49,34 @@ func (c *Cache) Set(key string, data []byte, lifeTime time.Duration) {
|
||||
}
|
||||
}
|
||||
|
||||
// StartCleaner runs periodic cleanup.
|
||||
// Blocking call: intended to be run in a separate goroutine.
|
||||
func (c *Cache) StartCleaner(ctx context.Context, interval time.Duration) {
|
||||
ticker := time.NewTicker(interval)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
c.cleanup()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cache) cleanup() {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
now := c.now()
|
||||
for k, v := range c.store {
|
||||
if now.After(v.expiredAt) {
|
||||
delete(c.store, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cache) now() time.Time {
|
||||
return time.Now()
|
||||
}
|
||||
+47
-1
@@ -9,6 +9,11 @@ import (
|
||||
"github.com/txix-open/jsonschema"
|
||||
)
|
||||
|
||||
const (
|
||||
HeaderTokenProviderType = "HEADER"
|
||||
CookieTokenProviderType = "COOKIE"
|
||||
)
|
||||
|
||||
func init() {
|
||||
schema.CustomGenerators.Register("logLevel", func(field reflect.StructField, t *jsonschema.Schema) {
|
||||
t.Type = "string"
|
||||
@@ -24,6 +29,8 @@ type Remote struct {
|
||||
Throttling []Throttling `schema:"Настройки пропускной способности"`
|
||||
EnableClientRequestIdForwarding bool `schema:"Включить проброс requestId из заголовка запроса"`
|
||||
ForwardReqIdClientSettings []ForwardReqIdClientSettings `schema:"Настройки проброcа requestId для приложений"`
|
||||
CustomAuth CustomAuth `schema:"Настройка кастомной аутентификации/авторизации"`
|
||||
ResponseContentTypeSettings []ResponseContentTypeSetting `schema:"Настройки Content-Type ответов"`
|
||||
}
|
||||
|
||||
type ForwardReqIdClientSettings struct {
|
||||
@@ -40,7 +47,7 @@ type Logging struct {
|
||||
LogLevel log.Level `schemaGen:"logLevel" schema:"Уровень логирования,логирование запросов осуществляется на уровне debug"`
|
||||
RequestLogEnable bool `schema:"Включить логирование запросов"`
|
||||
BodyLogEnable bool `schema:"Включить логирование тел запросов и ответов,должно быть включено логирование запросов"`
|
||||
SkipBodyLoggingEndpointPrefixes []string `schema:"регулярные выражения для отключения логирования"`
|
||||
SkipBodyLoggingEndpointPrefixes []string `schema:"Выключить логирование тел запросов и ответов для путей имеющих префикс из списка,'/' в начале игнорируется"`
|
||||
EnableForceUnescapingUnicode bool `schema:"Включить перевод тел запроса из unicode в utf-8, должно быть включено логирование тел запросов и ответов"`
|
||||
}
|
||||
|
||||
@@ -58,3 +65,42 @@ type Throttling struct {
|
||||
ApplicationId int `validate:"required" schema:"ID приложения"`
|
||||
RequestsPerSeconds int `validate:"required,min=1,max=1000" schema:"Запросов в секунду,не конфликтует с суточными ограничениями, алгоритм не работает на значениях больше 1000"`
|
||||
}
|
||||
|
||||
type CustomAuth struct {
|
||||
TokenProviders []TokenProvider `schema:"Настройки получения токена из запроса"`
|
||||
UserAuthSettings []UserAuthSetting `schema:"Настройка пользовательской аутентификации/авторизации"`
|
||||
}
|
||||
|
||||
type AuthProvider struct {
|
||||
Name string `schema:"Название настройки аутентификации/авторизации,должно быть уникальным" validate:"required"`
|
||||
ModuleName string `schema:"Название модуля,реализующего аутентификацию/авторизацию" validate:"required"`
|
||||
}
|
||||
|
||||
type TokenProvider struct {
|
||||
Name string `schema:"Название метода получения токена из запроса,должно быть уникальным" validate:"required"`
|
||||
Type string `schema:"Тип метода получения токена,один из: HEADER COOKIE" validate:"required,oneof=HEADER COOKIE"`
|
||||
HeaderProvider *HeaderTokenProvider `schema:"Настройки для получения токена из заголовка"`
|
||||
CookieProvider *CookieTokenProvider `schema:"Настройки для получения токена из cookie"`
|
||||
}
|
||||
|
||||
type HeaderTokenProvider struct {
|
||||
HeaderName string `schema:"Название заголовка,из которого берётся токен" validate:"required"`
|
||||
}
|
||||
|
||||
type CookieTokenProvider struct {
|
||||
CookieName string `schema:"Название cookie,из которого берётся токен" validate:"required"`
|
||||
Validate bool `schema:"Проверить валидность cookie"`
|
||||
}
|
||||
|
||||
type UserAuthSetting struct {
|
||||
ModuleNameList []string `schema:"Название модулей,для которых настраивается аутентификация/авторизация,название модулей должно быть уникальным" validate:"required"`
|
||||
TokenProviders []string `schema:"Список названий методов получения токена из запроса,используется первый провайдер, вернувший токен"`
|
||||
AuthenticateEndpoint string `schema:"Endpoint для аутентификации пользователя,вызывается через isp-router-service" validate:"required"`
|
||||
CacheDataInSec int `schema:"Время кеширования данных аутентификации/авторизации пользователя,отключен при значениях <=0,в секундах"`
|
||||
SkipAppAuth bool `schema:"Пропустить аутентификацию и авторизацию приложения"`
|
||||
}
|
||||
|
||||
type ResponseContentTypeSetting struct {
|
||||
ApplicationId int `validate:"required" schema:"ID приложения"`
|
||||
AddJsonUtf8Charset bool `schema:"Добавлять charset=utf-8 в Content-Type ответа: application/json для locations с protocol=http"`
|
||||
}
|
||||
+30
-1
@@ -1,9 +1,38 @@
|
||||
package domain
|
||||
|
||||
type AuthData struct {
|
||||
type AuthenticateAppResponse struct {
|
||||
Authenticated bool
|
||||
ErrorReason string
|
||||
AuthData *AppAuthData
|
||||
}
|
||||
|
||||
type AppAuthData struct {
|
||||
AppName string
|
||||
SystemId int
|
||||
DomainId int
|
||||
ServiceId int
|
||||
ApplicationId int
|
||||
}
|
||||
|
||||
type ApplicationToken struct {
|
||||
AppToken string
|
||||
AppName string
|
||||
}
|
||||
|
||||
type UserToken struct {
|
||||
Token string
|
||||
}
|
||||
|
||||
type AuthenticateUserResponse struct {
|
||||
Authenticated bool
|
||||
SkipUserAuth bool
|
||||
ErrorReason string
|
||||
AuthData *UserAuthData
|
||||
}
|
||||
|
||||
type UserAuthData struct {
|
||||
SkipAppAuth bool
|
||||
Identity string
|
||||
IdentityHeader string
|
||||
ExtraHeaders map[string][]string
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
+10
-2
@@ -1,14 +1,22 @@
|
||||
package domain
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type EndpointMeta struct {
|
||||
Inner bool
|
||||
Inner bool
|
||||
UserAuthRequired bool
|
||||
|
||||
ModuleName string
|
||||
RequiredAdminPermission string
|
||||
// Объявляемый сервисом метод
|
||||
PathSchema string
|
||||
// Вызываемый метод
|
||||
Endpoint string
|
||||
// Нормализованный путь, для известных путей берётся объявляемый метод, для неизвестных - вызываемый
|
||||
// Удаляет '/' из начала пути
|
||||
NormalizedEndpoint string
|
||||
}
|
||||
|
||||
type endpointMetaKey struct{}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package domain
|
||||
|
||||
import "github.com/txix-open/isp-kit/errors"
|
||||
|
||||
var (
|
||||
ErrUserAuthSettingNotFound = errors.New("user auth setting not found")
|
||||
ErrEmptyUserToken = errors.New("failed to extract user token")
|
||||
ErrInvalidUserToken = errors.New("invalid user token")
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
package entity
|
||||
|
||||
type AdminAuthenticateResponse struct {
|
||||
Authenticated bool
|
||||
ErrorReason string
|
||||
AdminId int
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package entity
|
||||
|
||||
type AppAuthData struct {
|
||||
AppName string
|
||||
SystemId int
|
||||
DomainId int
|
||||
ServiceId int
|
||||
ApplicationId int
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package domain
|
||||
package entity
|
||||
|
||||
type AuthenticateRequest struct {
|
||||
Token string
|
||||
@@ -7,7 +7,7 @@ type AuthenticateRequest struct {
|
||||
type AuthenticateResponse struct {
|
||||
Authenticated bool
|
||||
ErrorReason string
|
||||
AuthData *AuthData
|
||||
AuthData *AppAuthData
|
||||
}
|
||||
|
||||
type AuthorizeRequest struct {
|
||||
@@ -0,0 +1,17 @@
|
||||
package entity
|
||||
|
||||
type UserAuthenticateRequest struct {
|
||||
Token string
|
||||
}
|
||||
|
||||
type UserAuthenticateResponse struct {
|
||||
Authenticated bool
|
||||
ErrorReason string
|
||||
AuthData *UserAuthData
|
||||
}
|
||||
|
||||
type UserAuthData struct {
|
||||
Identity string
|
||||
IdentityHeader string
|
||||
ExtraHeaders map[string][]string
|
||||
}
|
||||
@@ -1,57 +1,58 @@
|
||||
module isp-gate-service
|
||||
|
||||
go 1.26
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/mux v1.8.1
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/redis/go-redis/v9 v9.11.0
|
||||
github.com/redis/go-redis/v9 v9.18.0
|
||||
github.com/stretchr/testify v1.11.1
|
||||
github.com/tomakado/websocketproxy v0.1.0
|
||||
github.com/txix-open/isp-kit v1.65.1
|
||||
github.com/txix-open/isp-kit v1.74.0
|
||||
github.com/txix-open/jsonschema v1.3.0
|
||||
golang.org/x/net v0.52.0
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260311181403-84a4fc48630c
|
||||
google.golang.org/grpc v1.79.2
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260729162451-8efbd57d26e0
|
||||
google.golang.org/grpc v1.83.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||
github.com/txix-open/etp/v4 v4.0.1 // indirect
|
||||
github.com/go-faker/faker/v4 v4.10.1 // indirect
|
||||
github.com/klauspost/compress v1.19.1 // indirect
|
||||
github.com/txix-open/etp/v4 v4.1.3 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.4 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
golang.org/x/net v0.57.0 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/buger/jsonparser v1.6.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/coder/websocket v1.8.14 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/coder/websocket v1.8.15 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
|
||||
github.com/getsentry/sentry-go v0.43.0 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.15 // indirect
|
||||
github.com/getsentry/sentry-go v0.48.0 // indirect
|
||||
github.com/go-logr/logr v1.4.4 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/julienschmidt/httprouter v1.3.0
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mailru/easyjson v0.9.1 // indirect
|
||||
github.com/leodido/go-urn v1.5.0 // indirect
|
||||
github.com/mailru/easyjson v0.9.2 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_golang v1.23.2 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/prometheus/client_golang v1.24.1 // indirect
|
||||
github.com/prometheus/client_model v0.6.2 // indirect
|
||||
github.com/prometheus/common v0.67.5 // indirect
|
||||
github.com/prometheus/procfs v0.20.1 // indirect
|
||||
github.com/prometheus/common v0.70.1 // indirect
|
||||
github.com/prometheus/procfs v0.21.1 // indirect
|
||||
github.com/txix-open/bellows v1.2.0 // indirect
|
||||
github.com/txix-open/etp/v3 v3.2.0
|
||||
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb // indirect
|
||||
@@ -59,20 +60,20 @@ require (
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.67.0 // indirect
|
||||
go.opentelemetry.io/otel v1.42.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.42.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.42.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.42.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.42.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.42.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.69.0 // indirect
|
||||
go.opentelemetry.io/otel v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.44.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.11.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.1 // indirect
|
||||
golang.org/x/crypto v0.49.0 // indirect
|
||||
golang.org/x/sys v0.42.0 // indirect
|
||||
golang.org/x/text v0.35.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260311181403-84a4fc48630c // indirect
|
||||
go.uber.org/zap v1.28.0 // indirect
|
||||
golang.org/x/crypto v0.54.0 // indirect
|
||||
golang.org/x/sys v0.47.0 // indirect
|
||||
golang.org/x/text v0.40.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260729162451-8efbd57d26e0 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
||||
@@ -8,32 +8,33 @@ github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
||||
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||
github.com/buger/jsonparser v1.6.0 h1:IHTgLjkgckOjAp8p0aYfXkv+cqC+zrzALg/JywnPjxY=
|
||||
github.com/buger/jsonparser v1.6.0/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
|
||||
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g=
|
||||
github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
|
||||
github.com/coder/websocket v1.8.15 h1:6B2JPeOGlpff2Uz6vOEH1Vzpi0iUz20A+lPVhPHtNUA=
|
||||
github.com/coder/websocket v1.8.15/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||
github.com/getsentry/sentry-go v0.43.0 h1:XbXLpFicpo8HmBDaInk7dum18G9KSLcjZiyUKS+hLW4=
|
||||
github.com/getsentry/sentry-go v0.43.0/go.mod h1:XDotiNZbgf5U8bPDUAfvcFmOnMQQceESxyKaObSssW0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.15 h1:05iP/CYtZ/w455R/KZM6rZ5ieAdh99UPtd+d3YzLmaI=
|
||||
github.com/gabriel-vasile/mimetype v1.4.15/go.mod h1:azpTcoLcDZRNgFou5j+APrqQx9HqVPWa6ijYQIIVswQ=
|
||||
github.com/getsentry/sentry-go v0.48.0 h1:FRZNr7Uk1C86ev1bSJmYlUkL9oyivQA6YOcdYfaaMmY=
|
||||
github.com/getsentry/sentry-go v0.48.0/go.mod h1:E5UkA5wp1qR2+MDydNYlVeUiNN2xEdjYMidkgf0Qoss=
|
||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
||||
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
||||
github.com/go-faker/faker/v4 v4.7.0 h1:VboC02cXHl/NuQh5lM2W8b87yp4iFXIu59x4w0RZi4E=
|
||||
github.com/go-faker/faker/v4 v4.7.0/go.mod h1:u1dIRP5neLB6kTzgyVjdBOV5R1uP7BdxkcWk7tiKQXk=
|
||||
github.com/go-faker/faker/v4 v4.10.1 h1:mGH3y0X8AfrXsfgPsPuTkWBYIebomvdkWEN1uDLoFFg=
|
||||
github.com/go-faker/faker/v4 v4.10.1/go.mod h1:VFIEwWDd16EdYDLF6NJ5gAAzEp7vz5LgKgJ2iZ17Tdg=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
|
||||
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
@@ -55,24 +56,26 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 h1:HWRh5R2+9EifMyIHV7ZV+MIZqgz+PMpZ14Jynv3O2Zs=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0/go.mod h1:JfhWUomR1baixubs02l85lZYYOm7LV6om4ceouMv45c=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 h1:5VipnvEpbqr2gA2VbM+nYVbkIF28c5ZQfqCBQ5g2xfk=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0/go.mod h1:Hyl3n6Twe1hvtd9XUXDec4pTvgMSEixRuQKPTMH2bNs=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/klauspost/compress v1.18.4 h1:RPhnKRAQ4Fh8zU2FY/6ZFDwTVTxgJ/EMydqSTzE9a2c=
|
||||
github.com/klauspost/compress v1.18.4/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
|
||||
github.com/klauspost/compress v1.19.1 h1:VsB4HPswih7mmZ8WleSFQ75c/Ui1M4trX5oAsJnhSlk=
|
||||
github.com/klauspost/compress v1.19.1/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mailru/easyjson v0.9.1 h1:LbtsOm5WAswyWbvTEOqhypdPeZzHavpZx96/n553mR8=
|
||||
github.com/mailru/easyjson v0.9.1/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
|
||||
github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0=
|
||||
github.com/leodido/go-urn v1.5.0/go.mod h1:9BORnCDhdPBJNDEX+w1bJisa8yOKYi116VeO96s4ifE=
|
||||
github.com/mailru/easyjson v0.9.2 h1:dX8U45hQsZpxd80nLvDGihsQ/OxlvTkVUXH2r/8cb2M=
|
||||
github.com/mailru/easyjson v0.9.2/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
@@ -86,20 +89,21 @@ github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4
|
||||
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
|
||||
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.24.1 h1:JnJkREXzWxUdCuPFpIWZiPispT9xVV59uiuyR2bPlnU=
|
||||
github.com/prometheus/client_golang v1.24.1/go.mod h1:F+oSRECHg4sse5ucfYpYDeIv/hu68Zo0uoHKetWnzcE=
|
||||
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
||||
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
||||
github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4=
|
||||
github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw=
|
||||
github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc=
|
||||
github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo=
|
||||
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
|
||||
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
||||
github.com/redis/go-redis/v9 v9.11.0 h1:E3S08Gl/nJNn5vkxd2i78wZxWAPNZgUNTp8WIJUAiIs=
|
||||
github.com/redis/go-redis/v9 v9.11.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
|
||||
github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi/PY=
|
||||
github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc=
|
||||
github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI=
|
||||
github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY=
|
||||
github.com/rabbitmq/amqp091-go v1.13.0 h1:L8NA1WtF76C6KA3LAoufjfLgbist/If1UQYcsOjtxXA=
|
||||
github.com/rabbitmq/amqp091-go v1.13.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
||||
github.com/redis/go-redis/v9 v9.18.0 h1:pMkxYPkEbMPwRdenAzUNyFNrDgHx9U+DrBabWNfSRQs=
|
||||
github.com/redis/go-redis/v9 v9.18.0/go.mod h1:k3ufPphLU5YXwNTUcCRXGxUoF1fqxnhFQmscfkCoDA0=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
@@ -119,12 +123,12 @@ github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgj
|
||||
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
|
||||
github.com/txix-open/etp/v3 v3.2.0 h1:EgTchT8VtCYV1iEo/y4jII3/NybrXiQDE0y6pmS350M=
|
||||
github.com/txix-open/etp/v3 v3.2.0/go.mod h1:lgen0TJmiturgBhvlxH1/PQ7iLL/OebKbxPAQYkuKI0=
|
||||
github.com/txix-open/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIgA=
|
||||
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
|
||||
github.com/txix-open/grmq v1.10.0 h1:1bXuF+7TxtUvoh+Wn6SOCYpVACFbWDuDmz/+tKwW9Ms=
|
||||
github.com/txix-open/grmq v1.10.0/go.mod h1:EyFOP17KrwEFOUjR+PH8iH3LCtiN9TSQ8t0ysyk62po=
|
||||
github.com/txix-open/isp-kit v1.65.1 h1:KehXIJdPZMnewDd5XQxk87yNAtNhvJXApaLFvbUau5U=
|
||||
github.com/txix-open/isp-kit v1.65.1/go.mod h1:F4B/+ErbNVaWzIIGasXM5DtcDKtjl6u2OESO02RyzCI=
|
||||
github.com/txix-open/etp/v4 v4.1.3 h1:u9ZyU2yKGgoQ1/DSaElhazWm8xASdqGEdWjoJ2xQlfo=
|
||||
github.com/txix-open/etp/v4 v4.1.3/go.mod h1:9GK+Aje8BmLFq8Hk4j6Qb976LdU9WECCWAuLK1vAKgM=
|
||||
github.com/txix-open/grmq v1.12.0 h1:lSPYvwLfTL0+b0xDQmuuN6RaKS3NCEJNK9ccWpOWa8Y=
|
||||
github.com/txix-open/grmq v1.12.0/go.mod h1:6m9CCTQao/HAFalu5rFOZGJ5KLEP6WzzIwj80Ml3KGE=
|
||||
github.com/txix-open/isp-kit v1.74.0 h1:Gi1X8Jnf9ppV4TXq4kMCBgBjJjqSKh57X8038I+tQFw=
|
||||
github.com/txix-open/isp-kit v1.74.0/go.mod h1:Kob233jk1j/Js7UmopJ5b7JpVZrpWbagEAjasgfqTdk=
|
||||
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
|
||||
github.com/txix-open/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
||||
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
|
||||
@@ -138,54 +142,60 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
||||
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
|
||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
||||
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
|
||||
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.67.0 h1:c9r/G1CSw4dPI1jaNNG9RnQP+q4SvZnHciDQJVIvchU=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.67.0/go.mod h1:gO9smoZe9KnZcJCqcB0lMmQ4Z5VEifYmjMTpnwtTSuQ=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.67.0 h1:OyrsyzuttWTSur2qN/Lm0m2a8yqyIjUVBZcxFPuXq2o=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.67.0/go.mod h1:C2NGBr+kAB4bk3xtMXfZ94gqFDtg/GkI7e9zqGh5Beg=
|
||||
go.opentelemetry.io/otel v1.42.0 h1:lSQGzTgVR3+sgJDAU/7/ZMjN9Z+vUip7leaqBKy4sho=
|
||||
go.opentelemetry.io/otel v1.42.0/go.mod h1:lJNsdRMxCUIWuMlVJWzecSMuNjE7dOYyWlqOXWkdqCc=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.42.0 h1:THuZiwpQZuHPul65w4WcwEnkX2QIuMT+UFoOrygtoJw=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.42.0/go.mod h1:J2pvYM5NGHofZ2/Ru6zw/TNWnEQp5crgyDeSrYpXkAw=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.42.0 h1:uLXP+3mghfMf7XmV4PkGfFhFKuNWoCvvx5wP/wOXo0o=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.42.0/go.mod h1:v0Tj04armyT59mnURNUJf7RCKcKzq+lgJs6QSjHjaTc=
|
||||
go.opentelemetry.io/otel/metric v1.42.0 h1:2jXG+3oZLNXEPfNmnpxKDeZsFI5o4J+nz6xUlaFdF/4=
|
||||
go.opentelemetry.io/otel/metric v1.42.0/go.mod h1:RlUN/7vTU7Ao/diDkEpQpnz3/92J9ko05BIwxYa2SSI=
|
||||
go.opentelemetry.io/otel/sdk v1.42.0 h1:LyC8+jqk6UJwdrI/8VydAq/hvkFKNHZVIWuslJXYsDo=
|
||||
go.opentelemetry.io/otel/sdk v1.42.0/go.mod h1:rGHCAxd9DAph0joO4W6OPwxjNTYWghRWmkHuGbayMts=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.42.0 h1:D/1QR46Clz6ajyZ3G8SgNlTJKBdGp84q9RKCAZ3YGuA=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.42.0/go.mod h1:Ua6AAlDKdZ7tdvaQKfSmnFTdHx37+J4ba8MwVCYM5hc=
|
||||
go.opentelemetry.io/otel/trace v1.42.0 h1:OUCgIPt+mzOnaUTpOQcBiM/PLQ/Op7oq6g4LenLmOYY=
|
||||
go.opentelemetry.io/otel/trace v1.42.0/go.mod h1:f3K9S+IFqnumBkKhRJMeaZeNk9epyhnCmQh/EysQCdc=
|
||||
go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g=
|
||||
go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.69.0 h1:MCcYL7J6Vt/X0kjqbMZkekCmwsurbQRbL69vkiye2lk=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.69.0/go.mod h1:3jnStNwSufK+f5ktjL4EPcwtig4rtd81NS70lqHuXl8=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 h1:8tvICD4vSTOOsNrsI4Ljf6C+6UKvpTEH5XY3JMoyPoo=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0/go.mod h1:z9+yiacE0IHRqM4qFfkbt/JYlmYXgss8GY/jXoNuPJI=
|
||||
go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU=
|
||||
go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0 h1:4YsVu3B8+3qtWYYrsUYgn0OG78pN0rnNPRGX4SbokQI=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0/go.mod h1:+wnlSn0mD1ADVMe3v9Z/WIaiz6q6gL2J/ejaAmdmv80=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.44.0 h1:lgh3PiVrRUWMLOVSkQicxzZll5NjF1r+AtsX1XRIHw0=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.44.0/go.mod h1:5Cnhth3m/AgOeTgE3ex12pPmiu/gGtZit03kSzx9X7s=
|
||||
go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc=
|
||||
go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo=
|
||||
go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58=
|
||||
go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA=
|
||||
go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk=
|
||||
go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE=
|
||||
go.opentelemetry.io/proto/otlp v1.11.0 h1:5rrYs0Ykyj50sdU/JU0x8etU+LubXWb+gED6TbEdMIk=
|
||||
go.opentelemetry.io/proto/otlp v1.11.0/go.mod h1:SmVizdCOAm3XBtG1g1NnOdhW6jtddT72hLMhv8VwA8E=
|
||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc=
|
||||
go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo=
|
||||
go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q=
|
||||
go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ=
|
||||
go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
|
||||
golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
|
||||
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
|
||||
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
|
||||
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
|
||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
|
||||
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
|
||||
golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
|
||||
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
||||
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260311181403-84a4fc48630c h1:OyQPd6I3pN/9gDxz6L13kYGJgqkpdrAohJRBeXyxlgI=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260311181403-84a4fc48630c/go.mod h1:X2gu9Qwng7Nn009s/r3RUxqkzQNqOrAy79bluY7ojIg=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260311181403-84a4fc48630c h1:xgCzyF2LFIO/0X2UAoVRiXKU5Xg6VjToG4i2/ecSswk=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260311181403-84a4fc48630c/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||
google.golang.org/grpc v1.79.2 h1:fRMD94s2tITpyJGtBBn7MkMseNpOZU8ZxgC3MMBaXRU=
|
||||
google.golang.org/grpc v1.79.2/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ=
|
||||
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw=
|
||||
golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk=
|
||||
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
|
||||
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
|
||||
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
||||
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
|
||||
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
|
||||
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260729162451-8efbd57d26e0 h1:ybvH/ZpOcpCrjtkb7oW/fdlzbEmRVeumw19SRQmNFKU=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260729162451-8efbd57d26e0/go.mod h1:HJ9MpJLeDSstBkx1LILTpd5f41ADSMZcTPypw02qEGw=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260729162451-8efbd57d26e0 h1:mJiOtnGp0k/BcSgdu03G2NwnscCfCH+h2QKUBZr18KI=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260729162451-8efbd57d26e0/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||
google.golang.org/grpc v1.83.0 h1:JeNZEKJFbQxArAMl+hiytHauacDNqJUllNfmIMmpqnQ=
|
||||
google.golang.org/grpc v1.83.0/go.mod h1:kDyl6SKsiHKt0uylY5gtn5cEjkrIOhQOGDgIc4JGwzQ=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -16,12 +16,16 @@ const (
|
||||
)
|
||||
|
||||
type Authenticator interface {
|
||||
Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error)
|
||||
Authenticate(ctx context.Context, token string) (*domain.AuthenticateAppResponse, error)
|
||||
}
|
||||
|
||||
func Authenticate(authenticator Authenticator) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
if ctx.SkipAppAuth() {
|
||||
return next.Handle(ctx)
|
||||
}
|
||||
|
||||
token, appName, err := extractToken(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -55,7 +59,7 @@ func Authenticate(authenticator Authenticator) Middleware {
|
||||
)
|
||||
}
|
||||
|
||||
ctx.Authenticate(request.AuthData(*resp.AuthData))
|
||||
ctx.Authenticate(*resp.AuthData)
|
||||
return next.Handle(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
)
|
||||
|
||||
type Authorizer interface {
|
||||
@@ -17,6 +18,10 @@ type Authorizer interface {
|
||||
func Authorize(authorizer Authorizer, logger log.Logger) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
if ctx.SkipAppAuth() {
|
||||
return next.Handle(ctx)
|
||||
}
|
||||
|
||||
authData, err := ctx.GetAuthData()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "authorize: get auth data")
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
@@ -16,6 +16,10 @@ type DailyLimitChecker interface {
|
||||
func DailyLimit(checker DailyLimitChecker) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
if ctx.SkipAppAuth() {
|
||||
return next.Handle(ctx)
|
||||
}
|
||||
|
||||
authData, err := ctx.GetAuthData()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "daily limit: get auth data")
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"isp-gate-service/request"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
func JsonResponseUtf8Charset(applicationIds map[int]bool) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
authData, _ := ctx.GetAuthData()
|
||||
ctx.EnableHttpJsonUtf8Charset(applicationIds[authData.ApplicationId])
|
||||
return next.Handle(ctx)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"isp-gate-service/helpers"
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/http/endpoint/buffer"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
)
|
||||
@@ -65,10 +65,11 @@ func Logger( // nolint:gocognit,funlen
|
||||
|
||||
r := ctx.Request()
|
||||
|
||||
endpoint := ctx.EndpointMeta().NormalizedEndpoint
|
||||
logBodyFromCurrenRequest := enableBodyLogging
|
||||
if logBodyFromCurrenRequest {
|
||||
for _, prefix := range skipBodyLoggingEndpointPrefixes {
|
||||
if strings.HasPrefix(ctx.EndpointMeta().Endpoint, prefix) {
|
||||
if strings.HasPrefix(endpoint, prefix) {
|
||||
logBodyFromCurrenRequest = false
|
||||
break
|
||||
}
|
||||
@@ -110,7 +111,7 @@ func Logger( // nolint:gocognit,funlen
|
||||
log.String("xForwardedFor", r.Header.Get("X-Forwarded-For")),
|
||||
log.Int("statusCode", scSrc.StatusCode()),
|
||||
log.String("path", originalPath),
|
||||
log.String("endpoint", ctx.EndpointMeta().Endpoint),
|
||||
log.String("endpoint", endpoint),
|
||||
log.Int("applicationId", authData.ApplicationId),
|
||||
log.String("applicationName", authData.AppName),
|
||||
log.Int("adminId", ctx.AdminId()),
|
||||
|
||||
@@ -9,17 +9,13 @@ import (
|
||||
"github.com/txix-open/isp-kit/requestid"
|
||||
)
|
||||
|
||||
const (
|
||||
requestIdHeader = "x-request-id"
|
||||
)
|
||||
|
||||
func RequestId() Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
requestId := requestid.Next()
|
||||
|
||||
context := requestid.ToContext(ctx.Context(), requestId)
|
||||
context = log.ToContext(context, log.String("requestId", requestId))
|
||||
context = log.ToContext(context, log.String(requestid.LogKey, requestId))
|
||||
|
||||
ctx.SetContext(context)
|
||||
return next.Handle(ctx)
|
||||
@@ -31,25 +27,21 @@ func ClientRequestId(forwardClientRequestId bool, forwardReqIdByApp map[int]bool
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
requestId := requestid.FromContext(ctx.Context())
|
||||
if requestId == "" {
|
||||
requestId = requestid.Next()
|
||||
}
|
||||
clientRequestId := strings.TrimSpace(ctx.Request().Header.Get(requestid.Header))
|
||||
|
||||
clientRequestId := strings.TrimSpace(ctx.Request().Header.Get(requestIdHeader))
|
||||
|
||||
logFields := make([]log.Field, 0)
|
||||
clientLogFields := make([]log.Field, 0, 1)
|
||||
if clientRequestId != "" {
|
||||
logFields = append(logFields, log.String("clientRequestId", clientRequestId))
|
||||
|
||||
authData, _ := ctx.GetAuthData()
|
||||
if forwardClientRequestId || forwardReqIdByApp[authData.ApplicationId] {
|
||||
requestId = clientRequestId
|
||||
}
|
||||
|
||||
clientLogFields = append(clientLogFields, log.String("clientRequestId", clientRequestId))
|
||||
}
|
||||
logFields = append(logFields, log.String("requestId", requestId))
|
||||
|
||||
context := requestid.ToContext(ctx.Context(), requestId)
|
||||
context = log.ToContext(context, logFields...)
|
||||
context = log.RewriteContextField(context, log.String(requestid.LogKey, requestId))
|
||||
context = log.ToContext(context, clientLogFields...)
|
||||
|
||||
ctx.SetContext(context)
|
||||
return next.Handle(ctx)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
@@ -18,6 +18,10 @@ type Throttler interface {
|
||||
func Throttling(throttler Throttler) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
if ctx.SkipAppAuth() {
|
||||
return next.Handle(ctx)
|
||||
}
|
||||
|
||||
authData, err := ctx.GetAuthData()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "throttling: get auth data")
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
)
|
||||
|
||||
type UserAuthenticator interface {
|
||||
Authenticate(ctx *request.Context) (*domain.AuthenticateUserResponse, error)
|
||||
}
|
||||
|
||||
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)
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrEmptyUserToken):
|
||||
return httperrors.New(
|
||||
http.StatusUnauthorized,
|
||||
"user token required",
|
||||
errors.New("customAuth: authenticate user: user token required"),
|
||||
)
|
||||
case errors.Is(err, domain.ErrInvalidUserToken):
|
||||
return httperrors.New(
|
||||
http.StatusUnauthorized,
|
||||
"invalid user token",
|
||||
errors.WithMessage(err, "customAuth: authenticate user: invalid user token"),
|
||||
)
|
||||
case err != nil:
|
||||
return errors.WithMessage(err, "customAuth: authenticate user: authenticator error")
|
||||
}
|
||||
|
||||
if resp.SkipUserAuth {
|
||||
return next.Handle(ctx)
|
||||
}
|
||||
if !resp.Authenticated {
|
||||
return httperrors.New(
|
||||
http.StatusUnauthorized,
|
||||
"invalid user token",
|
||||
errors.Errorf("customAuth: authenticate user: authenticate: %s", resp.ErrorReason),
|
||||
)
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
}
|
||||
}
|
||||
+43
-21
@@ -5,14 +5,16 @@ import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"io"
|
||||
"maps"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/grpc"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
"github.com/txix-open/isp-kit/grpc/isp"
|
||||
@@ -70,26 +72,7 @@ func (p Grpc) Handle(ctx *request.Context) error {
|
||||
}
|
||||
|
||||
requestId := requestid.FromContext(ctx.Context())
|
||||
md := metadata.MD{
|
||||
grpc.ProxyMethodNameHeader: {ctx.EndpointMeta().Endpoint},
|
||||
requestid.Header: {requestId},
|
||||
}
|
||||
|
||||
if !p.skipAuth {
|
||||
authData, err := ctx.GetAuthData()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "get auth data")
|
||||
}
|
||||
md[grpc.SystemIdHeader] = []string{strconv.Itoa(authData.SystemId)}
|
||||
md[grpc.DomainIdHeader] = []string{strconv.Itoa(authData.DomainId)}
|
||||
md[grpc.ServiceIdHeader] = []string{strconv.Itoa(authData.ServiceId)}
|
||||
md[grpc.ApplicationIdHeader] = []string{strconv.Itoa(authData.ApplicationId)}
|
||||
encodedAppName := base64.StdEncoding.EncodeToString([]byte(authData.AppName))
|
||||
md[grpc.ApplicationNameHeader] = []string{encodedAppName}
|
||||
if ctx.IsAdminAuthenticated() {
|
||||
md[xAdminIdHeader] = []string{strconv.Itoa(ctx.AdminId())}
|
||||
}
|
||||
}
|
||||
md := p.writeMetadata(ctx)
|
||||
requestContext := metadata.NewOutgoingContext(ctx.Context(), md)
|
||||
|
||||
requestContext, cancel := context.WithTimeout(requestContext, p.timeout)
|
||||
@@ -167,3 +150,42 @@ func (p Grpc) codeToHttpStatus(code codes.Code) int {
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func (p Grpc) writeMetadata(ctx *request.Context) metadata.MD {
|
||||
requestId := requestid.FromContext(ctx.Context())
|
||||
md := metadata.MD{
|
||||
grpc.ProxyMethodNameHeader: {ctx.EndpointMeta().Endpoint},
|
||||
requestid.Header: {requestId},
|
||||
}
|
||||
|
||||
if p.skipAuth {
|
||||
return md
|
||||
}
|
||||
|
||||
appAuthData, err := ctx.GetAuthData()
|
||||
if err == nil {
|
||||
md[grpc.SystemIdHeader] = []string{strconv.Itoa(appAuthData.SystemId)}
|
||||
md[grpc.DomainIdHeader] = []string{strconv.Itoa(appAuthData.DomainId)}
|
||||
md[grpc.ServiceIdHeader] = []string{strconv.Itoa(appAuthData.ServiceId)}
|
||||
md[grpc.ApplicationIdHeader] = []string{strconv.Itoa(appAuthData.ApplicationId)}
|
||||
encodedAppName := base64.StdEncoding.EncodeToString([]byte(appAuthData.AppName))
|
||||
md[grpc.ApplicationNameHeader] = []string{encodedAppName}
|
||||
}
|
||||
|
||||
userAuthData, err := ctx.GetUserAuthData()
|
||||
if err == nil {
|
||||
proxyHeaders := maps.Clone(userAuthData.ExtraHeaders)
|
||||
proxyHeaders[userAuthData.IdentityHeader] = []string{userAuthData.Identity}
|
||||
for header, values := range proxyHeaders {
|
||||
header = strings.ToLower(header)
|
||||
if strings.HasPrefix(header, "x-") {
|
||||
md.Set(header, values...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ctx.IsAdminAuthenticated() {
|
||||
md[xAdminIdHeader] = []string{strconv.Itoa(ctx.AdminId())}
|
||||
}
|
||||
return md
|
||||
}
|
||||
+44
-22
@@ -1,6 +1,7 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"net"
|
||||
@@ -8,15 +9,15 @@ import (
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/grpc"
|
||||
"github.com/txix-open/isp-kit/requestid"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -67,10 +68,8 @@ func (p Http) Handle(ctx *request.Context) error {
|
||||
|
||||
request := ctx.Request()
|
||||
request.URL.Path = ctx.EndpointMeta().Endpoint
|
||||
err = setHttpHeaders(ctx, request.Header, p.skipAuth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
setHttpHeaders(ctx, request.Header, p.skipAuth)
|
||||
|
||||
reverseProxy := httputil.NewSingleHostReverseProxy(target)
|
||||
reverseProxy.Transport = httpTransport
|
||||
var resultError error
|
||||
@@ -81,6 +80,9 @@ func (p Http) Handle(ctx *request.Context) error {
|
||||
errors.WithMessagef(err, "http proxy to %s", host),
|
||||
)
|
||||
}
|
||||
if ctx.IsJsonUtf8CharsetEnabled() {
|
||||
reverseProxy.ModifyResponse = addJsonUtf8Charset
|
||||
}
|
||||
|
||||
context, cancel := context.WithTimeout(request.Context(), p.timeout)
|
||||
defer cancel()
|
||||
@@ -90,28 +92,48 @@ func (p Http) Handle(ctx *request.Context) error {
|
||||
return resultError
|
||||
}
|
||||
|
||||
func setHttpHeaders(ctx *request.Context, header http.Header, skipAuth bool) error {
|
||||
func setHttpHeaders(ctx *request.Context, header http.Header, skipAuth bool) {
|
||||
header.Set(requestid.Header, requestid.FromContext(ctx.Context()))
|
||||
if !skipAuth {
|
||||
authData, err := ctx.GetAuthData()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "http: get auth data")
|
||||
if skipAuth {
|
||||
return
|
||||
}
|
||||
|
||||
userAuthData, err := ctx.GetUserAuthData()
|
||||
if err == nil {
|
||||
for key, values := range userAuthData.ExtraHeaders {
|
||||
for _, value := range values {
|
||||
header.Add(key, value)
|
||||
}
|
||||
}
|
||||
header.Set(grpc.SystemIdHeader, strconv.Itoa(authData.SystemId))
|
||||
header.Set(grpc.DomainIdHeader, strconv.Itoa(authData.DomainId))
|
||||
header.Set(grpc.ServiceIdHeader, strconv.Itoa(authData.ServiceId))
|
||||
header.Set(grpc.ApplicationIdHeader, strconv.Itoa(authData.ApplicationId))
|
||||
encodedAppName := base64.StdEncoding.EncodeToString([]byte(authData.AppName))
|
||||
header.Set(userAuthData.IdentityHeader, userAuthData.Identity)
|
||||
}
|
||||
|
||||
appAuthData, err := ctx.GetAuthData()
|
||||
if err == nil {
|
||||
header.Set(grpc.SystemIdHeader, strconv.Itoa(appAuthData.SystemId))
|
||||
header.Set(grpc.DomainIdHeader, strconv.Itoa(appAuthData.DomainId))
|
||||
header.Set(grpc.ServiceIdHeader, strconv.Itoa(appAuthData.ServiceId))
|
||||
header.Set(grpc.ApplicationIdHeader, strconv.Itoa(appAuthData.ApplicationId))
|
||||
encodedAppName := base64.StdEncoding.EncodeToString([]byte(appAuthData.AppName))
|
||||
header.Set(grpc.ApplicationNameHeader, encodedAppName) //nolint:canonicalheader
|
||||
if ctx.IsAdminAuthenticated() {
|
||||
header.Set(xAdminIdHeader, strconv.Itoa(ctx.AdminId())) //nolint:canonicalheader
|
||||
} else {
|
||||
header.Del(xAdminIdHeader) //nolint:canonicalheader
|
||||
}
|
||||
}
|
||||
|
||||
if ctx.IsAdminAuthenticated() {
|
||||
header.Set(xAdminIdHeader, strconv.Itoa(ctx.AdminId())) //nolint:canonicalheader
|
||||
} else {
|
||||
header.Del(xAdminIdHeader) //nolint:canonicalheader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func defaultTransportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) {
|
||||
return dialer.DialContext
|
||||
}
|
||||
|
||||
func addJsonUtf8Charset(response *http.Response) error {
|
||||
contentType := response.Header.Get("Content-Type")
|
||||
if strings.EqualFold(contentType, "application/json") {
|
||||
response.Header.Set("Content-Type", "application/json; charset=utf-8")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
+2
-2
@@ -7,8 +7,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tomakado/websocketproxy"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
@@ -43,7 +43,7 @@ func (ws Ws) Handle(ctx *request.Context) error {
|
||||
var resultError error
|
||||
proxy := websocketproxy.NewProxy(target)
|
||||
proxy.Director = func(incoming *http.Request, out http.Header) {
|
||||
_ = setHttpHeaders(ctx, out, ws.skipAuth)
|
||||
setHttpHeaders(ctx, out, ws.skipAuth)
|
||||
}
|
||||
proxy.Upgrader = &websocket.Upgrader{
|
||||
HandshakeTimeout: 5 * time.Second,
|
||||
|
||||
+7
-7
@@ -4,9 +4,9 @@ package repository
|
||||
import (
|
||||
"context"
|
||||
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/entity"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
)
|
||||
|
||||
@@ -23,10 +23,10 @@ func NewAdmin(cli *client.Client) Admin {
|
||||
return Admin{cli: cli}
|
||||
}
|
||||
|
||||
func (r Admin) Authenticate(ctx context.Context, token string) (*domain.AdminAuthenticateResponse, error) {
|
||||
resp := domain.AdminAuthenticateResponse{}
|
||||
func (r Admin) Authenticate(ctx context.Context, token string) (*entity.AdminAuthenticateResponse, error) {
|
||||
resp := entity.AdminAuthenticateResponse{}
|
||||
err := r.cli.Invoke(adminAuthenticate).
|
||||
JsonRequestBody(domain.AuthenticateRequest{Token: token}).
|
||||
JsonRequestBody(entity.AuthenticateRequest{Token: token}).
|
||||
JsonResponseBody(&resp).
|
||||
Do(ctx)
|
||||
if err != nil {
|
||||
@@ -36,9 +36,9 @@ func (r Admin) Authenticate(ctx context.Context, token string) (*domain.AdminAut
|
||||
}
|
||||
|
||||
func (r Admin) Authorize(ctx context.Context, adminId int, permission string) (bool, error) {
|
||||
resp := domain.AdminAuthorizeResponse{}
|
||||
resp := entity.AdminAuthorizeResponse{}
|
||||
err := r.cli.Invoke(adminAuthorize).
|
||||
JsonRequestBody(domain.AdminAuthorizeRequest{AdminId: adminId, Permission: permission}).
|
||||
JsonRequestBody(entity.AdminAuthorizeRequest{AdminId: adminId, Permission: permission}).
|
||||
JsonResponseBody(&resp).
|
||||
Do(ctx)
|
||||
if err != nil {
|
||||
|
||||
@@ -4,10 +4,12 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/json"
|
||||
"isp-gate-service/cache"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/entity"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/json"
|
||||
)
|
||||
|
||||
type AuthenticationCache struct {
|
||||
@@ -22,13 +24,13 @@ func NewAuthenticationCache(duration time.Duration) AuthenticationCache {
|
||||
}
|
||||
}
|
||||
|
||||
func (r AuthenticationCache) Get(ctx context.Context, token string) (*domain.AuthData, error) {
|
||||
func (r AuthenticationCache) Get(ctx context.Context, token string) (*entity.AppAuthData, error) {
|
||||
data, ok := r.cache.Get(token)
|
||||
if !ok {
|
||||
return nil, domain.ErrAuthenticationCacheMiss
|
||||
}
|
||||
|
||||
result := domain.AuthData{}
|
||||
result := entity.AppAuthData{}
|
||||
err := json.Unmarshal(data, &result)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "json unmarshal auth data")
|
||||
@@ -37,7 +39,7 @@ func (r AuthenticationCache) Get(ctx context.Context, token string) (*domain.Aut
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (r AuthenticationCache) Set(ctx context.Context, token string, data domain.AuthData) error {
|
||||
func (r AuthenticationCache) Set(ctx context.Context, token string, data entity.AppAuthData) error {
|
||||
value, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "json marshal auth data")
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
"isp-gate-service/entity"
|
||||
)
|
||||
|
||||
@@ -4,9 +4,9 @@ package repository
|
||||
import (
|
||||
"context"
|
||||
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/entity"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
)
|
||||
|
||||
@@ -25,10 +25,10 @@ func NewSystem(cli *client.Client) System {
|
||||
}
|
||||
}
|
||||
|
||||
func (r System) Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error) {
|
||||
resp := domain.AuthenticateResponse{}
|
||||
func (r System) Authenticate(ctx context.Context, token string) (*entity.AuthenticateResponse, error) {
|
||||
resp := entity.AuthenticateResponse{}
|
||||
err := r.cli.Invoke(authenticate).
|
||||
JsonRequestBody(domain.AuthenticateRequest{Token: token}).
|
||||
JsonRequestBody(entity.AuthenticateRequest{Token: token}).
|
||||
JsonResponseBody(&resp).
|
||||
Do(ctx)
|
||||
if err != nil {
|
||||
@@ -37,8 +37,8 @@ func (r System) Authenticate(ctx context.Context, token string) (*domain.Authent
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (r System) Authorize(ctx context.Context, req domain.AuthorizeRequest) (bool, error) {
|
||||
resp := domain.AuthorizeResponse{}
|
||||
func (r System) Authorize(ctx context.Context, req entity.AuthorizeRequest) (bool, error) {
|
||||
resp := entity.AuthorizeResponse{}
|
||||
err := r.cli.Invoke(authorize).
|
||||
JsonRequestBody(req).
|
||||
JsonResponseBody(&resp).
|
||||
|
||||
@@ -5,9 +5,10 @@ import (
|
||||
"time"
|
||||
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/entity"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/json"
|
||||
)
|
||||
|
||||
@@ -25,7 +26,7 @@ func NewRedisAuthCache(cli redis.UniversalClient, duration time.Duration, db int
|
||||
}
|
||||
}
|
||||
|
||||
func (r RedisAuthCache) Get(ctx context.Context, token string) (*domain.AuthData, error) {
|
||||
func (r RedisAuthCache) Get(ctx context.Context, token string) (*entity.AppAuthData, error) {
|
||||
results, err := r.cli.Pipelined(ctx, func(p redis.Pipeliner) error {
|
||||
p.Select(ctx, r.db)
|
||||
p.Get(ctx, token)
|
||||
@@ -43,7 +44,7 @@ func (r RedisAuthCache) Get(ctx context.Context, token string) (*domain.AuthData
|
||||
return nil, errors.WithMessage(err, "get")
|
||||
}
|
||||
|
||||
result := domain.AuthData{}
|
||||
result := entity.AppAuthData{}
|
||||
err = json.Unmarshal([]byte(data), &result)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "json unmarshal auth data")
|
||||
@@ -52,7 +53,7 @@ func (r RedisAuthCache) Get(ctx context.Context, token string) (*domain.AuthData
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (r RedisAuthCache) Set(ctx context.Context, token string, data domain.AuthData) error {
|
||||
func (r RedisAuthCache) Set(ctx context.Context, token string, data entity.AppAuthData) error {
|
||||
value, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "json marshal auth data")
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
type RedisAuthzCache struct {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"isp-gate-service/entity"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/http/httpcli"
|
||||
"github.com/txix-open/isp-kit/http/httpclix"
|
||||
"github.com/txix-open/isp-kit/lb"
|
||||
"github.com/txix-open/isp-kit/metrics/http_metrics"
|
||||
)
|
||||
|
||||
type UserAuth struct {
|
||||
lb *lb.RoundRobin
|
||||
cli *httpcli.Client
|
||||
}
|
||||
|
||||
func NewUserAuth(lb *lb.RoundRobin) UserAuth {
|
||||
return UserAuth{
|
||||
lb: lb,
|
||||
cli: httpclix.Default(),
|
||||
}
|
||||
}
|
||||
|
||||
func (r UserAuth) Authenticate(
|
||||
ctx context.Context,
|
||||
method string,
|
||||
token string,
|
||||
) (*entity.UserAuthenticateResponse, error) {
|
||||
ctx = http_metrics.ClientEndpointToContext(ctx, method)
|
||||
|
||||
host, err := r.lb.Next()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "lb next")
|
||||
}
|
||||
|
||||
endpoint := fmt.Sprintf("http://%s/%s", host, method)
|
||||
resp := entity.UserAuthenticateResponse{}
|
||||
err = r.cli.Post(endpoint).
|
||||
JsonRequestBody(entity.UserAuthenticateRequest{
|
||||
Token: token,
|
||||
}).JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
DoWithoutResponse(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "http client invoke: %s", endpoint)
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/entity"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/json"
|
||||
)
|
||||
|
||||
type Cache interface {
|
||||
Get(key string) ([]byte, bool)
|
||||
Set(key string, data []byte, lifeTime time.Duration)
|
||||
}
|
||||
|
||||
type UserAuthenticationCache struct {
|
||||
cache Cache
|
||||
}
|
||||
|
||||
func NewUserAuthenticationCache(cache Cache) UserAuthenticationCache {
|
||||
return UserAuthenticationCache{
|
||||
cache: cache,
|
||||
}
|
||||
}
|
||||
|
||||
func (r UserAuthenticationCache) Get(ctx context.Context, authMethodPath string, token string) (*entity.UserAuthData, error) {
|
||||
data, ok := r.cache.Get(r.key(authMethodPath, token))
|
||||
if !ok {
|
||||
return nil, domain.ErrAuthenticationCacheMiss
|
||||
}
|
||||
|
||||
result := entity.UserAuthData{}
|
||||
err := json.Unmarshal(data, &result)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "json unmarshal auth data")
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (r UserAuthenticationCache) Set(
|
||||
ctx context.Context,
|
||||
authMethodPath string,
|
||||
token string,
|
||||
data entity.UserAuthData,
|
||||
duration time.Duration,
|
||||
) error {
|
||||
value, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "json marshal auth data")
|
||||
}
|
||||
|
||||
r.cache.Set(r.key(authMethodPath, token), value, duration)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r UserAuthenticationCache) key(authModuleName string, token string) string {
|
||||
return fmt.Sprintf("%s:%s", authModuleName, token)
|
||||
}
|
||||
+34
-13
@@ -6,21 +6,13 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotAuthenticated = errors.New("not authenticated")
|
||||
)
|
||||
|
||||
type AuthData struct {
|
||||
AppName string
|
||||
SystemId int
|
||||
DomainId int
|
||||
ServiceId int
|
||||
ApplicationId int
|
||||
}
|
||||
|
||||
type Context struct {
|
||||
request *http.Request
|
||||
responseWriter http.ResponseWriter
|
||||
@@ -28,13 +20,18 @@ type Context struct {
|
||||
endpointMeta *domain.EndpointMeta
|
||||
|
||||
authenticated bool
|
||||
authData *AuthData
|
||||
authData *domain.AppAuthData
|
||||
|
||||
userAuthenticated bool
|
||||
userAuthData *domain.UserAuthData
|
||||
|
||||
adminAuthenticated bool
|
||||
adminId int
|
||||
adminToken string
|
||||
|
||||
queryParams map[string]string
|
||||
|
||||
httpJsonUtf8Charset bool
|
||||
}
|
||||
|
||||
func NewContext(
|
||||
@@ -65,18 +62,34 @@ func (c *Context) EndpointMeta() *domain.EndpointMeta {
|
||||
return c.endpointMeta
|
||||
}
|
||||
|
||||
func (c *Context) Authenticate(authData AuthData) {
|
||||
func (c *Context) Authenticate(authData domain.AppAuthData) {
|
||||
c.authenticated = true
|
||||
c.authData = &authData
|
||||
}
|
||||
|
||||
func (c *Context) GetAuthData() (AuthData, error) {
|
||||
func (c *Context) GetAuthData() (domain.AppAuthData, error) {
|
||||
if !c.authenticated {
|
||||
return AuthData{}, ErrNotAuthenticated
|
||||
return domain.AppAuthData{}, ErrNotAuthenticated
|
||||
}
|
||||
return *c.authData, nil
|
||||
}
|
||||
|
||||
func (c *Context) AuthenticateUser(authData domain.UserAuthData) {
|
||||
c.userAuthenticated = true
|
||||
c.userAuthData = &authData
|
||||
}
|
||||
|
||||
func (c *Context) GetUserAuthData() (domain.UserAuthData, error) {
|
||||
if !c.userAuthenticated {
|
||||
return domain.UserAuthData{}, ErrNotAuthenticated
|
||||
}
|
||||
return *c.userAuthData, nil
|
||||
}
|
||||
|
||||
func (c *Context) SkipAppAuth() bool {
|
||||
return c.userAuthData != nil && c.userAuthData.SkipAppAuth
|
||||
}
|
||||
|
||||
func (c *Context) IsAdminAuthenticated() bool {
|
||||
return c.adminAuthenticated
|
||||
}
|
||||
@@ -103,6 +116,14 @@ func (c *Context) SetContext(ctx context.Context) {
|
||||
c.request = c.request.WithContext(ctx)
|
||||
}
|
||||
|
||||
func (c *Context) EnableHttpJsonUtf8Charset(enable bool) {
|
||||
c.httpJsonUtf8Charset = enable
|
||||
}
|
||||
|
||||
func (c *Context) IsJsonUtf8CharsetEnabled() bool {
|
||||
return c.httpJsonUtf8Charset
|
||||
}
|
||||
|
||||
func (c *Context) Param(name string) string {
|
||||
value := c.request.Header.Get(name)
|
||||
if value != "" {
|
||||
|
||||
+13
-4
@@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
@@ -45,10 +45,10 @@ func (s *Routes) ReceiveRoutes(ctx context.Context, routes cluster.RoutingConfig
|
||||
for _, descriptor := range backend.Endpoints {
|
||||
path := normalizeDescriptorPath(descriptor.Path)
|
||||
if descriptor.HttpMethod != "" {
|
||||
s.registerEndpoint(router, descriptor.HttpMethod, path, descriptor)
|
||||
s.registerEndpoint(router, backend.ModuleName, descriptor.HttpMethod, path, descriptor)
|
||||
} else {
|
||||
for _, httpMethod := range s.allHttpMethods {
|
||||
s.registerEndpoint(router, httpMethod, path, descriptor)
|
||||
s.registerEndpoint(router, backend.ModuleName, httpMethod, path, descriptor)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,8 @@ func (s *Routes) ResolveEndpoint(method string, path string, cfg middleware.Entr
|
||||
return nil, errors.Errorf("unknown endpoint '%s'", lookupPath)
|
||||
}
|
||||
return &domain.EndpointMeta{
|
||||
Endpoint: metaEndpoint,
|
||||
Endpoint: metaEndpoint,
|
||||
NormalizedEndpoint: normalizePath(metaEndpoint),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -77,6 +78,7 @@ func (s *Routes) ResolveEndpoint(method string, path string, cfg middleware.Entr
|
||||
|
||||
meta := domain.EndpointMetaFromContext(req.Context())
|
||||
meta.Endpoint = metaEndpoint
|
||||
meta.NormalizedEndpoint = normalizePath(meta.PathSchema)
|
||||
return &meta, nil
|
||||
}
|
||||
|
||||
@@ -94,6 +96,7 @@ func (s *Routes) GetPaths(path string, cfg middleware.EntryPointConfig) (string,
|
||||
|
||||
func (s *Routes) registerEndpoint(
|
||||
router *httprouter.Router,
|
||||
moduleName string,
|
||||
httpMethod string,
|
||||
path string,
|
||||
descriptor cluster.EndpointDescriptor,
|
||||
@@ -105,6 +108,8 @@ func (s *Routes) registerEndpoint(
|
||||
requiredAdminPerm, _ := cluster.GetRequiredAdminPermission(descriptor)
|
||||
meta := domain.EndpointMeta{
|
||||
Inner: descriptor.Inner,
|
||||
UserAuthRequired: descriptor.UserAuthRequired,
|
||||
ModuleName: moduleName,
|
||||
RequiredAdminPermission: requiredAdminPerm,
|
||||
PathSchema: descriptor.Path,
|
||||
}
|
||||
@@ -116,3 +121,7 @@ func (s *Routes) registerEndpoint(
|
||||
}
|
||||
router.Handle(httpMethod, path, handler)
|
||||
}
|
||||
|
||||
func normalizePath(path string) string {
|
||||
return strings.TrimPrefix(path, "/")
|
||||
}
|
||||
+8
-3
@@ -4,12 +4,13 @@ import (
|
||||
"context"
|
||||
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/entity"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
type AdminAuth interface {
|
||||
Authenticate(ctx context.Context, token string) (*domain.AdminAuthenticateResponse, error)
|
||||
Authenticate(ctx context.Context, token string) (*entity.AdminAuthenticateResponse, error)
|
||||
Authorize(ctx context.Context, adminId int, permission string) (bool, error)
|
||||
}
|
||||
|
||||
@@ -30,7 +31,11 @@ func (s Admin) AdminAuthenticate(ctx context.Context, token string) (*domain.Adm
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get admin token data from admin service")
|
||||
}
|
||||
return resp, nil
|
||||
return &domain.AdminAuthenticateResponse{
|
||||
Authenticated: resp.Authenticated,
|
||||
ErrorReason: resp.ErrorReason,
|
||||
AdminId: resp.AdminId,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s Admin) AdminAuthorize(ctx context.Context, adminId int, permission string) (bool, error) {
|
||||
|
||||
+46
-19
@@ -2,54 +2,81 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/entity"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
type AuthenticationCache interface {
|
||||
Get(ctx context.Context, token string) (*domain.AuthData, error)
|
||||
Set(ctx context.Context, token string, data domain.AuthData) error
|
||||
Get(ctx context.Context, token string) (*entity.AppAuthData, error)
|
||||
Set(ctx context.Context, token string, data entity.AppAuthData) error
|
||||
}
|
||||
|
||||
type AuthenticationRepo interface {
|
||||
Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error)
|
||||
Authenticate(ctx context.Context, token string) (*entity.AuthenticateResponse, error)
|
||||
}
|
||||
|
||||
type Auth struct {
|
||||
type Authentication struct {
|
||||
cache AuthenticationCache
|
||||
repo AuthenticationRepo
|
||||
}
|
||||
|
||||
func NewAuthentication(cache AuthenticationCache, repo AuthenticationRepo) Auth {
|
||||
return Auth{
|
||||
func NewAuthentication(
|
||||
cache AuthenticationCache,
|
||||
repo AuthenticationRepo,
|
||||
) Authentication {
|
||||
return Authentication{
|
||||
cache: cache,
|
||||
repo: repo,
|
||||
}
|
||||
}
|
||||
|
||||
func (s Auth) Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error) {
|
||||
func (s Authentication) Authenticate(ctx context.Context, token string) (*domain.AuthenticateAppResponse, error) {
|
||||
authData, err := s.cache.Get(ctx, token)
|
||||
if errors.Is(err, domain.ErrAuthenticationCacheMiss) {
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrAuthenticationCacheMiss):
|
||||
resp, err := s.repo.Authenticate(ctx, token)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "auth repo authenticate")
|
||||
}
|
||||
if !resp.Authenticated {
|
||||
return resp, nil
|
||||
return s.convertAuthReponse(resp), nil
|
||||
}
|
||||
err = s.cache.Set(ctx, token, *resp.AuthData)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "auth cache set")
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
if err != nil {
|
||||
return s.convertAuthReponse(resp), nil
|
||||
case err != nil:
|
||||
return nil, errors.WithMessage(err, "auth cache get")
|
||||
default:
|
||||
return &domain.AuthenticateAppResponse{
|
||||
Authenticated: true,
|
||||
ErrorReason: "",
|
||||
AuthData: s.convertAuthData(authData),
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s Authentication) convertAuthReponse(resp *entity.AuthenticateResponse) *domain.AuthenticateAppResponse {
|
||||
return &domain.AuthenticateAppResponse{
|
||||
Authenticated: resp.Authenticated,
|
||||
ErrorReason: resp.ErrorReason,
|
||||
AuthData: s.convertAuthData(resp.AuthData),
|
||||
}
|
||||
}
|
||||
|
||||
func (Authentication) convertAuthData(authData *entity.AppAuthData) *domain.AppAuthData {
|
||||
if authData == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &domain.AppAuthData{
|
||||
AppName: authData.AppName,
|
||||
SystemId: authData.SystemId,
|
||||
DomainId: authData.DomainId,
|
||||
ServiceId: authData.ServiceId,
|
||||
ApplicationId: authData.ApplicationId,
|
||||
}
|
||||
return &domain.AuthenticateResponse{
|
||||
Authenticated: true,
|
||||
ErrorReason: "",
|
||||
AuthData: authData,
|
||||
}, nil
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package service
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/entity"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
type AuthorizationCache interface {
|
||||
@@ -14,7 +14,7 @@ type AuthorizationCache interface {
|
||||
}
|
||||
|
||||
type AuthorizationRepo interface {
|
||||
Authorize(ctx context.Context, req domain.AuthorizeRequest) (bool, error)
|
||||
Authorize(ctx context.Context, req entity.AuthorizeRequest) (bool, error)
|
||||
}
|
||||
|
||||
type Authorization struct {
|
||||
@@ -39,7 +39,7 @@ func (s Authorization) Authorize(ctx context.Context, applicationId int, httpMet
|
||||
return true, nil
|
||||
}
|
||||
|
||||
ok, err = s.repo.Authorize(ctx, domain.AuthorizeRequest{
|
||||
ok, err = s.repo.Authorize(ctx, entity.AuthorizeRequest{
|
||||
ApplicationId: applicationId,
|
||||
HttpMethod: httpMethod,
|
||||
Endpoint: endpoint,
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"isp-gate-service/conf"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/entity"
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package token_provider
|
||||
|
||||
import (
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/request"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
type CookieProvider struct {
|
||||
name string
|
||||
cookieName string
|
||||
validate bool
|
||||
}
|
||||
|
||||
func NewCookieProvider(name string, cfg conf.CookieTokenProvider) CookieProvider {
|
||||
return CookieProvider{
|
||||
name: name,
|
||||
cookieName: cfg.CookieName,
|
||||
validate: cfg.Validate,
|
||||
}
|
||||
}
|
||||
|
||||
func (p CookieProvider) GetName() string {
|
||||
return p.name
|
||||
}
|
||||
|
||||
func (p CookieProvider) ExtractToken(ctx *request.Context) (string, error) {
|
||||
cookie, err := ctx.Request().Cookie(p.cookieName)
|
||||
switch {
|
||||
case errors.Is(err, http.ErrNoCookie):
|
||||
return "", nil
|
||||
case err != nil:
|
||||
return "", errors.WithMessagef(err, "get cookie with name '%s'", p.cookieName)
|
||||
}
|
||||
if !p.validate {
|
||||
return strings.TrimSpace(cookie.Value), nil
|
||||
}
|
||||
|
||||
err = cookie.Valid()
|
||||
if err != nil {
|
||||
return "", errors.WithMessagef(err, "validate cookie with name '%s'", p.cookieName)
|
||||
}
|
||||
return strings.TrimSpace(cookie.Value), nil
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package token_provider
|
||||
|
||||
import (
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/request"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type HeaderProvider struct {
|
||||
name string
|
||||
headerName string
|
||||
}
|
||||
|
||||
func NewHeaderProvider(name string, cfg conf.HeaderTokenProvider) HeaderProvider {
|
||||
return HeaderProvider{
|
||||
name: name,
|
||||
headerName: cfg.HeaderName,
|
||||
}
|
||||
}
|
||||
|
||||
func (p HeaderProvider) GetName() string {
|
||||
return p.name
|
||||
}
|
||||
|
||||
func (p HeaderProvider) ExtractToken(ctx *request.Context) (string, error) {
|
||||
value := ctx.Request().Header.Get(p.headerName)
|
||||
return strings.TrimSpace(value), nil
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
// nolint:ireturn
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/entity"
|
||||
"isp-gate-service/request"
|
||||
"isp-gate-service/service/token_provider"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
type UserAuthenticationCache interface {
|
||||
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, authEndpoint string, token string) (*entity.UserAuthenticateResponse, error)
|
||||
}
|
||||
|
||||
type TokenProvider interface {
|
||||
GetName() string
|
||||
ExtractToken(ctx *request.Context) (string, error)
|
||||
}
|
||||
|
||||
type userAuthSetting struct {
|
||||
tokenProviders []TokenProvider
|
||||
authEndpoint string
|
||||
authCacheDuration time.Duration
|
||||
skipAppAuth bool
|
||||
}
|
||||
|
||||
type UserAuthentication struct {
|
||||
cache UserAuthenticationCache
|
||||
repo UserAuthenticationRepo
|
||||
settingsByModuleName map[string]userAuthSetting
|
||||
}
|
||||
|
||||
func NewUserAuthentication(
|
||||
cfg conf.CustomAuth,
|
||||
cache UserAuthenticationCache,
|
||||
repo UserAuthenticationRepo,
|
||||
) (UserAuthentication, error) {
|
||||
tokenProviders := make(map[string]TokenProvider, len(cfg.TokenProviders))
|
||||
for i, provider := range cfg.TokenProviders {
|
||||
_, ok := tokenProviders[provider.Name]
|
||||
if ok {
|
||||
return UserAuthentication{}, errors.Errorf("token provider name must have unique name, found duplicate at [%d] with name '%s'", i, provider.Name)
|
||||
}
|
||||
|
||||
tokenProvider, err := tokenProviderFromConfig(provider)
|
||||
if err != nil {
|
||||
return UserAuthentication{}, errors.WithMessagef(err, "init token provider with name '%s'", provider.Name)
|
||||
}
|
||||
tokenProviders[provider.Name] = tokenProvider
|
||||
}
|
||||
|
||||
settingsByModuleName := make(map[string]userAuthSetting, len(cfg.UserAuthSettings))
|
||||
for _, setting := range cfg.UserAuthSettings {
|
||||
settingTokenProviders := make([]TokenProvider, 0, len(setting.TokenProviders))
|
||||
for _, providerName := range setting.TokenProviders {
|
||||
tokenProvider, ok := tokenProviders[providerName]
|
||||
if !ok {
|
||||
return UserAuthentication{},
|
||||
errors.Errorf("modules with names'[%s]' has unknown token provider '%s'",
|
||||
strings.Join(setting.ModuleNameList, ","),
|
||||
providerName,
|
||||
)
|
||||
}
|
||||
settingTokenProviders = append(settingTokenProviders, tokenProvider)
|
||||
}
|
||||
|
||||
cacheDuration := time.Duration(setting.CacheDataInSec) * time.Second
|
||||
for _, moduleName := range setting.ModuleNameList {
|
||||
_, ok := settingsByModuleName[moduleName]
|
||||
if ok {
|
||||
return UserAuthentication{},
|
||||
errors.Errorf("setting unique violation, setting for module with name '%s' already present",
|
||||
moduleName,
|
||||
)
|
||||
}
|
||||
settingsByModuleName[moduleName] = userAuthSetting{
|
||||
tokenProviders: settingTokenProviders,
|
||||
authEndpoint: setting.AuthenticateEndpoint,
|
||||
authCacheDuration: cacheDuration,
|
||||
skipAppAuth: setting.SkipAppAuth,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return UserAuthentication{
|
||||
cache: cache,
|
||||
repo: repo,
|
||||
settingsByModuleName: settingsByModuleName,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s UserAuthentication) Authenticate(ctx *request.Context) (*domain.AuthenticateUserResponse, error) {
|
||||
meta := ctx.EndpointMeta()
|
||||
if !meta.UserAuthRequired {
|
||||
return &domain.AuthenticateUserResponse{
|
||||
SkipUserAuth: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
setting, ok := s.settingsByModuleName[meta.ModuleName]
|
||||
if !ok {
|
||||
return nil, errors.WithMessagef(domain.ErrUserAuthSettingNotFound,
|
||||
"setting for module '%s' and endpoint '%s' not found",
|
||||
meta.ModuleName, meta.Endpoint,
|
||||
)
|
||||
}
|
||||
|
||||
token, err := s.extractToken(ctx, setting.tokenProviders)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "extract user token")
|
||||
}
|
||||
|
||||
resp, err := s.authenticate(
|
||||
ctx.Context(),
|
||||
setting,
|
||||
token,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "auth")
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s UserAuthentication) extractToken(ctx *request.Context, providers []TokenProvider) (string, error) {
|
||||
for _, provider := range providers {
|
||||
token, err := provider.ExtractToken(ctx)
|
||||
if err != nil {
|
||||
return "", errors.WithMessagef(
|
||||
domain.ErrInvalidUserToken,
|
||||
"extract token by '%s' error: %s",
|
||||
provider.GetName(),
|
||||
err.Error(),
|
||||
)
|
||||
}
|
||||
if token != "" {
|
||||
return token, nil
|
||||
}
|
||||
}
|
||||
return "", domain.ErrEmptyUserToken
|
||||
}
|
||||
|
||||
func (s UserAuthentication) authenticate(
|
||||
ctx context.Context,
|
||||
setting userAuthSetting,
|
||||
token string,
|
||||
) (*domain.AuthenticateUserResponse, error) {
|
||||
if setting.authCacheDuration <= 0 {
|
||||
resp, err := s.repo.Authenticate(ctx, setting.authEndpoint, token)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "auth repo authenticate")
|
||||
}
|
||||
return s.convertAuthResponse(resp, setting.skipAppAuth), nil
|
||||
}
|
||||
|
||||
authData, err := s.cache.Get(ctx, setting.authEndpoint, token)
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrAuthenticationCacheMiss):
|
||||
resp, err := s.repo.Authenticate(ctx, setting.authEndpoint, token)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "auth repo authenticate")
|
||||
}
|
||||
if !resp.Authenticated {
|
||||
return s.convertAuthResponse(resp, setting.skipAppAuth), nil
|
||||
}
|
||||
err = s.cache.Set(
|
||||
ctx,
|
||||
setting.authEndpoint,
|
||||
token,
|
||||
*resp.AuthData,
|
||||
setting.authCacheDuration,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "auth cache set")
|
||||
}
|
||||
return s.convertAuthResponse(resp, setting.skipAppAuth), nil
|
||||
case err != nil:
|
||||
return nil, errors.WithMessage(err, "auth cache get")
|
||||
default:
|
||||
return &domain.AuthenticateUserResponse{
|
||||
Authenticated: true,
|
||||
ErrorReason: "",
|
||||
AuthData: s.convertAuthData(authData, setting.skipAppAuth),
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s UserAuthentication) convertAuthResponse(resp *entity.UserAuthenticateResponse, skipAppAuth bool) *domain.AuthenticateUserResponse {
|
||||
return &domain.AuthenticateUserResponse{
|
||||
Authenticated: resp.Authenticated,
|
||||
ErrorReason: resp.ErrorReason,
|
||||
AuthData: s.convertAuthData(resp.AuthData, skipAppAuth),
|
||||
}
|
||||
}
|
||||
|
||||
func (UserAuthentication) convertAuthData(authData *entity.UserAuthData, skipAppAuth bool) *domain.UserAuthData {
|
||||
if authData == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &domain.UserAuthData{
|
||||
Identity: authData.Identity,
|
||||
IdentityHeader: authData.IdentityHeader,
|
||||
ExtraHeaders: authData.ExtraHeaders,
|
||||
SkipAppAuth: skipAppAuth,
|
||||
}
|
||||
}
|
||||
|
||||
func tokenProviderFromConfig(cfg conf.TokenProvider) (TokenProvider, error) {
|
||||
switch cfg.Type {
|
||||
case conf.HeaderTokenProviderType:
|
||||
if cfg.HeaderProvider == nil {
|
||||
return nil, errors.Errorf("token method '%s' has empty header provider", cfg.Name)
|
||||
}
|
||||
return token_provider.NewHeaderProvider(cfg.Name, *cfg.HeaderProvider), nil
|
||||
case conf.CookieTokenProviderType:
|
||||
if cfg.CookieProvider == nil {
|
||||
return nil, errors.Errorf("token method '%s' has empty cookie provider", cfg.Name)
|
||||
}
|
||||
return token_provider.NewCookieProvider(cfg.Name, *cfg.CookieProvider), nil
|
||||
default:
|
||||
return nil, errors.Errorf("unknown token provider with type '%s'", cfg.Type)
|
||||
}
|
||||
}
|
||||
+300
-24
@@ -12,15 +12,20 @@ import (
|
||||
"time"
|
||||
|
||||
"isp-gate-service/assembly"
|
||||
"isp-gate-service/cache"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/entity"
|
||||
"isp-gate-service/routes"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/txix-open/etp/v3"
|
||||
"github.com/txix-open/etp/v3/msg"
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/http/endpoint"
|
||||
"github.com/txix-open/isp-kit/http/endpoint/httplog"
|
||||
"github.com/txix-open/isp-kit/http/httpcli"
|
||||
"github.com/txix-open/isp-kit/http/router"
|
||||
"github.com/txix-open/isp-kit/test/fake"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/suite"
|
||||
@@ -86,7 +91,7 @@ func (s *HappyPathTestSuite) TestGrpcProxy() {
|
||||
}})
|
||||
require.NoError(err)
|
||||
|
||||
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli, nil)
|
||||
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli, nil, nil, nil)
|
||||
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
@@ -101,14 +106,14 @@ func (s *HappyPathTestSuite) TestGrpcProxy() {
|
||||
cli := httpcli.New()
|
||||
req := request{Id: uuid.New().String()}
|
||||
resp := response{}
|
||||
_, err = cli.Post(srv.URL+"/api/endpoint").
|
||||
err = cli.Post(srv.URL+"/api/endpoint").
|
||||
Header("x-application-token", "token").
|
||||
Header("x-request-id", requestId).
|
||||
Header("x-auth-admin", "mock-token").
|
||||
JsonRequestBody(req).
|
||||
JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
Do(context.Background())
|
||||
DoWithoutResponse(s.T().Context())
|
||||
require.NoError(err)
|
||||
require.EqualValues(req.Id, resp.Id)
|
||||
}
|
||||
@@ -136,7 +141,7 @@ func (s *HappyPathTestSuite) TestHttpProxy() {
|
||||
}})
|
||||
require.NoError(err)
|
||||
|
||||
locator := assembly.NewLocator(test.Logger(), nil, targetClients, routes, systemCli, adminCli, nil)
|
||||
locator := assembly.NewLocator(test.Logger(), nil, targetClients, routes, systemCli, adminCli, nil, nil, nil)
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/api",
|
||||
@@ -150,19 +155,19 @@ func (s *HappyPathTestSuite) TestHttpProxy() {
|
||||
cli := httpcli.New()
|
||||
req := request{Id: uuid.New().String()}
|
||||
resp := response{}
|
||||
_, err = cli.Post(srv.URL+"/api/endpoint").
|
||||
err = cli.Post(srv.URL+"/api/endpoint").
|
||||
Header("x-application-token", "token").
|
||||
Header("x-request-id", requestId).
|
||||
Header("x-auth-admin", "mock-token").
|
||||
JsonRequestBody(req).
|
||||
JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
Do(context.Background())
|
||||
DoWithoutResponse(s.T().Context())
|
||||
require.NoError(err)
|
||||
require.EqualValues(req.Id, resp.Id)
|
||||
}
|
||||
|
||||
func (s *HappyPathTestSuite) TestWsProxy() { // nolint: funlen
|
||||
func (s *HappyPathTestSuite) TestWsProxy() { // nolint:funlen
|
||||
test, require := test.New(s.T())
|
||||
config, systemCli, adminCli := s.commonDependencies(test)
|
||||
|
||||
@@ -192,7 +197,7 @@ func (s *HappyPathTestSuite) TestWsProxy() { // nolint: funlen
|
||||
}})
|
||||
require.NoError(err)
|
||||
|
||||
locator := assembly.NewLocator(test.Logger(), nil, targetClients, routes, systemCli, adminCli, nil)
|
||||
locator := assembly.NewLocator(test.Logger(), nil, targetClients, routes, systemCli, adminCli, nil, nil, nil)
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/ws",
|
||||
@@ -252,7 +257,7 @@ func (s *HappyPathTestSuite) TestAdminAuthorization() {
|
||||
logger, err := log.New(log.WithLevel(log.DebugLevel))
|
||||
require.NoError(err)
|
||||
routes := routes.NewRoutes(logger)
|
||||
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli, nil)
|
||||
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli, nil, nil, nil)
|
||||
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
@@ -281,28 +286,299 @@ func (s *HappyPathTestSuite) TestAdminAuthorization() {
|
||||
cli := httpcli.New()
|
||||
req := request{Id: uuid.New().String()}
|
||||
resp := response{}
|
||||
_, err = cli.Post(srv.URL+"/api/endpoint").
|
||||
err = cli.Post(srv.URL+"/api/endpoint").
|
||||
Header("x-application-token", "token").
|
||||
Header("x-auth-admin", "mock-token").
|
||||
JsonRequestBody(req).
|
||||
JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
Do(context.Background())
|
||||
DoWithoutResponse(s.T().Context())
|
||||
require.NoError(err)
|
||||
require.EqualValues(req.Id, resp.Id)
|
||||
|
||||
_, err = cli.Post(srv.URL+"/api/failed_endpoint").
|
||||
err = cli.Post(srv.URL+"/api/failed_endpoint").
|
||||
Header("x-application-token", "token").
|
||||
Header("x-auth-admin", "mock-token").
|
||||
JsonRequestBody(req).
|
||||
JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
Do(context.Background())
|
||||
DoWithoutResponse(s.T().Context())
|
||||
errResp := httpcli.ErrorResponse{}
|
||||
require.ErrorAs(err, &errResp)
|
||||
require.EqualValues(http.StatusForbidden, errResp.StatusCode)
|
||||
}
|
||||
|
||||
func (s *HappyPathTestSuite) TestUserAuthorization() { // nolint:funlen
|
||||
test, require := test.New(s.T())
|
||||
config, systemCli, adminCli := s.commonDependencies(test)
|
||||
userAuthData := fake.It[entity.UserAuthData]()
|
||||
userAuthData.IdentityHeader = "x-" + userAuthData.IdentityHeader
|
||||
|
||||
targetService, targetCli := grpct.NewMock(test)
|
||||
targetService.Mock("endpoint", func(ctx context.Context, authData grpc.AuthData, req request) response {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
require.True(ok)
|
||||
require.ElementsMatch([]string{userAuthData.Identity}, md.Get(userAuthData.IdentityHeader))
|
||||
|
||||
return response{Id: req.Id}
|
||||
})
|
||||
targetService.Mock("failed_auth_endpoint", func(ctx context.Context, authData grpc.AuthData, req request) response {
|
||||
return response{Id: req.Id}
|
||||
})
|
||||
|
||||
routerMux := router.New()
|
||||
defaultWrapper := endpoint.DefaultWrapper(
|
||||
test.Logger(),
|
||||
httplog.Noop(),
|
||||
)
|
||||
|
||||
userAuthToken := fake.It[string]()
|
||||
|
||||
routerMux.POST("/test-user-auth/authenticate",
|
||||
defaultWrapper.Endpoint(func(req entity.UserAuthenticateRequest) entity.UserAuthenticateResponse {
|
||||
require.Equal(userAuthToken, req.Token)
|
||||
return entity.UserAuthenticateResponse{
|
||||
Authenticated: true,
|
||||
AuthData: &userAuthData,
|
||||
}
|
||||
}))
|
||||
routerMux.POST("/failed-user-auth/authenticate",
|
||||
defaultWrapper.Endpoint(func(req entity.UserAuthenticateRequest) entity.UserAuthenticateResponse {
|
||||
require.Equal(userAuthToken, req.Token)
|
||||
return entity.UserAuthenticateResponse{
|
||||
Authenticated: false,
|
||||
ErrorReason: "test fail",
|
||||
}
|
||||
}))
|
||||
routerMock := httptest.NewServer(routerMux)
|
||||
targetUrl, err := url.Parse(routerMock.URL)
|
||||
require.NoError(err)
|
||||
rr := lb.NewRoundRobin([]string{targetUrl.Host})
|
||||
|
||||
targetClients := map[string]*client.Client{"target": targetCli}
|
||||
logger, err := log.New(log.WithLevel(log.DebugLevel))
|
||||
require.NoError(err)
|
||||
routes := routes.NewRoutes(logger)
|
||||
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli, nil, rr, cache.New())
|
||||
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/api",
|
||||
Protocol: "grpc",
|
||||
TargetModule: "target",
|
||||
}}
|
||||
config.CustomAuth = conf.CustomAuth{
|
||||
TokenProviders: []conf.TokenProvider{
|
||||
{
|
||||
Name: "test_provider",
|
||||
Type: conf.HeaderTokenProviderType,
|
||||
HeaderProvider: &conf.HeaderTokenProvider{
|
||||
HeaderName: "test-token-header",
|
||||
},
|
||||
},
|
||||
},
|
||||
UserAuthSettings: []conf.UserAuthSetting{
|
||||
{
|
||||
ModuleNameList: []string{"target"},
|
||||
TokenProviders: []string{"test_provider"},
|
||||
AuthenticateEndpoint: "test-user-auth/authenticate",
|
||||
},
|
||||
{
|
||||
ModuleNameList: []string{"target2"},
|
||||
TokenProviders: []string{"test_provider"},
|
||||
AuthenticateEndpoint: "failed-user-auth/authenticate",
|
||||
},
|
||||
},
|
||||
}
|
||||
handler, err := locator.Handler(config, locations)
|
||||
require.NoError(err)
|
||||
|
||||
err = routes.ReceiveRoutes(context.Background(), cluster.RoutingConfig{
|
||||
{
|
||||
ModuleName: "target",
|
||||
Endpoints: []cluster.EndpointDescriptor{{
|
||||
Path: "endpoint",
|
||||
Inner: true,
|
||||
UserAuthRequired: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ModuleName: "target2",
|
||||
Endpoints: []cluster.EndpointDescriptor{
|
||||
{
|
||||
Path: "failed_auth_endpoint",
|
||||
Inner: true,
|
||||
UserAuthRequired: true,
|
||||
}, {
|
||||
Path: "failed_endpoint",
|
||||
Inner: true,
|
||||
UserAuthRequired: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(err)
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
cli := httpcli.New()
|
||||
req := request{Id: uuid.New().String()}
|
||||
resp := response{}
|
||||
err = cli.Post(srv.URL+"/api/endpoint").
|
||||
Header("x-application-token", "token").
|
||||
Header("test-token-header", userAuthToken).
|
||||
Header("x-auth-admin", "mock-token").
|
||||
JsonRequestBody(req).
|
||||
JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
DoWithoutResponse(s.T().Context())
|
||||
require.NoError(err)
|
||||
require.EqualValues(req.Id, resp.Id)
|
||||
|
||||
err = cli.Post(srv.URL+"/api/failed_auth_endpoint").
|
||||
Header("x-application-token", "token").
|
||||
Header("test-token-header", userAuthToken).
|
||||
Header("x-auth-admin", "mock-token").
|
||||
JsonRequestBody(req).
|
||||
JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
DoWithoutResponse(s.T().Context())
|
||||
errResp := httpcli.ErrorResponse{}
|
||||
require.ErrorAs(err, &errResp)
|
||||
require.EqualValues(http.StatusUnauthorized, errResp.StatusCode)
|
||||
}
|
||||
|
||||
func (s *HappyPathTestSuite) TestUserAuthorization_SkipAppAuth() { // nolint:funlen
|
||||
test, require := test.New(s.T())
|
||||
config, _, adminCli := s.commonDependencies(test)
|
||||
systemService, systemCli := grpct.NewMock(test)
|
||||
systemService.Mock("system/secure/authenticate", func() entity.AuthenticateResponse {
|
||||
return entity.AuthenticateResponse{
|
||||
Authenticated: false,
|
||||
ErrorReason: "",
|
||||
}
|
||||
}).Mock("system/secure/authorize", func() entity.AuthorizeResponse {
|
||||
return entity.AuthorizeResponse{Authorized: false}
|
||||
})
|
||||
|
||||
userAuthData := fake.It[entity.UserAuthData]()
|
||||
userAuthData.IdentityHeader = "x-" + userAuthData.IdentityHeader
|
||||
|
||||
targetService, targetCli := grpct.NewMock(test)
|
||||
targetService.Mock("endpoint", func(ctx context.Context, authData grpc.AuthData, req request) response {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
require.True(ok)
|
||||
require.ElementsMatch([]string{userAuthData.Identity}, md.Get(userAuthData.IdentityHeader))
|
||||
|
||||
return response{Id: req.Id}
|
||||
})
|
||||
|
||||
routerMux := router.New()
|
||||
defaultWrapper := endpoint.DefaultWrapper(
|
||||
test.Logger(),
|
||||
httplog.Noop(),
|
||||
)
|
||||
|
||||
userAuthToken := fake.It[string]()
|
||||
|
||||
routerMux.POST("/test-user-auth/authenticate",
|
||||
defaultWrapper.Endpoint(func(req entity.UserAuthenticateRequest) entity.UserAuthenticateResponse {
|
||||
require.Equal(userAuthToken, req.Token)
|
||||
return entity.UserAuthenticateResponse{
|
||||
Authenticated: true,
|
||||
AuthData: &userAuthData,
|
||||
}
|
||||
}))
|
||||
routerMock := httptest.NewServer(routerMux)
|
||||
targetUrl, err := url.Parse(routerMock.URL)
|
||||
require.NoError(err)
|
||||
rr := lb.NewRoundRobin([]string{targetUrl.Host})
|
||||
|
||||
targetClients := map[string]*client.Client{"target": targetCli}
|
||||
logger, err := log.New(log.WithLevel(log.DebugLevel))
|
||||
require.NoError(err)
|
||||
routes := routes.NewRoutes(logger)
|
||||
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli, nil, rr, cache.New())
|
||||
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/api",
|
||||
Protocol: "grpc",
|
||||
TargetModule: "target",
|
||||
}}
|
||||
config.CustomAuth = conf.CustomAuth{
|
||||
TokenProviders: []conf.TokenProvider{
|
||||
{
|
||||
Name: "test_provider",
|
||||
Type: conf.HeaderTokenProviderType,
|
||||
HeaderProvider: &conf.HeaderTokenProvider{
|
||||
HeaderName: "test-token-header",
|
||||
},
|
||||
},
|
||||
},
|
||||
UserAuthSettings: []conf.UserAuthSetting{
|
||||
{
|
||||
ModuleNameList: []string{"target"},
|
||||
TokenProviders: []string{"test_provider"},
|
||||
AuthenticateEndpoint: "test-user-auth/authenticate",
|
||||
SkipAppAuth: true,
|
||||
},
|
||||
{
|
||||
ModuleNameList: []string{"target2"},
|
||||
TokenProviders: []string{"test_provider"},
|
||||
AuthenticateEndpoint: "test-user-auth/authenticate",
|
||||
},
|
||||
},
|
||||
}
|
||||
handler, err := locator.Handler(config, locations)
|
||||
require.NoError(err)
|
||||
|
||||
err = routes.ReceiveRoutes(context.Background(), cluster.RoutingConfig{{
|
||||
ModuleName: "target",
|
||||
Endpoints: []cluster.EndpointDescriptor{{
|
||||
Path: "endpoint",
|
||||
Inner: true,
|
||||
UserAuthRequired: true,
|
||||
}}},
|
||||
{
|
||||
ModuleName: "target2",
|
||||
Endpoints: []cluster.EndpointDescriptor{{
|
||||
Path: "failed_endpoint",
|
||||
Inner: true,
|
||||
UserAuthRequired: true,
|
||||
}},
|
||||
},
|
||||
})
|
||||
require.NoError(err)
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
cli := httpcli.New()
|
||||
req := request{Id: uuid.New().String()}
|
||||
resp := response{}
|
||||
err = cli.Post(srv.URL+"/api/endpoint").
|
||||
Header("x-application-token", "token").
|
||||
Header("test-token-header", userAuthToken).
|
||||
Header("x-auth-admin", "mock-token").
|
||||
JsonRequestBody(req).
|
||||
JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
DoWithoutResponse(s.T().Context())
|
||||
require.NoError(err)
|
||||
require.EqualValues(req.Id, resp.Id)
|
||||
|
||||
err = cli.Post(srv.URL+"/api/failed_endpoint").
|
||||
Header("x-application-token", "token").
|
||||
Header("test-token-header", userAuthToken).
|
||||
Header("x-auth-admin", "mock-token").
|
||||
JsonRequestBody(req).
|
||||
JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
DoWithoutResponse(s.T().Context())
|
||||
errResp := httpcli.ErrorResponse{}
|
||||
require.ErrorAs(err, &errResp)
|
||||
require.EqualValues(http.StatusUnauthorized, errResp.StatusCode)
|
||||
}
|
||||
|
||||
// nolint:ireturn
|
||||
func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, *client.Client, *client.Client) {
|
||||
config := conf.Remote{
|
||||
@@ -316,11 +592,11 @@ func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, *
|
||||
}
|
||||
|
||||
systemService, systemCli := grpct.NewMock(test)
|
||||
systemService.Mock("system/secure/authenticate", func() domain.AuthenticateResponse {
|
||||
return domain.AuthenticateResponse{
|
||||
systemService.Mock("system/secure/authenticate", func() entity.AuthenticateResponse {
|
||||
return entity.AuthenticateResponse{
|
||||
Authenticated: true,
|
||||
ErrorReason: "",
|
||||
AuthData: &domain.AuthData{
|
||||
AuthData: &entity.AppAuthData{
|
||||
SystemId: 1,
|
||||
DomainId: 2,
|
||||
ServiceId: 3,
|
||||
@@ -328,22 +604,22 @@ func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, *
|
||||
AppName: "test",
|
||||
},
|
||||
}
|
||||
}).Mock("system/secure/authorize", func() domain.AuthorizeResponse {
|
||||
return domain.AuthorizeResponse{Authorized: true}
|
||||
}).Mock("system/secure/authorize", func() entity.AuthorizeResponse {
|
||||
return entity.AuthorizeResponse{Authorized: true}
|
||||
})
|
||||
|
||||
adminService, adminCli := grpct.NewMock(test)
|
||||
adminService.Mock("admin/secure/authenticate", func(req domain.AdminAuthorizeRequest) domain.AdminAuthenticateResponse {
|
||||
return domain.AdminAuthenticateResponse{
|
||||
adminService.Mock("admin/secure/authenticate", func(req entity.AdminAuthorizeRequest) entity.AdminAuthenticateResponse {
|
||||
return entity.AdminAuthenticateResponse{
|
||||
Authenticated: true,
|
||||
ErrorReason: "",
|
||||
AdminId: 1,
|
||||
}
|
||||
}).Mock("admin/secure/authorize", func(req domain.AdminAuthorizeRequest) domain.AdminAuthorizeResponse {
|
||||
}).Mock("admin/secure/authorize", func(req entity.AdminAuthorizeRequest) entity.AdminAuthorizeResponse {
|
||||
if req.Permission == "ok_permission" {
|
||||
return domain.AdminAuthorizeResponse{Authorized: true}
|
||||
return entity.AdminAuthorizeResponse{Authorized: true}
|
||||
}
|
||||
return domain.AdminAuthorizeResponse{Authorized: false}
|
||||
return entity.AdminAuthorizeResponse{Authorized: false}
|
||||
})
|
||||
|
||||
return config, systemCli, adminCli
|
||||
|
||||
@@ -5,12 +5,14 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"isp-gate-service/assembly"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/entity"
|
||||
"isp-gate-service/routes"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/txix-open/isp-kit/grpc"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
endpoint2 "github.com/txix-open/isp-kit/grpc/endpoint"
|
||||
@@ -54,19 +56,19 @@ func main() {
|
||||
}
|
||||
|
||||
systemService, systemCli, _ := NewMock(logger)
|
||||
systemService.Mock("system/secure/authenticate", func() domain.AuthenticateResponse {
|
||||
return domain.AuthenticateResponse{
|
||||
systemService.Mock("system/secure/authenticate", func() entity.AuthenticateResponse {
|
||||
return entity.AuthenticateResponse{
|
||||
Authenticated: true,
|
||||
ErrorReason: "",
|
||||
AuthData: &domain.AuthData{
|
||||
AuthData: &entity.AppAuthData{
|
||||
SystemId: 1,
|
||||
DomainId: 1,
|
||||
ServiceId: 1,
|
||||
ApplicationId: 1,
|
||||
},
|
||||
}
|
||||
}).Mock("system/secure/authorize", func() domain.AuthorizeResponse {
|
||||
return domain.AuthorizeResponse{Authorized: true}
|
||||
}).Mock("system/secure/authorize", func() entity.AuthorizeResponse {
|
||||
return entity.AuthorizeResponse{Authorized: true}
|
||||
})
|
||||
|
||||
adminService, _, adminCli := NewMock(logger)
|
||||
@@ -84,7 +86,7 @@ func main() {
|
||||
})
|
||||
targetClients := map[string]*client.Client{"target": targetCli}
|
||||
logger, _ = log.New(log.WithLevel(log.DebugLevel))
|
||||
locator := assembly.NewLocator(logger, targetClients, nil, routes.NewRoutes(logger), systemCli, adminCli, nil)
|
||||
locator := assembly.NewLocator(logger, targetClients, nil, routes.NewRoutes(logger), systemCli, adminCli, nil, nil, nil)
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/api",
|
||||
|
||||
Reference in new issue
Block a user