Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a269de8e17 | ||
|
|
15cb2cadf2 | ||
|
|
76f88fd593 | ||
|
|
9ff0057014 | ||
|
|
71a1f0a04e | ||
|
|
394bbc82e2 | ||
|
|
7de248e63c | ||
|
|
011a1d7048 | ||
|
|
f3fb9cff75 | ||
|
|
c7bd042239 | ||
|
|
202fa7035e | ||
|
|
602a2a1ac4 | ||
|
|
6a3abf67a2 | ||
|
|
2f88738f78 | ||
|
|
a637d56ea7 | ||
|
|
a841cd082b | ||
|
|
9b18fe7351 | ||
|
|
f3c801e4a4 | ||
|
|
ee13991d87 | ||
|
|
d4846359e4 | ||
|
|
13cf0075f6 | ||
|
|
135e551473 | ||
|
|
689f730a3e | ||
|
|
a30582fa38 | ||
|
|
5b1ce14467 | ||
|
|
264b438cdb | ||
|
|
f699aefa58 | ||
|
|
8d40e76637 | ||
|
|
e2b4becfd6 | ||
|
|
e4ef2d8645 | ||
|
|
bfc28503d5 | ||
|
|
d759f883f4 | ||
|
|
64373fdf3c | ||
|
|
1dd566593e | ||
|
|
560c1f22c4 | ||
|
|
171b85f627 | ||
|
|
734b83b2b8 | ||
|
|
bdeb2c0753 | ||
|
|
97c44fb3bd | ||
|
|
6db18c1495 | ||
|
|
cd985ff5a3 | ||
|
|
2eed857503 | ||
|
|
2b91caece0 |
No files matched your search
@@ -0,0 +1,60 @@
|
|||||||
|
name: Create and publish a Docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
APP_NAME: ${{ github.event.repository.name }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push-image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Get version from tag
|
||||||
|
id: version_reader
|
||||||
|
run: |
|
||||||
|
VERSION=${GITHUB_REF_NAME#v}
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
driver: docker-container
|
||||||
|
- name: Log in to the Container registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_reader.outputs.version }}
|
||||||
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
|
||||||
|
org.opencontainers.image.version=${{ steps.version_reader.outputs.version }}
|
||||||
|
build-args: |
|
||||||
|
app_name=${{ env.APP_NAME }}
|
||||||
|
version=${{ steps.version_reader.outputs.version }}
|
||||||
|
- name: Generate artifact attestation
|
||||||
|
uses: actions/attest-build-provenance@v2
|
||||||
|
with:
|
||||||
|
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
|
||||||
|
subject-digest: ${{ steps.push.outputs.digest }}
|
||||||
|
push-to-registry: true
|
||||||
@@ -1,10 +1,3 @@
|
|||||||
### v5.12.0
|
|
||||||
* добавлена проверка пользовательских прав на эндпоинте: гейт вызывает `authorizeEndpoint` модуля из `userAuthSettings` и возвращает 403, если пользователь не имеет права, объявленного в дескрипторе эндпоинта; положительные результаты кэшируются на `caching.authorizationDataInSec`
|
|
||||||
* добавлена очистка хедеров, совпадающих с хедерами пришедшими в `UserAuthData.ExtraHeaders`, перед добавлением
|
|
||||||
### v5.11.4
|
|
||||||
* добавлена возможность через переменную окружения `adminServiceName` переопределить название сервиса `msp-admin-service`
|
|
||||||
### v5.11.3
|
|
||||||
* добавлена настройка для преопределения content-type в ответе с `application/json` на `application/json; charset=utf-8` для конкретных приложений
|
|
||||||
### v5.11.2
|
### v5.11.2
|
||||||
* обновлены зависимости
|
* обновлены зависимости
|
||||||
### v5.11.1
|
### v5.11.1
|
||||||
|
|||||||
+5
-10
@@ -8,10 +8,10 @@ import (
|
|||||||
"isp-gate-service/conf"
|
"isp-gate-service/conf"
|
||||||
"isp-gate-service/routes"
|
"isp-gate-service/routes"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/app"
|
"github.com/txix-open/isp-kit/app"
|
||||||
"github.com/txix-open/isp-kit/bootstrap"
|
"github.com/txix-open/isp-kit/bootstrap"
|
||||||
"github.com/txix-open/isp-kit/cluster"
|
"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/grpc/client"
|
||||||
"github.com/txix-open/isp-kit/http"
|
"github.com/txix-open/isp-kit/http"
|
||||||
"github.com/txix-open/isp-kit/lb"
|
"github.com/txix-open/isp-kit/lb"
|
||||||
@@ -20,7 +20,6 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
routerModuleName = "isp-router-service"
|
routerModuleName = "isp-router-service"
|
||||||
defaultAdminServiceName = "msp-admin-service"
|
|
||||||
usersAuthCachePurgeInterval = 5 * time.Second
|
usersAuthCachePurgeInterval = 5 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ type Assembly struct {
|
|||||||
lockerCli *client.Client
|
lockerCli *client.Client
|
||||||
routerLb *lb.RoundRobin
|
routerLb *lb.RoundRobin
|
||||||
|
|
||||||
localConfig conf.Local
|
locations []conf.Location
|
||||||
grpcClientByModuleName map[string]*client.Client
|
grpcClientByModuleName map[string]*client.Client
|
||||||
httpHostManagerByModuleName map[string]*lb.RoundRobin
|
httpHostManagerByModuleName map[string]*lb.RoundRobin
|
||||||
|
|
||||||
@@ -86,7 +85,7 @@ func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
|||||||
server: server,
|
server: server,
|
||||||
logger: boot.App.Logger(),
|
logger: boot.App.Logger(),
|
||||||
routes: routes.NewRoutes(boot.App.Logger()),
|
routes: routes.NewRoutes(boot.App.Logger()),
|
||||||
localConfig: localConfig,
|
locations: localConfig.Locations,
|
||||||
grpcClientByModuleName: grpcClientByModuleName,
|
grpcClientByModuleName: grpcClientByModuleName,
|
||||||
httpHostManagerByModuleName: httpHostManagerByModuleName,
|
httpHostManagerByModuleName: httpHostManagerByModuleName,
|
||||||
systemCli: systemCli,
|
systemCli: systemCli,
|
||||||
@@ -119,7 +118,7 @@ func (a *Assembly) ReceiveConfig(ctx context.Context, remoteConfig []byte) error
|
|||||||
a.routerLb,
|
a.routerLb,
|
||||||
a.usersAuthCache,
|
a.usersAuthCache,
|
||||||
)
|
)
|
||||||
handler, err := locator.Handler(newCfg, a.localConfig.Locations)
|
handler, err := locator.Handler(newCfg, a.locations)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "locator handler")
|
return errors.WithMessage(err, "locator handler")
|
||||||
}
|
}
|
||||||
@@ -140,12 +139,8 @@ func (a *Assembly) Runners() []app.Runner {
|
|||||||
for moduleName, upgrader := range a.httpHostManagerByModuleName {
|
for moduleName, upgrader := range a.httpHostManagerByModuleName {
|
||||||
eventHandler.RequireModule(moduleName, upgrader)
|
eventHandler.RequireModule(moduleName, upgrader)
|
||||||
}
|
}
|
||||||
adminServiceName := a.localConfig.AdminServiceName
|
|
||||||
if adminServiceName == "" {
|
|
||||||
adminServiceName = defaultAdminServiceName
|
|
||||||
}
|
|
||||||
eventHandler.RequireModule("isp-system-service", a.systemCli)
|
eventHandler.RequireModule("isp-system-service", a.systemCli)
|
||||||
eventHandler.RequireModule(adminServiceName, a.adminCli)
|
eventHandler.RequireModule("msp-admin-service", a.adminCli)
|
||||||
eventHandler.RequireModule("isp-lock-service", a.lockerCli)
|
eventHandler.RequireModule("isp-lock-service", a.lockerCli)
|
||||||
eventHandler.RequireModule(routerModuleName, a.routerLb)
|
eventHandler.RequireModule(routerModuleName, a.routerLb)
|
||||||
|
|
||||||
|
|||||||
+1
-10
@@ -17,7 +17,7 @@ import (
|
|||||||
"isp-gate-service/service"
|
"isp-gate-service/service"
|
||||||
|
|
||||||
mux2 "github.com/gorilla/mux"
|
mux2 "github.com/gorilla/mux"
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/grpc/client"
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
"github.com/txix-open/isp-kit/lb"
|
"github.com/txix-open/isp-kit/lb"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
@@ -67,12 +67,10 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
|||||||
authentication := service.NewAuthentication(authenticationCache, systemRepo)
|
authentication := service.NewAuthentication(authenticationCache, systemRepo)
|
||||||
|
|
||||||
userAuthenticationCache := repository.NewUserAuthenticationCache(l.usersAuthCache)
|
userAuthenticationCache := repository.NewUserAuthenticationCache(l.usersAuthCache)
|
||||||
userAuthorizationCache := repository.NewUserAuthorizationCache(time.Duration(config.Caching.AuthorizationDataInSec) * time.Second)
|
|
||||||
userAuthRepo := repository.NewUserAuth(l.routerLb)
|
userAuthRepo := repository.NewUserAuth(l.routerLb)
|
||||||
userAuthentication, err := service.NewUserAuthentication(
|
userAuthentication, err := service.NewUserAuthentication(
|
||||||
config.CustomAuth,
|
config.CustomAuth,
|
||||||
userAuthenticationCache,
|
userAuthenticationCache,
|
||||||
userAuthorizationCache,
|
|
||||||
userAuthRepo,
|
userAuthRepo,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -126,11 +124,6 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
|||||||
forwardReqIdByAppId[setting.ApplicationId] = setting.ForwardRequestId
|
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)
|
metricsStorage := http_metrics.NewServerStorage(metrics.DefaultRegistry)
|
||||||
|
|
||||||
handler := middleware.Chain(
|
handler := middleware.Chain(
|
||||||
@@ -144,11 +137,9 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
|||||||
middleware.RequestId(),
|
middleware.RequestId(),
|
||||||
middleware.ErrorHandler(l.logger),
|
middleware.ErrorHandler(l.logger),
|
||||||
middleware.UserAuthenticate(userAuthentication, l.logger),
|
middleware.UserAuthenticate(userAuthentication, l.logger),
|
||||||
middleware.UserAuthorize(userAuthentication),
|
|
||||||
middleware.Authenticate(authentication),
|
middleware.Authenticate(authentication),
|
||||||
middleware.AdminAuthenticate(adminService),
|
middleware.AdminAuthenticate(adminService),
|
||||||
middleware.ClientRequestId(config.EnableClientRequestIdForwarding, forwardReqIdByAppId),
|
middleware.ClientRequestId(config.EnableClientRequestIdForwarding, forwardReqIdByAppId),
|
||||||
middleware.JsonResponseUtf8Charset(enableUtf8JsonCharsetByApp),
|
|
||||||
middleware.Authorize(authorization, l.logger),
|
middleware.Authorize(authorization, l.logger),
|
||||||
middleware.AdminAuthorize(adminService),
|
middleware.AdminAuthorize(adminService),
|
||||||
middleware.Throttling(throttlingService),
|
middleware.Throttling(throttlingService),
|
||||||
|
|||||||
+1
-2
@@ -17,9 +17,8 @@ logfile:
|
|||||||
maxBackups: 4
|
maxBackups: 4
|
||||||
compress: true
|
compress: true
|
||||||
|
|
||||||
adminServiceName: msp-admin-service
|
|
||||||
|
|
||||||
locations:
|
locations:
|
||||||
- pathPrefix: /api
|
- pathPrefix: /api
|
||||||
protocol: grpc
|
protocol: grpc
|
||||||
targetModule: router
|
targetModule: router
|
||||||
+1
-2
@@ -7,8 +7,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Local struct {
|
type Local struct {
|
||||||
Locations []Location
|
Locations []Location
|
||||||
AdminServiceName string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Location struct {
|
type Location struct {
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ type Remote struct {
|
|||||||
EnableClientRequestIdForwarding bool `schema:"Включить проброс requestId из заголовка запроса"`
|
EnableClientRequestIdForwarding bool `schema:"Включить проброс requestId из заголовка запроса"`
|
||||||
ForwardReqIdClientSettings []ForwardReqIdClientSettings `schema:"Настройки проброcа requestId для приложений"`
|
ForwardReqIdClientSettings []ForwardReqIdClientSettings `schema:"Настройки проброcа requestId для приложений"`
|
||||||
CustomAuth CustomAuth `schema:"Настройка кастомной аутентификации/авторизации"`
|
CustomAuth CustomAuth `schema:"Настройка кастомной аутентификации/авторизации"`
|
||||||
ResponseContentTypeSettings []ResponseContentTypeSetting `schema:"Настройки Content-Type ответов"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ForwardReqIdClientSettings struct {
|
type ForwardReqIdClientSettings struct {
|
||||||
@@ -96,12 +95,6 @@ type UserAuthSetting struct {
|
|||||||
ModuleNameList []string `schema:"Название модулей,для которых настраивается аутентификация/авторизация,название модулей должно быть уникальным" validate:"required"`
|
ModuleNameList []string `schema:"Название модулей,для которых настраивается аутентификация/авторизация,название модулей должно быть уникальным" validate:"required"`
|
||||||
TokenProviders []string `schema:"Список названий методов получения токена из запроса,используется первый провайдер, вернувший токен"`
|
TokenProviders []string `schema:"Список названий методов получения токена из запроса,используется первый провайдер, вернувший токен"`
|
||||||
AuthenticateEndpoint string `schema:"Endpoint для аутентификации пользователя,вызывается через isp-router-service" validate:"required"`
|
AuthenticateEndpoint string `schema:"Endpoint для аутентификации пользователя,вызывается через isp-router-service" validate:"required"`
|
||||||
AuthorizeEndpoint string `schema:"Endpoint для проверки прав пользователя,вызывается через isp-router-service" validate:"required"`
|
|
||||||
CacheDataInSec int `schema:"Время кеширования данных аутентификации/авторизации пользователя,отключен при значениях <=0,в секундах"`
|
CacheDataInSec int `schema:"Время кеширования данных аутентификации/авторизации пользователя,отключен при значениях <=0,в секундах"`
|
||||||
SkipAppAuth bool `schema:"Пропустить аутентификацию и авторизацию приложения"`
|
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"`
|
|
||||||
}
|
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package domain
|
package domain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ type EndpointMeta struct {
|
|||||||
|
|
||||||
ModuleName string
|
ModuleName string
|
||||||
RequiredAdminPermission string
|
RequiredAdminPermission string
|
||||||
RequiredUserPermission string
|
|
||||||
// Объявляемый сервисом метод
|
// Объявляемый сервисом метод
|
||||||
PathSchema string
|
PathSchema string
|
||||||
// Вызываемый метод
|
// Вызываемый метод
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package domain
|
package domain
|
||||||
|
|
||||||
import "github.com/txix-open/isp-kit/errors"
|
import "github.com/pkg/errors"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrUserAuthSettingNotFound = errors.New("user auth setting not found")
|
ErrUserAuthSettingNotFound = errors.New("user auth setting not found")
|
||||||
|
|||||||
@@ -15,12 +15,3 @@ type UserAuthData struct {
|
|||||||
IdentityHeader string
|
IdentityHeader string
|
||||||
ExtraHeaders map[string][]string
|
ExtraHeaders map[string][]string
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserAuthorizeRequest struct {
|
|
||||||
Identity string
|
|
||||||
Permission string
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserAuthorizeResponse struct {
|
|
||||||
Authorized bool
|
|
||||||
}
|
|
||||||
@@ -1,57 +1,58 @@
|
|||||||
module isp-gate-service
|
module isp-gate-service
|
||||||
|
|
||||||
go 1.26.0
|
go 1.26
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/gorilla/mux v1.8.1
|
github.com/gorilla/mux v1.8.1
|
||||||
github.com/gorilla/websocket v1.5.3
|
github.com/gorilla/websocket v1.5.3
|
||||||
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/redis/go-redis/v9 v9.18.0
|
github.com/redis/go-redis/v9 v9.18.0
|
||||||
github.com/stretchr/testify v1.11.1
|
github.com/stretchr/testify v1.11.1
|
||||||
github.com/tomakado/websocketproxy v0.1.0
|
github.com/tomakado/websocketproxy v0.1.0
|
||||||
github.com/txix-open/isp-kit v1.74.0
|
github.com/txix-open/isp-kit v1.71.1
|
||||||
github.com/txix-open/jsonschema v1.3.0
|
github.com/txix-open/jsonschema v1.3.0
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260729162451-8efbd57d26e0
|
golang.org/x/net v0.57.0
|
||||||
google.golang.org/grpc v1.83.0
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20260724162435-b2f20204f0df
|
||||||
|
google.golang.org/grpc v1.82.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||||
github.com/go-faker/faker/v4 v4.10.1 // indirect
|
github.com/go-faker/faker/v4 v4.9.0 // indirect
|
||||||
github.com/klauspost/compress v1.19.1 // indirect
|
github.com/klauspost/compress v1.19.0 // indirect
|
||||||
github.com/txix-open/etp/v4 v4.1.3 // indirect
|
github.com/txix-open/etp/v4 v4.1.1 // indirect
|
||||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||||
go.uber.org/atomic v1.11.0 // indirect
|
go.uber.org/atomic v1.11.0 // indirect
|
||||||
golang.org/x/net v0.57.0 // indirect
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/buger/jsonparser v1.6.0 // indirect
|
github.com/buger/jsonparser v1.2.0 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/coder/websocket v1.8.15 // indirect
|
github.com/coder/websocket v1.8.15 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // 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/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.15 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
|
||||||
github.com/getsentry/sentry-go v0.48.0 // indirect
|
github.com/getsentry/sentry-go v0.47.0 // indirect
|
||||||
github.com/go-logr/logr v1.4.4 // indirect
|
github.com/go-logr/logr v1.4.3 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/julienschmidt/httprouter v1.3.0
|
github.com/julienschmidt/httprouter v1.3.0
|
||||||
github.com/leodido/go-urn v1.5.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/mailru/easyjson v0.9.2 // indirect
|
github.com/mailru/easyjson v0.9.2 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // 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_golang v1.23.2 // indirect
|
||||||
github.com/prometheus/client_model v0.6.2 // indirect
|
github.com/prometheus/client_model v0.6.2 // indirect
|
||||||
github.com/prometheus/common v0.70.1 // indirect
|
github.com/prometheus/common v0.69.0 // indirect
|
||||||
github.com/prometheus/procfs v0.21.1 // indirect
|
github.com/prometheus/procfs v0.21.1 // indirect
|
||||||
github.com/txix-open/bellows v1.2.0 // indirect
|
github.com/txix-open/bellows v1.2.0 // indirect
|
||||||
github.com/txix-open/etp/v3 v3.2.0
|
github.com/txix-open/etp/v3 v3.2.0
|
||||||
@@ -67,13 +68,13 @@ require (
|
|||||||
go.opentelemetry.io/otel/metric 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/sdk v1.44.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.44.0 // indirect
|
go.opentelemetry.io/otel/trace v1.44.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v1.11.0 // indirect
|
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
go.uber.org/zap v1.28.0 // indirect
|
go.uber.org/zap v1.28.0 // indirect
|
||||||
golang.org/x/crypto v0.54.0 // indirect
|
golang.org/x/crypto v0.54.0 // indirect
|
||||||
golang.org/x/sys v0.47.0 // indirect
|
golang.org/x/sys v0.47.0 // indirect
|
||||||
golang.org/x/text v0.40.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/genproto/googleapis/api v0.0.0-20260630182238-925bb5da69e7 // indirect
|
||||||
google.golang.org/protobuf v1.36.11 // indirect
|
google.golang.org/protobuf v1.36.11 // indirect
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ 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/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 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||||
github.com/buger/jsonparser v1.6.0 h1:IHTgLjkgckOjAp8p0aYfXkv+cqC+zrzALg/JywnPjxY=
|
github.com/buger/jsonparser v1.2.0 h1:4EFcvK1kD4jyj6YqNK6skK6w+y7FHHBR+XBCtxwu/6g=
|
||||||
github.com/buger/jsonparser v1.6.0/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
github.com/buger/jsonparser v1.2.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 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
|
||||||
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
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 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
@@ -24,17 +24,17 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
|
|||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
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 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.15 h1:05iP/CYtZ/w455R/KZM6rZ5ieAdh99UPtd+d3YzLmaI=
|
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.15/go.mod h1:azpTcoLcDZRNgFou5j+APrqQx9HqVPWa6ijYQIIVswQ=
|
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||||
github.com/getsentry/sentry-go v0.48.0 h1:FRZNr7Uk1C86ev1bSJmYlUkL9oyivQA6YOcdYfaaMmY=
|
github.com/getsentry/sentry-go v0.47.0 h1:AnSMSyrYA5qZCIN/2xpgAAwv63sVULV+vBq37ajouc8=
|
||||||
github.com/getsentry/sentry-go v0.48.0/go.mod h1:E5UkA5wp1qR2+MDydNYlVeUiNN2xEdjYMidkgf0Qoss=
|
github.com/getsentry/sentry-go v0.47.0/go.mod h1:h+b4VHpKnK7aUXB5wc+KDnPgp9ZtfliRD4eV85FbiSA=
|
||||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
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-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
||||||
github.com/go-faker/faker/v4 v4.10.1 h1:mGH3y0X8AfrXsfgPsPuTkWBYIebomvdkWEN1uDLoFFg=
|
github.com/go-faker/faker/v4 v4.9.0 h1:a4HXLwueuTCtgF93VpUsl8Zd2nG1VH2SgNWDPVEBg5U=
|
||||||
github.com/go-faker/faker/v4 v4.10.1/go.mod h1:VFIEwWDd16EdYDLF6NJ5gAAzEp7vz5LgKgJ2iZ17Tdg=
|
github.com/go-faker/faker/v4 v4.9.0/go.mod h1:u1dIRP5neLB6kTzgyVjdBOV5R1uP7BdxkcWk7tiKQXk=
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
|
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||||
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
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-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
@@ -62,8 +62,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
|
|||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
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 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||||
github.com/klauspost/compress v1.19.1 h1:VsB4HPswih7mmZ8WleSFQ75c/Ui1M4trX5oAsJnhSlk=
|
github.com/klauspost/compress v1.19.0 h1:sXLILfc9jV2QYWkzFOPWStmcUVH2RHEB1JCdY2oVvCQ=
|
||||||
github.com/klauspost/compress v1.19.1/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
github.com/klauspost/compress v1.19.0/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
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/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 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
@@ -72,8 +72,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
|||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
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 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||||
github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0=
|
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||||
github.com/leodido/go-urn v1.5.0/go.mod h1:9BORnCDhdPBJNDEX+w1bJisa8yOKYi116VeO96s4ifE=
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
github.com/mailru/easyjson v0.9.2 h1:dX8U45hQsZpxd80nLvDGihsQ/OxlvTkVUXH2r/8cb2M=
|
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/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 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
@@ -92,16 +92,16 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
|||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
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/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.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
|
||||||
github.com/prometheus/client_golang v1.24.1/go.mod h1:F+oSRECHg4sse5ucfYpYDeIv/hu68Zo0uoHKetWnzcE=
|
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
|
||||||
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
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/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
||||||
github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi/PY=
|
github.com/prometheus/common v0.69.0 h1:OA85nJQS/T/MaYh/Q2CcgDKSGWqNIgrBDvDH85CuiNk=
|
||||||
github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc=
|
github.com/prometheus/common v0.69.0/go.mod h1:ZzL3f6u94qUxh9p+tJTrF+FvBS1XXbbRAZCQkytAL0Y=
|
||||||
github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI=
|
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/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.12.0 h1:V0v14Iqfs+MwHWihJt/nGS5Ulu0vw572b2Co3mwunkI=
|
||||||
github.com/rabbitmq/amqp091-go v1.13.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
github.com/rabbitmq/amqp091-go v1.12.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 h1:pMkxYPkEbMPwRdenAzUNyFNrDgHx9U+DrBabWNfSRQs=
|
||||||
github.com/redis/go-redis/v9 v9.18.0/go.mod h1:k3ufPphLU5YXwNTUcCRXGxUoF1fqxnhFQmscfkCoDA0=
|
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 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||||
@@ -123,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/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 h1:EgTchT8VtCYV1iEo/y4jII3/NybrXiQDE0y6pmS350M=
|
||||||
github.com/txix-open/etp/v3 v3.2.0/go.mod h1:lgen0TJmiturgBhvlxH1/PQ7iLL/OebKbxPAQYkuKI0=
|
github.com/txix-open/etp/v3 v3.2.0/go.mod h1:lgen0TJmiturgBhvlxH1/PQ7iLL/OebKbxPAQYkuKI0=
|
||||||
github.com/txix-open/etp/v4 v4.1.3 h1:u9ZyU2yKGgoQ1/DSaElhazWm8xASdqGEdWjoJ2xQlfo=
|
github.com/txix-open/etp/v4 v4.1.1 h1:Yna+0mw/kQZP7Rl6QI4spCrO6qgO8ZhP8PjHlJj2lTU=
|
||||||
github.com/txix-open/etp/v4 v4.1.3/go.mod h1:9GK+Aje8BmLFq8Hk4j6Qb976LdU9WECCWAuLK1vAKgM=
|
github.com/txix-open/etp/v4 v4.1.1/go.mod h1:9GK+Aje8BmLFq8Hk4j6Qb976LdU9WECCWAuLK1vAKgM=
|
||||||
github.com/txix-open/grmq v1.12.0 h1:lSPYvwLfTL0+b0xDQmuuN6RaKS3NCEJNK9ccWpOWa8Y=
|
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/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.71.1 h1:MNSuHy/HEvy7dKPQXkM+dgQpShDhcv1Sq1kLgep2LaA=
|
||||||
github.com/txix-open/isp-kit v1.74.0/go.mod h1:Kob233jk1j/Js7UmopJ5b7JpVZrpWbagEAjasgfqTdk=
|
github.com/txix-open/isp-kit v1.71.1/go.mod h1:j2sj86byoKllCs+DaRWwg56NgcL2omr/bUzmU7+AF74=
|
||||||
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
|
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/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
|
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
|
||||||
@@ -164,8 +164,8 @@ go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRk
|
|||||||
go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA=
|
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 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk=
|
||||||
go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE=
|
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.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g=
|
||||||
go.opentelemetry.io/proto/otlp v1.11.0/go.mod h1:SmVizdCOAm3XBtG1g1NnOdhW6jtddT72hLMhv8VwA8E=
|
go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk=
|
||||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
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/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 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
@@ -190,12 +190,12 @@ 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=
|
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 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||||
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
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-20260630182238-925bb5da69e7 h1:jQ9p21COKWjP3VwuFrNRiiOTMh3mPpN45R7SLrH/HUU=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20260729162451-8efbd57d26e0/go.mod h1:HJ9MpJLeDSstBkx1LILTpd5f41ADSMZcTPypw02qEGw=
|
google.golang.org/genproto/googleapis/api v0.0.0-20260630182238-925bb5da69e7/go.mod h1:KqHwBx2upmfa1XSi1WuRvC+2VGCLtooKkfmyvRbUmqA=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260729162451-8efbd57d26e0 h1:mJiOtnGp0k/BcSgdu03G2NwnscCfCH+h2QKUBZr18KI=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20260724162435-b2f20204f0df h1:O3ig1i5WDDzsVzRp+cCdgelT9vXnlnOFdlEeFtL4HCc=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260729162451-8efbd57d26e0/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20260724162435-b2f20204f0df/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||||
google.golang.org/grpc v1.83.0 h1:JeNZEKJFbQxArAMl+hiytHauacDNqJUllNfmIMmpqnQ=
|
google.golang.org/grpc v1.82.1 h1:NnAxzGRA0677vCa4BUkOAnO5+FfQqVl9iUXeD0IqcGE=
|
||||||
google.golang.org/grpc v1.83.0/go.mod h1:kDyl6SKsiHKt0uylY5gtn5cEjkrIOhQOGDgIc4JGwzQ=
|
google.golang.org/grpc v1.82.1/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA=
|
||||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
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=
|
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/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
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/helpers"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/http/endpoint/buffer"
|
"github.com/txix-open/isp-kit/http/endpoint/buffer"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"isp-gate-service/httperrors"
|
|
||||||
"isp-gate-service/request"
|
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type UserAuthorizer interface {
|
|
||||||
UserAuthorize(ctx *request.Context) (bool, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func UserAuthorize(authorizer UserAuthorizer) Middleware {
|
|
||||||
return func(next Handler) Handler {
|
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
|
||||||
endpointMeta := ctx.EndpointMeta()
|
|
||||||
requiredPerm := endpointMeta.RequiredUserPermission
|
|
||||||
if requiredPerm == "" {
|
|
||||||
return next.Handle(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
userAuthData, err := ctx.GetUserAuthData()
|
|
||||||
if err != nil {
|
|
||||||
return httperrors.New(
|
|
||||||
http.StatusUnauthorized,
|
|
||||||
"user authentication required",
|
|
||||||
errors.Errorf("user authorization: user authentication required for '%s'",
|
|
||||||
endpointMeta.Endpoint,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
ok, err := authorizer.UserAuthorize(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "user authorization: authorize")
|
|
||||||
}
|
|
||||||
if !ok {
|
|
||||||
return httperrors.New(
|
|
||||||
http.StatusForbidden,
|
|
||||||
"endpoint is not allowed",
|
|
||||||
errors.Errorf(
|
|
||||||
"user authorization: endpoint '%s' requires '%s' permission, but user '%s' doesn't have it",
|
|
||||||
endpointMeta.Endpoint, requiredPerm, userAuthData.Identity,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return next.Handle(ctx)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -14,7 +14,7 @@ import (
|
|||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/grpc"
|
"github.com/txix-open/isp-kit/grpc"
|
||||||
"github.com/txix-open/isp-kit/grpc/client"
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
"github.com/txix-open/isp-kit/grpc/isp"
|
"github.com/txix-open/isp-kit/grpc/isp"
|
||||||
|
|||||||
+2
-16
@@ -1,7 +1,6 @@
|
|||||||
package proxy
|
package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
@@ -9,15 +8,15 @@ import (
|
|||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/grpc"
|
"github.com/txix-open/isp-kit/grpc"
|
||||||
"github.com/txix-open/isp-kit/requestid"
|
"github.com/txix-open/isp-kit/requestid"
|
||||||
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -80,9 +79,6 @@ func (p Http) Handle(ctx *request.Context) error {
|
|||||||
errors.WithMessagef(err, "http proxy to %s", host),
|
errors.WithMessagef(err, "http proxy to %s", host),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if ctx.IsJsonUtf8CharsetEnabled() {
|
|
||||||
reverseProxy.ModifyResponse = addJsonUtf8Charset
|
|
||||||
}
|
|
||||||
|
|
||||||
context, cancel := context.WithTimeout(request.Context(), p.timeout)
|
context, cancel := context.WithTimeout(request.Context(), p.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@@ -101,7 +97,6 @@ func setHttpHeaders(ctx *request.Context, header http.Header, skipAuth bool) {
|
|||||||
userAuthData, err := ctx.GetUserAuthData()
|
userAuthData, err := ctx.GetUserAuthData()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for key, values := range userAuthData.ExtraHeaders {
|
for key, values := range userAuthData.ExtraHeaders {
|
||||||
header.Del(key)
|
|
||||||
for _, value := range values {
|
for _, value := range values {
|
||||||
header.Add(key, value)
|
header.Add(key, value)
|
||||||
}
|
}
|
||||||
@@ -129,12 +124,3 @@ func setHttpHeaders(ctx *request.Context, header http.Header, skipAuth bool) {
|
|||||||
func defaultTransportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) {
|
func defaultTransportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) {
|
||||||
return dialer.DialContext
|
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
|
|
||||||
}
|
|
||||||
+1
-1
@@ -7,8 +7,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/tomakado/websocketproxy"
|
"github.com/tomakado/websocketproxy"
|
||||||
"github.com/txix-open/isp-kit/errors"
|
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"isp-gate-service/entity"
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/grpc/client"
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
"isp-gate-service/entity"
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/json"
|
"github.com/txix-open/isp-kit/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/grpc/client"
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
"isp-gate-service/entity"
|
"isp-gate-service/entity"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"isp-gate-service/entity"
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/grpc/client"
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
"isp-gate-service/entity"
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"github.com/txix-open/isp-kit/errors"
|
|
||||||
"github.com/txix-open/isp-kit/json"
|
"github.com/txix-open/isp-kit/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"github.com/txix-open/isp-kit/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type RedisAuthzCache struct {
|
type RedisAuthzCache struct {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"isp-gate-service/entity"
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/http/httpcli"
|
"github.com/txix-open/isp-kit/http/httpcli"
|
||||||
"github.com/txix-open/isp-kit/http/httpclix"
|
"github.com/txix-open/isp-kit/http/httpclix"
|
||||||
"github.com/txix-open/isp-kit/lb"
|
"github.com/txix-open/isp-kit/lb"
|
||||||
@@ -49,31 +49,3 @@ func (r UserAuth) Authenticate(
|
|||||||
}
|
}
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r UserAuth) Authorize(
|
|
||||||
ctx context.Context,
|
|
||||||
method string,
|
|
||||||
identity string,
|
|
||||||
permission string,
|
|
||||||
) (bool, error) {
|
|
||||||
ctx = http_metrics.ClientEndpointToContext(ctx, method)
|
|
||||||
|
|
||||||
host, err := r.lb.Next()
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessage(err, "lb next")
|
|
||||||
}
|
|
||||||
|
|
||||||
endpoint := fmt.Sprintf("http://%s/%s", host, method)
|
|
||||||
resp := entity.UserAuthorizeResponse{}
|
|
||||||
err = r.cli.Post(endpoint).
|
|
||||||
JsonRequestBody(entity.UserAuthorizeRequest{
|
|
||||||
Identity: identity,
|
|
||||||
Permission: permission,
|
|
||||||
}).JsonResponseBody(&resp).
|
|
||||||
StatusCodeToError().
|
|
||||||
DoWithoutResponse(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessagef(err, "http client invoke: %s", endpoint)
|
|
||||||
}
|
|
||||||
return resp.Authorized, nil
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
"isp-gate-service/entity"
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/txix-open/isp-kit/json"
|
"github.com/txix-open/isp-kit/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
package repository
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"isp-gate-service/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
type UserAuthorizationCache struct {
|
|
||||||
duration time.Duration
|
|
||||||
cache *cache.Cache
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewUserAuthorizationCache(duration time.Duration) *UserAuthorizationCache {
|
|
||||||
return &UserAuthorizationCache{
|
|
||||||
duration: duration,
|
|
||||||
cache: cache.New(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r UserAuthorizationCache) Get(ctx context.Context, authorizeEndpoint string, identity string, permission string) (bool, error) {
|
|
||||||
key := r.key(authorizeEndpoint, identity, permission)
|
|
||||||
_, ok := r.cache.Get(key)
|
|
||||||
return ok, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r UserAuthorizationCache) SetAuthorized(ctx context.Context, authorizeEndpoint string, identity string, permission string) error {
|
|
||||||
key := r.key(authorizeEndpoint, identity, permission)
|
|
||||||
r.cache.Set(key, nil, r.duration)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r UserAuthorizationCache) key(authorizeEndpoint string, identity string, permission string) string {
|
|
||||||
return fmt.Sprintf("%s:%s:%s", authorizeEndpoint, identity, permission)
|
|
||||||
}
|
|
||||||
+1
-11
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -30,8 +30,6 @@ type Context struct {
|
|||||||
adminToken string
|
adminToken string
|
||||||
|
|
||||||
queryParams map[string]string
|
queryParams map[string]string
|
||||||
|
|
||||||
httpJsonUtf8Charset bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewContext(
|
func NewContext(
|
||||||
@@ -116,14 +114,6 @@ func (c *Context) SetContext(ctx context.Context) {
|
|||||||
c.request = c.request.WithContext(ctx)
|
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 {
|
func (c *Context) Param(name string) string {
|
||||||
value := c.request.Header.Get(name)
|
value := c.request.Header.Get(name)
|
||||||
if value != "" {
|
if value != "" {
|
||||||
|
|||||||
+1
-3
@@ -8,7 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/cluster"
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
@@ -106,13 +106,11 @@ func (s *Routes) registerEndpoint(
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
requiredAdminPerm, _ := cluster.GetRequiredAdminPermission(descriptor)
|
requiredAdminPerm, _ := cluster.GetRequiredAdminPermission(descriptor)
|
||||||
requiredUserPerm, _ := cluster.GetRequiredUserPermission(descriptor)
|
|
||||||
meta := domain.EndpointMeta{
|
meta := domain.EndpointMeta{
|
||||||
Inner: descriptor.Inner,
|
Inner: descriptor.Inner,
|
||||||
UserAuthRequired: descriptor.UserAuthRequired,
|
UserAuthRequired: descriptor.UserAuthRequired,
|
||||||
ModuleName: moduleName,
|
ModuleName: moduleName,
|
||||||
RequiredAdminPermission: requiredAdminPerm,
|
RequiredAdminPermission: requiredAdminPerm,
|
||||||
RequiredUserPermission: requiredUserPerm,
|
|
||||||
PathSchema: descriptor.Path,
|
PathSchema: descriptor.Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
|||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
"isp-gate-service/entity"
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AdminAuth interface {
|
type AdminAuth interface {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
"isp-gate-service/entity"
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuthenticationCache interface {
|
type AuthenticationCache interface {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"isp-gate-service/entity"
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuthorizationCache interface {
|
type AuthorizationCache interface {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"isp-gate-service/conf"
|
"isp-gate-service/conf"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
"isp-gate-service/conf"
|
"isp-gate-service/conf"
|
||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
"isp-gate-service/entity"
|
"isp-gate-service/entity"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CookieProvider struct {
|
type CookieProvider struct {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserAuthenticationCache interface {
|
type UserAuthenticationCache interface {
|
||||||
@@ -19,14 +19,8 @@ type UserAuthenticationCache interface {
|
|||||||
Set(ctx context.Context, authEndpoint string, token string, data entity.UserAuthData, duration time.Duration) error
|
Set(ctx context.Context, authEndpoint string, token string, data entity.UserAuthData, duration time.Duration) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserAuthorizationCache interface {
|
|
||||||
Get(ctx context.Context, authorizeEndpoint string, identity string, permission string) (bool, error)
|
|
||||||
SetAuthorized(ctx context.Context, authorizeEndpoint string, identity string, permission string) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserAuthenticationRepo interface {
|
type UserAuthenticationRepo interface {
|
||||||
Authenticate(ctx context.Context, authEndpoint string, token string) (*entity.UserAuthenticateResponse, error)
|
Authenticate(ctx context.Context, authEndpoint string, token string) (*entity.UserAuthenticateResponse, error)
|
||||||
Authorize(ctx context.Context, authorizeEndpoint string, identity string, permission string) (bool, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type TokenProvider interface {
|
type TokenProvider interface {
|
||||||
@@ -37,14 +31,12 @@ type TokenProvider interface {
|
|||||||
type userAuthSetting struct {
|
type userAuthSetting struct {
|
||||||
tokenProviders []TokenProvider
|
tokenProviders []TokenProvider
|
||||||
authEndpoint string
|
authEndpoint string
|
||||||
authorizeEndpoint string
|
|
||||||
authCacheDuration time.Duration
|
authCacheDuration time.Duration
|
||||||
skipAppAuth bool
|
skipAppAuth bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserAuthentication struct {
|
type UserAuthentication struct {
|
||||||
cache UserAuthenticationCache
|
cache UserAuthenticationCache
|
||||||
authzCache UserAuthorizationCache
|
|
||||||
repo UserAuthenticationRepo
|
repo UserAuthenticationRepo
|
||||||
settingsByModuleName map[string]userAuthSetting
|
settingsByModuleName map[string]userAuthSetting
|
||||||
}
|
}
|
||||||
@@ -52,7 +44,6 @@ type UserAuthentication struct {
|
|||||||
func NewUserAuthentication(
|
func NewUserAuthentication(
|
||||||
cfg conf.CustomAuth,
|
cfg conf.CustomAuth,
|
||||||
cache UserAuthenticationCache,
|
cache UserAuthenticationCache,
|
||||||
authzCache UserAuthorizationCache,
|
|
||||||
repo UserAuthenticationRepo,
|
repo UserAuthenticationRepo,
|
||||||
) (UserAuthentication, error) {
|
) (UserAuthentication, error) {
|
||||||
tokenProviders := make(map[string]TokenProvider, len(cfg.TokenProviders))
|
tokenProviders := make(map[string]TokenProvider, len(cfg.TokenProviders))
|
||||||
@@ -96,7 +87,6 @@ func NewUserAuthentication(
|
|||||||
settingsByModuleName[moduleName] = userAuthSetting{
|
settingsByModuleName[moduleName] = userAuthSetting{
|
||||||
tokenProviders: settingTokenProviders,
|
tokenProviders: settingTokenProviders,
|
||||||
authEndpoint: setting.AuthenticateEndpoint,
|
authEndpoint: setting.AuthenticateEndpoint,
|
||||||
authorizeEndpoint: setting.AuthorizeEndpoint,
|
|
||||||
authCacheDuration: cacheDuration,
|
authCacheDuration: cacheDuration,
|
||||||
skipAppAuth: setting.SkipAppAuth,
|
skipAppAuth: setting.SkipAppAuth,
|
||||||
}
|
}
|
||||||
@@ -105,7 +95,6 @@ func NewUserAuthentication(
|
|||||||
|
|
||||||
return UserAuthentication{
|
return UserAuthentication{
|
||||||
cache: cache,
|
cache: cache,
|
||||||
authzCache: authzCache,
|
|
||||||
repo: repo,
|
repo: repo,
|
||||||
settingsByModuleName: settingsByModuleName,
|
settingsByModuleName: settingsByModuleName,
|
||||||
}, nil
|
}, nil
|
||||||
@@ -143,58 +132,6 @@ func (s UserAuthentication) Authenticate(ctx *request.Context) (*domain.Authenti
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s UserAuthentication) UserAuthorize(ctx *request.Context) (bool, error) {
|
|
||||||
meta := ctx.EndpointMeta()
|
|
||||||
|
|
||||||
setting, ok := s.settingsByModuleName[meta.ModuleName]
|
|
||||||
if !ok {
|
|
||||||
return false, errors.WithMessagef(domain.ErrUserAuthSettingNotFound,
|
|
||||||
"setting for module '%s' and endpoint '%s' not found",
|
|
||||||
meta.ModuleName, meta.Endpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
userAuthData, err := ctx.GetUserAuthData()
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessage(err, "get user auth data")
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.authorize(
|
|
||||||
ctx.Context(),
|
|
||||||
setting,
|
|
||||||
userAuthData.Identity,
|
|
||||||
meta.RequiredUserPermission,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s UserAuthentication) authorize(
|
|
||||||
ctx context.Context,
|
|
||||||
setting userAuthSetting,
|
|
||||||
identity string,
|
|
||||||
permission string,
|
|
||||||
) (bool, error) {
|
|
||||||
ok, err := s.authzCache.Get(ctx, setting.authorizeEndpoint, identity, permission)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessage(err, "user authz cache get")
|
|
||||||
}
|
|
||||||
if ok {
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
ok, err = s.repo.Authorize(ctx, setting.authorizeEndpoint, identity, permission)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessagef(err, "user authz repo authorize")
|
|
||||||
}
|
|
||||||
if ok {
|
|
||||||
err = s.authzCache.SetAuthorized(ctx, setting.authorizeEndpoint, identity, permission)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessagef(err, "user authz cache set")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ok, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s UserAuthentication) extractToken(ctx *request.Context, providers []TokenProvider) (string, error) {
|
func (s UserAuthentication) extractToken(ctx *request.Context, providers []TokenProvider) (string, error) {
|
||||||
for _, provider := range providers {
|
for _, provider := range providers {
|
||||||
token, err := provider.ExtractToken(ctx)
|
token, err := provider.ExtractToken(ctx)
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync/atomic"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -383,13 +382,11 @@ func (s *HappyPathTestSuite) TestUserAuthorization() { // nolint:funlen
|
|||||||
ModuleNameList: []string{"target"},
|
ModuleNameList: []string{"target"},
|
||||||
TokenProviders: []string{"test_provider"},
|
TokenProviders: []string{"test_provider"},
|
||||||
AuthenticateEndpoint: "test-user-auth/authenticate",
|
AuthenticateEndpoint: "test-user-auth/authenticate",
|
||||||
AuthorizeEndpoint: "test-user-auth/authorize",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ModuleNameList: []string{"target2"},
|
ModuleNameList: []string{"target2"},
|
||||||
TokenProviders: []string{"test_provider"},
|
TokenProviders: []string{"test_provider"},
|
||||||
AuthenticateEndpoint: "failed-user-auth/authenticate",
|
AuthenticateEndpoint: "failed-user-auth/authenticate",
|
||||||
AuthorizeEndpoint: "failed-user-auth/authorize",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -524,14 +521,12 @@ func (s *HappyPathTestSuite) TestUserAuthorization_SkipAppAuth() { // nolint:fun
|
|||||||
ModuleNameList: []string{"target"},
|
ModuleNameList: []string{"target"},
|
||||||
TokenProviders: []string{"test_provider"},
|
TokenProviders: []string{"test_provider"},
|
||||||
AuthenticateEndpoint: "test-user-auth/authenticate",
|
AuthenticateEndpoint: "test-user-auth/authenticate",
|
||||||
AuthorizeEndpoint: "test-user-auth/authorize",
|
|
||||||
SkipAppAuth: true,
|
SkipAppAuth: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ModuleNameList: []string{"target2"},
|
ModuleNameList: []string{"target2"},
|
||||||
TokenProviders: []string{"test_provider"},
|
TokenProviders: []string{"test_provider"},
|
||||||
AuthenticateEndpoint: "test-user-auth/authenticate",
|
AuthenticateEndpoint: "test-user-auth/authenticate",
|
||||||
AuthorizeEndpoint: "test-user-auth/authorize",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -584,163 +579,6 @@ func (s *HappyPathTestSuite) TestUserAuthorization_SkipAppAuth() { // nolint:fun
|
|||||||
require.EqualValues(http.StatusUnauthorized, errResp.StatusCode)
|
require.EqualValues(http.StatusUnauthorized, errResp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *HappyPathTestSuite) TestUserAuthorization_PermissionCheck() { // nolint:funlen
|
|
||||||
test, require := test.New(s.T())
|
|
||||||
config, systemCli, adminCli := s.commonDependencies(test)
|
|
||||||
|
|
||||||
userAuthData := entity.UserAuthData{
|
|
||||||
Identity: "42",
|
|
||||||
IdentityHeader: "x-user-identity",
|
|
||||||
ExtraHeaders: map[string][]string{"x-user-session-token": {"test-session-token"}},
|
|
||||||
}
|
|
||||||
|
|
||||||
targetService, targetCli := grpct.NewMock(test)
|
|
||||||
for _, endpointName := range []string{"perm_ok_endpoint", "no_perm_endpoint"} {
|
|
||||||
targetService.Mock(endpointName, 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}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var authorizeCalls atomic.Int64
|
|
||||||
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("/test-user-auth/authorize",
|
|
||||||
defaultWrapper.Endpoint(func(req entity.UserAuthorizeRequest) entity.UserAuthorizeResponse {
|
|
||||||
authorizeCalls.Add(1)
|
|
||||||
require.Equal(userAuthData.Identity, req.Identity)
|
|
||||||
if req.Permission == "ok_permission" {
|
|
||||||
return entity.UserAuthorizeResponse{Authorized: true}
|
|
||||||
}
|
|
||||||
return entity.UserAuthorizeResponse{}
|
|
||||||
}))
|
|
||||||
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",
|
|
||||||
AuthorizeEndpoint: "test-user-auth/authorize",
|
|
||||||
SkipAppAuth: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
handler, err := locator.Handler(config, locations)
|
|
||||||
require.NoError(err)
|
|
||||||
|
|
||||||
err = routes.ReceiveRoutes(context.Background(), cluster.RoutingConfig{{
|
|
||||||
ModuleName: "target",
|
|
||||||
Endpoints: []cluster.EndpointDescriptor{
|
|
||||||
{
|
|
||||||
Path: "perm_ok_endpoint",
|
|
||||||
Inner: false,
|
|
||||||
UserAuthRequired: true,
|
|
||||||
Extra: cluster.RequireUserPermission("ok_permission"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Path: "perm_bad_endpoint",
|
|
||||||
Inner: false,
|
|
||||||
UserAuthRequired: true,
|
|
||||||
Extra: cluster.RequireUserPermission("bad_permission"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Path: "no_perm_endpoint",
|
|
||||||
Inner: false,
|
|
||||||
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/perm_ok_endpoint").
|
|
||||||
Header("test-token-header", userAuthToken).
|
|
||||||
JsonRequestBody(req).
|
|
||||||
JsonResponseBody(&resp).
|
|
||||||
StatusCodeToError().
|
|
||||||
DoWithoutResponse(s.T().Context())
|
|
||||||
require.NoError(err)
|
|
||||||
require.EqualValues(req.Id, resp.Id)
|
|
||||||
require.EqualValues(int64(1), authorizeCalls.Load())
|
|
||||||
|
|
||||||
err = cli.Post(srv.URL+"/api/perm_bad_endpoint").
|
|
||||||
Header("test-token-header", userAuthToken).
|
|
||||||
JsonRequestBody(req).
|
|
||||||
JsonResponseBody(&resp).
|
|
||||||
StatusCodeToError().
|
|
||||||
DoWithoutResponse(s.T().Context())
|
|
||||||
errResp := httpcli.ErrorResponse{}
|
|
||||||
require.ErrorAs(err, &errResp)
|
|
||||||
require.EqualValues(http.StatusForbidden, errResp.StatusCode)
|
|
||||||
require.EqualValues(int64(2), authorizeCalls.Load())
|
|
||||||
|
|
||||||
err = cli.Post(srv.URL+"/api/no_perm_endpoint").
|
|
||||||
Header("test-token-header", userAuthToken).
|
|
||||||
JsonRequestBody(req).
|
|
||||||
JsonResponseBody(&resp).
|
|
||||||
StatusCodeToError().
|
|
||||||
DoWithoutResponse(s.T().Context())
|
|
||||||
require.NoError(err)
|
|
||||||
require.EqualValues(req.Id, resp.Id)
|
|
||||||
require.EqualValues(int64(2), authorizeCalls.Load())
|
|
||||||
|
|
||||||
err = cli.Post(srv.URL + "/api/perm_ok_endpoint").
|
|
||||||
JsonRequestBody(req).
|
|
||||||
JsonResponseBody(&resp).
|
|
||||||
StatusCodeToError().
|
|
||||||
DoWithoutResponse(s.T().Context())
|
|
||||||
errResp = httpcli.ErrorResponse{}
|
|
||||||
require.ErrorAs(err, &errResp)
|
|
||||||
require.EqualValues(http.StatusUnauthorized, errResp.StatusCode)
|
|
||||||
}
|
|
||||||
|
|
||||||
// nolint:ireturn
|
// nolint:ireturn
|
||||||
func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, *client.Client, *client.Client) {
|
func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, *client.Client, *client.Client) {
|
||||||
config := conf.Remote{
|
config := conf.Remote{
|
||||||
|
|||||||
Reference in new issue
Block a user