Merge branch 'dev' into 'main'

Dev

Closes MSP-7042

See merge request isp/isp-system-service!13
This commit is contained in:
Грязнов Денис Владимирович committed 2026-02-11 13:46:19 +00:00
commit c304645d60
24 files changed
+2709 -1608

No files matched your search

+1 -1
View File
@@ -1 +1 @@
5.6.0
5.7.0
+3
View File
@@ -1,3 +1,6 @@
### v5.7.0
* Обновлены зависимости
* Добавлено поле `http_method` в `access_list`
### v5.6.0
* Для endpoint'а `system/secure/authenticate` в ответ добавлено поле `appName` (название приложения)
* Обновлена версия `go` до `1.25`
+28
View File
@@ -16,6 +16,7 @@ type AccessListService interface {
SetOne(ctx context.Context, request domain.AccessListSetOneRequest) (*domain.AccessListSetOneResponse, error)
SetList(ctx context.Context, req domain.AccessListSetListRequest) ([]domain.MethodInfo, error)
DeleteList(ctx context.Context, req domain.AccessListDeleteListRequest) error
DeleteListWithMethods(ctx context.Context, req domain.AccessListDeleteV2ListRequest) error
}
type AccessList struct {
@@ -141,3 +142,30 @@ func (c AccessList) DeleteList(ctx context.Context, req domain.AccessListDeleteL
return err
}
}
// DeleteListWithMethods godoc
//
// @Tags accessList
// @Summary Удалить список доступных методов для приложения
// @Description Удаляет заданный список методов для приложения
// @Accept json
// @Produce json
// @Param body body domain.AccessListDeleteV2ListRequest false "тело запроса"
// @Success 200 {object} any
// @Failure 404 {object} apierrors.Error
// @Failure 500 {object} apierrors.Error
// @Router /access_list/delete_list_with_methods [POST]
func (c AccessList) DeleteListWithMethods(ctx context.Context, req domain.AccessListDeleteV2ListRequest) error {
err := c.service.DeleteListWithMethods(ctx, req)
switch {
case errors.Is(err, domain.ErrApplicationNotFound):
return apierrors.New(
codes.NotFound,
domain.ErrCodeApplicationNotFound,
fmt.Sprintf("application with id %d not found", req.AppId),
err,
)
default:
return err
}
}
+2 -2
View File
@@ -10,7 +10,7 @@ import (
type SecureService interface {
Authenticate(ctx context.Context, token string) (*domain.AuthData, error)
Authorize(ctx context.Context, appId int, endpoint string) (bool, error)
Authorize(ctx context.Context, req domain.AuthorizeRequest) (bool, error)
}
type Secure struct {
@@ -69,7 +69,7 @@ func (c Secure) Authenticate(ctx context.Context, req domain.AuthenticateRequest
// @Failure 500 {object} apierrors.Error
// @Router /secure/authorize [POST]
func (c Secure) Authorize(ctx context.Context, req domain.AuthorizeRequest) (*domain.AuthorizeResponse, error) {
result, err := c.service.Authorize(ctx, req.ApplicationId, req.Endpoint)
result, err := c.service.Authorize(ctx, req)
switch {
case errors.Is(err, domain.ErrAccessListNotFound):
return &domain.AuthorizeResponse{
+9
View File
@@ -0,0 +1,9 @@
package docs
import _ "embed"
// Embedded swagger files.
var (
//go:embed swagger.json
SwaggerJson []byte
)
+2296
View File
File diff suppressed because it is too large. Load diff
-1454
View File
File diff suppressed because it is too large. Load diff
+17 -5
View File
@@ -1,9 +1,10 @@
package domain
type AccessListSetOneRequest struct {
AppId int `validate:"required"`
Method string `validate:"required"`
Value bool
AppId int `validate:"required"`
HttpMethod string
Method string `validate:"required"`
Value bool
}
type AccessListSetOneResponse struct {
@@ -17,11 +18,22 @@ type AccessListSetListRequest struct {
}
type MethodInfo struct {
Method string
Value bool
HttpMethod string
Method string
Value bool
}
type AccessListDeleteListRequest struct {
AppId int `validate:"required"`
Methods []string `validate:"required,min=1"`
}
type AccessListDeleteV2ListRequest struct {
AppId int `validate:"required"`
Methods []Method `validate:"required,min=1"`
}
type Method struct {
HttpMethod string
Method string `validate:"required"`
}
+2 -1
View File
@@ -19,7 +19,8 @@ type AuthData struct {
}
type AuthorizeRequest struct {
ApplicationId int `validate:"required"`
ApplicationId int `validate:"required"`
HttpMethod string
Endpoint string `validate:"required"`
}
+9 -3
View File
@@ -1,7 +1,13 @@
package entity
type AccessList struct {
AppId int
Method string
Value bool
AppId int
HttpMethod string
Method string
Value bool
}
type Method struct {
HttpMethod string
Method string
}
+27 -27
View File
@@ -4,12 +4,12 @@ go 1.25
require (
github.com/Masterminds/squirrel v1.5.4
github.com/jackc/pgx/v5 v5.7.6
github.com/jackc/pgx/v5 v5.8.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.11.1
github.com/txix-open/isp-kit v1.62.0
github.com/txix-open/isp-kit v1.64.10
github.com/txix-open/jsonschema v1.3.0
google.golang.org/grpc v1.75.1
google.golang.org/grpc v1.78.0
)
require (
@@ -20,15 +20,15 @@ require (
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/gabriel-vasile/mimetype v1.4.10 // indirect
github.com/getsentry/sentry-go v0.35.2 // indirect
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
github.com/getsentry/sentry-go v0.42.0 // indirect
github.com/go-faker/faker/v4 v4.6.1 // indirect
github.com/go-logr/logr v1.4.3 // 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/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.8 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
@@ -38,18 +38,18 @@ require (
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mailru/easyjson v0.9.1 // indirect
github.com/mfridman/interpolate v0.0.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/pressly/goose/v3 v3.25.0 // indirect
github.com/pressly/goose/v3 v3.26.0 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.17.0 // indirect
github.com/prometheus/common v0.67.5 // indirect
github.com/prometheus/procfs v0.19.2 // indirect
github.com/sethvargo/go-retry v0.3.0 // indirect
github.com/txix-open/bellows v1.2.0 // indirect
github.com/txix-open/etp/v4 v4.0.1 // indirect
@@ -58,25 +58,25 @@ 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/auto/sdk v1.2.0 // indirect
go.opentelemetry.io/otel v1.38.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 // indirect
go.opentelemetry.io/otel/metric v1.38.0 // indirect
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect
go.opentelemetry.io/proto/otlp v1.8.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel v1.40.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.40.0 // indirect
go.opentelemetry.io/otel/metric v1.40.0 // indirect
go.opentelemetry.io/otel/sdk v1.40.0 // indirect
go.opentelemetry.io/otel/trace v1.40.0 // indirect
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
go.uber.org/zap v1.27.1 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
golang.org/x/crypto v0.42.0 // indirect
golang.org/x/net v0.44.0 // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/text v0.29.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250908214217-97024824d090 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090 // indirect
google.golang.org/protobuf v1.36.9 // indirect
golang.org/x/crypto v0.48.0 // indirect
golang.org/x/net v0.50.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/text v0.34.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57 // 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
)
+58 -58
View File
@@ -21,10 +21,10 @@ 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/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0=
github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/getsentry/sentry-go v0.35.2 h1:jKuujpRwa8FFRYMIwwZpu83Xh0voll9bmvyc6310WBM=
github.com/getsentry/sentry-go v0.35.2/go.mod h1:mdL49ixwT2yi57k5eh7mpnDyPybixPzlzEJFu0Z76QA=
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.42.0 h1:eeFMACuZTbUQf90RE8dE4tXeSe4CZyfvR1MBL7RLEt8=
github.com/getsentry/sentry-go v0.42.0/go.mod h1:eRXCoh3uvmjQLY6qu63BjUZnaBu5L5WhMV1RwYO8W5s=
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.6.1 h1:xUyVpAjEtB04l6XFY0V/29oR332rOSPWV4lU8RwDt4k=
@@ -50,16 +50,16 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnVTyacbefKhmbLhIhU=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.8 h1:NpbJl/eVbvrGE0MJ6X16X9SAifesl6Fwxg/YmCvubRI=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.8/go.mod h1:mi7YA+gCzVem12exXy46ZespvGtX/lZmD/RLnQhVW7U=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.7.6 h1:rWQc5FwZSPX58r1OQmkuaNicxdmExaEz5A2DO2hUuTk=
github.com/jackc/pgx/v5 v5.7.6/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M=
github.com/jackc/pgx/v5 v5.8.0 h1:TYPDoleBBme0xGSAX3/+NujXXtpZn9HBONkQC7IEZSo=
github.com/jackc/pgx/v5 v5.8.0/go.mod h1:QVeDInX2m9VyzvNeiCJVjCkNFqzsNb43204HshNSZKw=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
@@ -68,8 +68,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/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.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
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=
@@ -84,8 +84,8 @@ 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/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
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/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
@@ -109,16 +109,16 @@ 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/pressly/goose/v3 v3.25.0 h1:6WeYhMWGRCzpyd89SpODFnCBCKz41KrVbRT58nVjGng=
github.com/pressly/goose/v3 v3.25.0/go.mod h1:4hC1KrritdCxtuFsqgs1R4AU5bWtTAf+cnWvfhf2DNY=
github.com/pressly/goose/v3 v3.26.0 h1:KJakav68jdH0WDvoAcj8+n61WqOIaPGgH0bJWS6jpmM=
github.com/pressly/goose/v3 v3.26.0/go.mod h1:4hC1KrritdCxtuFsqgs1R4AU5bWtTAf+cnWvfhf2DNY=
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/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.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs=
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0=
github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw=
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.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws=
github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw=
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/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
@@ -146,8 +146,8 @@ github.com/txix-open/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIg
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
github.com/txix-open/grmq v1.9.0 h1:ArDbJJcFX9zXKEcPf49rp9nYiRyGMJxGKJAxdbSsfaM=
github.com/txix-open/grmq v1.9.0/go.mod h1:EyFOP17KrwEFOUjR+PH8iH3LCtiN9TSQ8t0ysyk62po=
github.com/txix-open/isp-kit v1.62.0 h1:SfY8x5/3yYEicr5phGTJBaUwFvgktSIsD/NubrKYbg4=
github.com/txix-open/isp-kit v1.62.0/go.mod h1:hyCFmWF0qoVY2loTLyHJx8QPZJuULntG0JfthqFCdsA=
github.com/txix-open/isp-kit v1.64.10 h1:lAowLtShBbICZbOWQJ4ptr9LaKKRZ7CE5DBK+7LcLqM=
github.com/txix-open/isp-kit v1.64.10/go.mod h1:GvBsX5p2U3/ugK6PuWANYzSy/4YgawROm3eAKb35G6o=
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=
@@ -161,56 +161,56 @@ 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=
go.opentelemetry.io/auto/sdk v1.2.0 h1:YpRtUFjvhSymycLS2T81lT6IGhcUP+LUPtv0iv1N8bM=
go.opentelemetry.io/auto/sdk v1.2.0/go.mod h1:1deq2zL7rwjwC8mR7XgY2N+tlIl6pjmEUoLDENMEzwk=
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.63.0 h1:2pn7OzMewmYRiNtv1doZnLo3gONcnMHlFnmOR8Vgt+8=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.63.0/go.mod h1:rjbQTDEPQymPE0YnRQp9/NuPwwtL0sesz/fnqRW/v84=
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 h1:GqRJVj7UmLjCVyVJ3ZFLdPRmhDUp2zFmQe3RHIOsw24=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0/go.mod h1:ri3aaHSmCTVYu2AWv44YMauwAQc0aqI9gHKIcSbI1pU=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 h1:aTL7F04bJHUlztTsNGJ2l+6he8c+y/b//eR0jjjemT4=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0/go.mod h1:kldtb7jDTeol0l3ewcmd8SDvx3EmIE7lyvqbasU3QC4=
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=
go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg=
go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM=
go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA=
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
go.opentelemetry.io/proto/otlp v1.8.0 h1:fRAZQDcAFHySxpJ1TwlA1cJ4tvcrw7nXl9xWWC8N5CE=
go.opentelemetry.io/proto/otlp v1.8.0/go.mod h1:tIeYOeNBU4cvmPqpaji1P+KbB4Oloai8wN4rWzRrFF0=
go.opentelemetry.io/otel v1.40.0 h1:oA5YeOcpRTXq6NN7frwmwFR0Cn3RhTVZvXsP4duvCms=
go.opentelemetry.io/otel v1.40.0/go.mod h1:IMb+uXZUKkMXdPddhwAHm6UfOwJyh4ct1ybIlV14J0g=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0 h1:QKdN8ly8zEMrByybbQgv8cWBcdAarwmIPZ6FThrWXJs=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0/go.mod h1:bTdK1nhqF76qiPoCCdyFIV+N/sRHYXYCTQc+3VCi3MI=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.40.0 h1:wVZXIWjQSeSmMoxF74LzAnpVQOAFDo3pPji9Y4SOFKc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.40.0/go.mod h1:khvBS2IggMFNwZK/6lEeHg/W57h/IX6J4URh57fuI40=
go.opentelemetry.io/otel/metric v1.40.0 h1:rcZe317KPftE2rstWIBitCdVp89A2HqjkxR3c11+p9g=
go.opentelemetry.io/otel/metric v1.40.0/go.mod h1:ib/crwQH7N3r5kfiBZQbwrTge743UDc7DTFVZrrXnqc=
go.opentelemetry.io/otel/sdk v1.40.0 h1:KHW/jUzgo6wsPh9At46+h4upjtccTmuZCFAc9OJ71f8=
go.opentelemetry.io/otel/sdk v1.40.0/go.mod h1:Ph7EFdYvxq72Y8Li9q8KebuYUr2KoeyHx0DRMKrYBUE=
go.opentelemetry.io/otel/sdk/metric v1.40.0 h1:mtmdVqgQkeRxHgRv4qhyJduP3fYJRMX4AtAlbuWdCYw=
go.opentelemetry.io/otel/sdk/metric v1.40.0/go.mod h1:4Z2bGMf0KSK3uRjlczMOeMhKU2rhUqdWNoKcYrtcBPg=
go.opentelemetry.io/otel/trace v1.40.0 h1:WA4etStDttCSYuhwvEa8OP8I5EWu24lkOzp+ZYblVjw=
go.opentelemetry.io/otel/trace v1.40.0/go.mod h1:zeAhriXecNGP/s2SEG3+Y8X9ujcJOTqQ5RgdEJcawiA=
go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A=
go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4=
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.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc=
go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts=
golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
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-20250908214217-97024824d090 h1:d8Nakh1G+ur7+P3GcMjpRDEkoLUcLW2iU92XVqR+XMQ=
google.golang.org/genproto/googleapis/api v0.0.0-20250908214217-97024824d090/go.mod h1:U8EXRNSd8sUYyDfs/It7KVWodQr+Hf9xtxyxWudSwEw=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090 h1:/OQuEa4YWtDt7uQWHd3q3sUMb+QOLQUg1xa8CEsRv5w=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090/go.mod h1:GmFNa4BdJZ2a8G+wCe9Bg3wwThLrJun751XstdJt5Og=
google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=
google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57 h1:JLQynH/LBHfCTSbDWl+py8C+Rg/k1OVH3xfcaiANuF0=
google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57/go.mod h1:kSJwQxqmFXeo79zOmbrALdflXQeAYcUbgS7PbpMknCY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57 h1:mWPCjDEyshlQYzBpMNHaEof6UX1PmHcaUODUywQ0uac=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ=
google.golang.org/grpc v1.78.0 h1:K1XZG/yGDJnzMdd/uZHAkVqJE+xIDOcmdSFZkBUicNc=
google.golang.org/grpc v1.78.0/go.mod h1:I47qjTo4OKbMkjA/aOOwxDIiPSBofUtQUI5EfpWvW7U=
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=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
+3 -2
View File
@@ -6,6 +6,7 @@ import (
"isp-system-service/routes"
"github.com/txix-open/isp-kit/bootstrap"
"github.com/txix-open/isp-kit/cluster"
"github.com/txix-open/isp-kit/shutdown"
)
@@ -23,9 +24,9 @@ var (
// @BasePath /api/system
//go:generate swag init --parseDependency
//go:generate rm -f docs/swagger.json docs/docs.go
//go:generate rm -f docs/swagger.yaml docs/docs.go
func main() {
boot := bootstrap.New(version, conf.Remote{}, routes.EndpointDescriptors())
boot := bootstrap.New(version, conf.Remote{}, routes.EndpointDescriptors(), cluster.GrpcTransport)
app := boot.App
logger := app.Logger()
@@ -0,0 +1,36 @@
-- +goose Up
CREATE TABLE access_list_new
(
app_id INT,
http_method VARCHAR(255) NOT NULL DEFAULT '',
method VARCHAR(255),
value BOOLEAN NOT NULL,
PRIMARY KEY (app_id, http_method, method),
CONSTRAINT FK_app_id__application_id FOREIGN KEY (app_id) REFERENCES application (id) ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO access_list_new (app_id, method, value)
SELECT app_id, method, value
FROM access_list
WHERE value = true;
DROP TABLE access_list;
ALTER TABLE access_list_new RENAME TO access_list;
-- +goose Down
CREATE TABLE access_list_old
(
app_id INT,
method VARCHAR(255),
value BOOLEAN NOT NULL,
PRIMARY KEY (app_id, method),
CONSTRAINT FK_app_id__application_id FOREIGN KEY (app_id) REFERENCES application (id) ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO access_list_old (app_id, method, value)
SELECT app_id, method, value
FROM access_list
WHERE value = true;
DROP TABLE access_list;
ALTER TABLE access_list_old RENAME TO access_list;
+51 -23
View File
@@ -11,6 +11,7 @@ import (
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/db"
"github.com/txix-open/isp-kit/db/query"
"github.com/txix-open/isp-kit/metrics/sql_metrics"
)
type AccessList struct {
@@ -23,14 +24,20 @@ func NewAccessList(db db.DB) AccessList {
}
}
func (r AccessList) GetAccessListByAppIdAndMethod(ctx context.Context, appId int, method string) (*entity.AccessList, error) {
func (r AccessList) GetAccessListByAppIdAndMethod(ctx context.Context, appId int, httpMethod string, method string) (*entity.AccessList, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "AccessList.GetAccessListByAppIdAndMethod")
q := `
SELECT app_id, method, value
FROM access_list
WHERE app_id = $1 AND method = $2
`
SELECT app_id, http_method, method, value
FROM access_list
WHERE app_id = $1
AND method = $2
AND http_method IN ($3, '')
ORDER BY (http_method = $3) DESC
LIMIT 1;
`
result := entity.AccessList{}
err := r.db.SelectRow(ctx, &result, q, appId, method)
err := r.db.SelectRow(ctx, &result, q, appId, method, httpMethod)
switch {
case errors.Is(err, sql.ErrNoRows):
return nil, domain.ErrAccessListNotFound
@@ -42,11 +49,13 @@ func (r AccessList) GetAccessListByAppIdAndMethod(ctx context.Context, appId int
}
func (r AccessList) GetAccessListByAppId(ctx context.Context, appId int) ([]entity.AccessList, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "AccessList.GetAccessListByAppId")
q := `
SELECT app_id, method, value
SELECT app_id, http_method, method, value
FROM access_list
WHERE app_id = $1
`
`
result := make([]entity.AccessList, 0)
err := r.db.Select(ctx, &result, q, appId)
if err != nil {
@@ -57,8 +66,10 @@ func (r AccessList) GetAccessListByAppId(ctx context.Context, appId int) ([]enti
}
func (r AccessList) GetAccessListByAppIdList(ctx context.Context, appIdList []int) ([]entity.AccessList, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "AccessList.GetAccessListByAppIdList")
q, args, err := query.New().
Select("app_id", "method", "value").
Select("app_id", "http_method", "method", "value").
From("access_list").
Where(squirrel.Eq{"app_id": appIdList}).
ToSql()
@@ -76,11 +87,13 @@ func (r AccessList) GetAccessListByAppIdList(ctx context.Context, appIdList []in
}
func (r AccessList) InsertArrayAccessList(ctx context.Context, entity []entity.AccessList) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "AccessList.InsertArrayAccessList")
qBuilder := query.New().
Insert("access_list").
Columns("app_id", "method", "value")
Columns("app_id", "http_method", "method", "value")
for _, e := range entity {
qBuilder = qBuilder.Values(e.AppId, e.Method, e.Value)
qBuilder = qBuilder.Values(e.AppId, e.HttpMethod, e.Method, e.Value)
}
q, args, err := qBuilder.ToSql()
if err != nil {
@@ -96,15 +109,17 @@ func (r AccessList) InsertArrayAccessList(ctx context.Context, entity []entity.A
}
func (r AccessList) UpsertAccessList(ctx context.Context, e entity.AccessList) (int, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "AccessList.UpsertAccessList")
q := `
INSERT INTO access_list
(app_id, method, value)
VALUES ($1, $2, $3)
ON CONFLICT (app_id, method)
(app_id, http_method, method, value)
VALUES ($1, $2, $3, $4)
ON CONFLICT (app_id, http_method, method)
DO UPDATE
SET (value) = (SELECT EXCLUDED.value)
`
result, err := r.db.Exec(ctx, q, e.AppId, e.Method, e.Value)
`
result, err := r.db.Exec(ctx, q, e.AppId, e.HttpMethod, e.Method, e.Value)
if err != nil {
return 0, errors.WithMessagef(err, "exec query %s", q)
}
@@ -117,14 +132,25 @@ func (r AccessList) UpsertAccessList(ctx context.Context, e entity.AccessList) (
return int(rowsAffected), nil
}
func (r AccessList) DeleteAccessList(ctx context.Context, appId int, methods []string) error {
func (r AccessList) DeleteAccessList(ctx context.Context, appId int, methods []entity.Method) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "AccessList.DeleteAccessList")
methodsClause := squirrel.Or{}
for _, method := range methods {
methodsClause = append(methodsClause, squirrel.And{
squirrel.Eq{"method": method.Method},
squirrel.Eq{"http_method": method.HttpMethod},
})
}
q, args, err := query.New().
Delete("access_list").
Where(squirrel.Eq{
"app_id": appId,
"method": methods,
Where(squirrel.And{
squirrel.Eq{
"app_id": appId,
},
methodsClause,
}).
Suffix("RETURNING app_id, method, value").
ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
@@ -139,11 +165,13 @@ func (r AccessList) DeleteAccessList(ctx context.Context, appId int, methods []s
}
func (r AccessList) DeleteAccessListByAppId(ctx context.Context, appId int) ([]entity.AccessList, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "AccessList.DeleteAccessListByAppId")
q := `
DELETE FROM access_list
WHERE app_id = $1
RETURNING app_id, method, value
`
RETURNING app_id, http_method, method, value
`
result := make([]entity.AccessList, 0)
err := r.db.Select(ctx, &result, q, appId)
if err != nil {
+21 -4
View File
@@ -12,6 +12,7 @@ import (
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/db"
"github.com/txix-open/isp-kit/db/query"
"github.com/txix-open/isp-kit/metrics/sql_metrics"
)
type AppGroup struct {
@@ -25,11 +26,13 @@ func NewAppGroup(db db.DB) AppGroup {
}
func (r AppGroup) GetAppGroupById(ctx context.Context, id int) (*entity.AppGroup, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.GetAppGroupById")
q := `
SELECT id, name, description, domain_id, created_at, updated_at
FROM application_group
WHERE id = $1
`
`
result := entity.AppGroup{}
err := r.db.SelectRow(ctx, &result, q, id)
switch {
@@ -43,6 +46,8 @@ func (r AppGroup) GetAppGroupById(ctx context.Context, id int) (*entity.AppGroup
}
func (r AppGroup) GetAppGroupByIdList(ctx context.Context, idList []int) ([]entity.AppGroup, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.GetAppGroupByIdList")
q, arg, err := query.New().
Select("id", "name", "description", "domain_id", "created_at", "updated_at").
From("application_group").
@@ -63,6 +68,8 @@ func (r AppGroup) GetAppGroupByIdList(ctx context.Context, idList []int) ([]enti
}
func (r AppGroup) GetAppGroupByDomainId(ctx context.Context, domainIdList []int) ([]entity.AppGroup, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.GetAppGroupByDomainId")
q, arg, err := query.New().
Select("id", "name", "description", "domain_id", "created_at", "updated_at").
From("application_group").
@@ -83,11 +90,13 @@ func (r AppGroup) GetAppGroupByDomainId(ctx context.Context, domainIdList []int)
}
func (r AppGroup) GetAppGroupByNameAndDomainId(ctx context.Context, name string, domainId int) (*entity.AppGroup, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.GetAppGroupByNameAndDomainId")
q := `
SELECT id, name, description, domain_id, created_at, updated_at
FROM application_group
WHERE name = $1 AND domain_id = $2
`
`
result := entity.AppGroup{}
err := r.db.SelectRow(ctx, &result, q, name, domainId)
switch {
@@ -101,13 +110,15 @@ func (r AppGroup) GetAppGroupByNameAndDomainId(ctx context.Context, name string,
}
func (r AppGroup) CreateAppGroup(ctx context.Context, name string, desc string, domainId int) (*entity.AppGroup, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.CreateAppGroup")
q := `
INSERT INTO application_group
(name, description, domain_id)
VALUES ($1, $2, $3)
ON CONFLICT (name, domain_id) DO NOTHING
RETURNING id, name, description, domain_id, created_at, updated_at
`
`
result := entity.AppGroup{}
err := r.db.SelectRow(ctx, &result, q, name, desc, domainId)
switch {
@@ -121,12 +132,14 @@ func (r AppGroup) CreateAppGroup(ctx context.Context, name string, desc string,
}
func (r AppGroup) UpdateAppGroup(ctx context.Context, id int, name string, description string) (*entity.AppGroup, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.UpdateAppGroup")
q := `
UPDATE application_group
SET name = $1, description = $2
WHERE id = $3
RETURNING id, name, description, domain_id, created_at, updated_at
`
`
result := entity.AppGroup{}
err := r.db.SelectRow(ctx, &result, q, name, description, id)
var pgErr *pgconn.PgError
@@ -143,6 +156,8 @@ func (r AppGroup) UpdateAppGroup(ctx context.Context, id int, name string, descr
}
func (r AppGroup) DeleteAppGroup(ctx context.Context, idList []int) (int, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.DeleteAppGroup")
q, args, err := query.New().
Delete("application_group").
Where(squirrel.Eq{"id": idList}).
@@ -165,6 +180,8 @@ func (r AppGroup) DeleteAppGroup(ctx context.Context, idList []int) (int, error)
}
func (r AppGroup) GetAllAppGroups(ctx context.Context) ([]entity.AppGroup, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "AppGroup.GetAllAppGroups")
q, arg, err := query.New().
Select("id", "name", "description", "domain_id", "created_at", "updated_at").
From("application_group").
+34 -7
View File
@@ -12,6 +12,7 @@ import (
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/db"
"github.com/txix-open/isp-kit/db/query"
"github.com/txix-open/isp-kit/metrics/sql_metrics"
)
type Application struct {
@@ -25,11 +26,13 @@ func NewApplication(db db.DB) Application {
}
func (r Application) GetApplicationById(ctx context.Context, id int) (*entity.Application, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Application.GetApplicationById")
q := `
SELECT id, name, description, application_group_id, type, created_at, updated_at
FROM application
WHERE id = $1
`
`
result := entity.Application{}
err := r.db.SelectRow(ctx, &result, q, id)
switch {
@@ -43,6 +46,8 @@ func (r Application) GetApplicationById(ctx context.Context, id int) (*entity.Ap
}
func (r Application) GetApplicationByIdList(ctx context.Context, idList []int) ([]entity.Application, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Application.GetApplicationByIdList")
q, args, err := query.New().
Select("id", "name", "description", "application_group_id", "type", "created_at", "updated_at").
From("application").
@@ -63,6 +68,8 @@ func (r Application) GetApplicationByIdList(ctx context.Context, idList []int) (
}
func (r Application) GetApplicationByAppGroupIdList(ctx context.Context, appGroupIdList []int) ([]entity.Application, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Application.GetApplicationByAppGroupIdList")
q, args, err := query.New().
Select("id", "name", "description", "application_group_id", "type", "created_at", "updated_at").
From("application").
@@ -83,11 +90,13 @@ func (r Application) GetApplicationByAppGroupIdList(ctx context.Context, appGrou
}
func (r Application) GetApplicationByNameAndAppGroupId(ctx context.Context, name string, serviceId int) (*entity.Application, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Application.GetApplicationByNameAndAppGroupId")
q := `
SELECT id, name, description, application_group_id, type, created_at, updated_at
FROM application
WHERE name = $1 AND application_group_id = $2
`
`
result := entity.Application{}
err := r.db.SelectRow(ctx, &result, q, name, serviceId)
switch {
@@ -100,14 +109,22 @@ func (r Application) GetApplicationByNameAndAppGroupId(ctx context.Context, name
}
}
func (r Application) CreateApplication(ctx context.Context, id int, name string, desc string, appGroupId int, appType string) (
*entity.Application, error) {
func (r Application) CreateApplication(
ctx context.Context,
id int,
name string,
desc string,
appGroupId int,
appType string,
) (*entity.Application, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Application.CreateApplication")
q := `
INSERT INTO application
(id, name, description, application_group_id, type)
VALUES ($1, $2, $3, $4, $5)
RETURNING id, name, description, application_group_id, type, created_at, updated_at
`
`
result := entity.Application{}
err := r.db.SelectRow(ctx, &result, q, id, name, desc, appGroupId, appType)
if err != nil {
@@ -122,13 +139,15 @@ func (r Application) UpdateApplication(
name string,
description string,
) (*entity.Application, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Application.UpdateApplication")
q := `
UPDATE application
SET name = $2,
description = $3
WHERE id = $1
RETURNING id, name, description, application_group_id, type, created_at, updated_at
`
`
result := entity.Application{}
err := r.db.SelectRow(ctx, &result, q, id, name, description)
if err != nil {
@@ -144,6 +163,8 @@ func (r Application) UpdateApplicationWithNewId(
name string,
description string,
) (*entity.Application, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Application.UpdateApplicationWithNewId")
q := `
UPDATE application
SET id = $2,
@@ -151,7 +172,7 @@ func (r Application) UpdateApplicationWithNewId(
description = $4
WHERE id = $1
RETURNING id, name, description, application_group_id, type, created_at, updated_at
`
`
result := entity.Application{}
err := r.db.SelectRow(ctx, &result, q, oldId, newId, name, description)
if err != nil {
@@ -161,6 +182,8 @@ func (r Application) UpdateApplicationWithNewId(
}
func (r Application) DeleteApplicationByIdList(ctx context.Context, idList []int) (int, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Application.DeleteApplicationByIdList")
q, args, err := query.New().
Delete("application").
Where(squirrel.Eq{"id": idList}).
@@ -183,6 +206,8 @@ func (r Application) DeleteApplicationByIdList(ctx context.Context, idList []int
}
func (r Application) NextApplicationId(ctx context.Context) (int, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Application.NextApplicationId")
q := `SELECT COALESCE(MAX(id)+1, 1) FROM application;`
nextAppId := 0
err := r.db.SelectRow(ctx, &nextAppId, q)
@@ -193,6 +218,8 @@ func (r Application) NextApplicationId(ctx context.Context) (int, error) {
}
func (r Application) GetAllApplications(ctx context.Context) ([]entity.Application, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Application.GetAllApplications")
q, args, err := query.New().
Select("id", "name", "description", "application_group_id", "type", "created_at", "updated_at").
From("application").
+19 -4
View File
@@ -11,6 +11,7 @@ import (
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/db"
"github.com/txix-open/isp-kit/db/query"
"github.com/txix-open/isp-kit/metrics/sql_metrics"
)
type Domain struct {
@@ -24,11 +25,13 @@ func NewDomain(db db.DB) Domain {
}
func (r Domain) GetDomainById(ctx context.Context, id int) (*entity.Domain, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.GetDomainById")
q := `
SELECT id, name, description, system_id, created_at, updated_at
FROM domain
WHERE id = $1
`
`
result := entity.Domain{}
err := r.db.SelectRow(ctx, &result, q, id)
switch {
@@ -42,6 +45,8 @@ func (r Domain) GetDomainById(ctx context.Context, id int) (*entity.Domain, erro
}
func (r Domain) GetDomainByIdList(ctx context.Context, idList []int) ([]entity.Domain, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.GetDomainByIdList")
q, args, err := query.New().
Select("id", "name", "description", "system_id", "created_at", "updated_at").
From("domain").
@@ -61,12 +66,14 @@ func (r Domain) GetDomainByIdList(ctx context.Context, idList []int) ([]entity.D
}
func (r Domain) GetDomainBySystemId(ctx context.Context, systemId int) ([]entity.Domain, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.GetDomainBySystemId")
q := `
SELECT id, name, description, system_id, created_at, updated_at
FROM domain
WHERE system_id = $1
ORDER BY created_at DESC
`
`
result := make([]entity.Domain, 0)
err := r.db.Select(ctx, &result, q, systemId)
if err != nil {
@@ -77,11 +84,13 @@ func (r Domain) GetDomainBySystemId(ctx context.Context, systemId int) ([]entity
}
func (r Domain) GetDomainByNameAndSystemId(ctx context.Context, name string, systemId int) (*entity.Domain, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.GetDomainByNameAndSystemId")
q := `
SELECT id, name, description, system_id, created_at, updated_at
FROM domain
WHERE name = $1 AND system_id = $2
`
`
result := entity.Domain{}
err := r.db.SelectRow(ctx, &result, q, name, systemId)
switch {
@@ -95,12 +104,14 @@ func (r Domain) GetDomainByNameAndSystemId(ctx context.Context, name string, sys
}
func (r Domain) CreateDomain(ctx context.Context, name string, desc string, systemId int) (*entity.Domain, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.CreateDomain")
q := `
INSERT INTO domain
(name, description, system_id)
VALUES ($1, $2, $3)
RETURNING id, name, description, system_id, created_at, updated_at
`
`
result := entity.Domain{}
err := r.db.SelectRow(ctx, &result, q, name, desc, systemId)
if err != nil {
@@ -110,6 +121,8 @@ func (r Domain) CreateDomain(ctx context.Context, name string, desc string, syst
}
func (r Domain) UpdateDomain(ctx context.Context, id int, name string, description string) (*entity.Domain, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.UpdateDomain")
q := `
UPDATE domain
SET name = $1, description = $2
@@ -129,6 +142,8 @@ func (r Domain) UpdateDomain(ctx context.Context, id int, name string, descripti
}
func (r Domain) DeleteDomain(ctx context.Context, idList []int) (int, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Domain.DeleteDomain")
q, args, err := query.New().
Delete("domain").
Where(squirrel.Eq{"id": idList}).
+13 -2
View File
@@ -11,6 +11,7 @@ import (
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/db"
"github.com/txix-open/isp-kit/db/query"
"github.com/txix-open/isp-kit/metrics/sql_metrics"
)
type Token struct {
@@ -24,12 +25,14 @@ func NewToken(db db.DB) Token {
}
func (r Token) SaveToken(ctx context.Context, token string, appId int, expireTime int) (*entity.Token, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.SaveToken")
q := `
INSERT INTO token
(token, app_id, expire_time)
VALUES ($1, $2, $3)
RETURNING token, app_id, expire_time, created_at
`
`
result := entity.Token{}
err := r.db.SelectRow(ctx, &result, q, token, appId, expireTime)
if err != nil {
@@ -40,11 +43,13 @@ func (r Token) SaveToken(ctx context.Context, token string, appId int, expireTim
}
func (r Token) GetTokenById(ctx context.Context, token string) (*entity.Token, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.GetTokenById")
q := `
SELECT token, app_id, expire_time, created_at
FROM token
WHERE token = $1
`
`
result := entity.Token{}
err := r.db.SelectRow(ctx, &result, q, token)
switch {
@@ -58,6 +63,8 @@ func (r Token) GetTokenById(ctx context.Context, token string) (*entity.Token, e
}
func (r Token) GetTokenByAppIdList(ctx context.Context, appIdList []int) ([]entity.Token, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.GetTokenByAppIdList")
q, args, err := query.New().
Select("token", "app_id", "expire_time", "created_at").
From("token").
@@ -78,6 +85,8 @@ func (r Token) GetTokenByAppIdList(ctx context.Context, appIdList []int) ([]enti
}
func (r Token) DeleteToken(ctx context.Context, tokens []string) (int, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.DeleteToken")
q, args, err := query.New().
Delete("token").
Where(squirrel.Eq{"token": tokens}).
@@ -100,6 +109,8 @@ func (r Token) DeleteToken(ctx context.Context, tokens []string) (int, error) {
}
func (r Token) AuthDataByToken(ctx context.Context, token string) (*entity.AuthData, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Token.AuthDataByToken")
q := `
SELECT system_id, domain_id, application_group_id, app_id, application.name AS app_name , token.expire_time, token.created_at
FROM token
+15
View File
@@ -2,8 +2,10 @@ package routes
import (
"isp-system-service/controller"
"isp-system-service/docs"
"github.com/txix-open/isp-kit/cluster"
"github.com/txix-open/isp-kit/common_endpoints"
"github.com/txix-open/isp-kit/grpc"
"github.com/txix-open/isp-kit/grpc/endpoint"
)
@@ -39,6 +41,7 @@ func endpointDescriptors(c Controllers) []cluster.EndpointDescriptor {
applicationCluster(c),
tokenCluster(c),
applicationGroupCluster(c),
commonEndpoints(),
)
}
@@ -79,6 +82,11 @@ func accessListCluster(c Controllers) []cluster.EndpointDescriptor {
Inner: true,
Handler: c.AccessList.DeleteList,
},
{
Path: "system/access_list/delete_list_with_methods",
Inner: true,
Handler: c.AccessList.DeleteListWithMethods,
},
}
}
@@ -248,6 +256,13 @@ func applicationGroupCluster(c Controllers) []cluster.EndpointDescriptor {
}
}
func commonEndpoints() []cluster.EndpointDescriptor {
return common_endpoints.CommonEndpoints(
"system",
common_endpoints.WithSwaggerEndpoint(docs.SwaggerJson),
)
}
func concatCluster(clusters ...[]cluster.EndpointDescriptor) []cluster.EndpointDescriptor {
var result []cluster.EndpointDescriptor
for _, c := range clusters {
+32 -11
View File
@@ -11,7 +11,7 @@ import (
type AccessListRepo interface {
GetAccessListByAppId(ctx context.Context, appId int) ([]entity.AccessList, error)
DeleteAccessList(ctx context.Context, appId int, methods []string) error
DeleteAccessList(ctx context.Context, appId int, methods []entity.Method) error
}
type AccessListSetOneTx interface {
@@ -21,7 +21,7 @@ type AccessListSetOneTx interface {
type AccessListSetListTx interface {
GetAccessListByAppId(ctx context.Context, appId int) ([]entity.AccessList, error)
InsertArrayAccessList(ctx context.Context, entity []entity.AccessList) error
DeleteAccessList(ctx context.Context, appId int, methods []string) error
DeleteAccessList(ctx context.Context, appId int, methods []entity.Method) error
DeleteAccessListByAppId(ctx context.Context, appId int) ([]entity.AccessList, error)
}
@@ -79,9 +79,10 @@ func (s AccessList) SetOne(ctx context.Context, request domain.AccessListSetOneR
var resp int
err = s.tx.AccessListSetOneTx(ctx, func(ctx context.Context, tx AccessListSetOneTx) error {
resp, err = tx.UpsertAccessList(ctx, entity.AccessList{
AppId: request.AppId,
Method: request.Method,
Value: request.Value,
AppId: request.AppId,
HttpMethod: request.HttpMethod,
Method: request.Method,
Value: request.Value,
})
if err != nil {
return errors.WithMessage(err, "upsert access list")
@@ -113,13 +114,17 @@ func (s AccessList) SetList(ctx context.Context, req domain.AccessListSetListReq
}
newAccessList := make([]entity.AccessList, len(req.Methods))
updateMethods := make([]string, len(req.Methods))
updateMethods := make([]entity.Method, len(req.Methods))
for i, m := range req.Methods {
updateMethods[i] = m.Method
updateMethods[i] = entity.Method{
HttpMethod: m.HttpMethod,
Method: m.Method,
}
newAccessList[i] = entity.AccessList{
AppId: req.AppId,
Method: m.Method,
Value: m.Value,
AppId: req.AppId,
HttpMethod: m.HttpMethod,
Method: m.Method,
Value: m.Value,
}
}
@@ -158,11 +163,27 @@ func (s AccessList) SetList(ctx context.Context, req domain.AccessListSetListReq
}
func (s AccessList) DeleteList(ctx context.Context, req domain.AccessListDeleteListRequest) error {
methods := make([]domain.Method, 0, len(req.Methods))
for _, method := range req.Methods {
methods = append(methods, domain.Method{Method: method})
}
return s.DeleteListWithMethods(ctx, domain.AccessListDeleteV2ListRequest{
AppId: req.AppId,
Methods: methods,
})
}
func (s AccessList) DeleteListWithMethods(ctx context.Context, req domain.AccessListDeleteV2ListRequest) error {
_, err := s.appRepo.GetApplicationById(ctx, req.AppId)
if err != nil {
return errors.WithMessage(err, "get application by id")
}
err = s.accessListRepo.DeleteAccessList(ctx, req.AppId, req.Methods)
methods := make([]entity.Method, 0, len(req.Methods))
for _, method := range req.Methods {
methods = append(methods, entity.Method{Method: method.Method, HttpMethod: method.HttpMethod})
}
err = s.accessListRepo.DeleteAccessList(ctx, req.AppId, methods)
if err != nil {
return errors.WithMessage(err, "delete access_list")
}
+8 -3
View File
@@ -15,7 +15,7 @@ type TokenRep interface {
}
type AccessListRep interface {
GetAccessListByAppIdAndMethod(ctx context.Context, appId int, method string) (*entity.AccessList, error)
GetAccessListByAppIdAndMethod(ctx context.Context, appId int, httpMethod string, method string) (*entity.AccessList, error)
}
type Service struct {
@@ -53,8 +53,13 @@ func (s Service) Authenticate(ctx context.Context, token string) (*domain.AuthDa
}, nil
}
func (s Service) Authorize(ctx context.Context, appId int, endpoint string) (bool, error) {
accessList, err := s.accessListRep.GetAccessListByAppIdAndMethod(ctx, appId, endpoint)
func (s Service) Authorize(ctx context.Context, req domain.AuthorizeRequest) (bool, error) {
accessList, err := s.accessListRep.GetAccessListByAppIdAndMethod(
ctx,
req.ApplicationId,
req.HttpMethod,
req.Endpoint,
)
if err != nil {
return false, errors.WithMessage(err, "get access list by app_id and method")
}
+1 -1
View File
@@ -158,7 +158,7 @@ func (s *ApplicationSuite) TestUpdate_HappyPath() {
inserted := s.insertApps(2)
apiReq := domain.UpdateApplicationRequest{
OldId: inserted[0].Id,
NewId: fake.It[int](),
NewId: inserted[0].Id + inserted[1].Id,
Name: fake.It[string](),
Description: fake.It[string](),
}
+24
View File
@@ -1,6 +1,7 @@
package tests_test
import (
"net/http"
"testing"
"time"
@@ -196,3 +197,26 @@ func (s *SecureSuite) TestAuthorize_NotFound() {
Authorized: false,
}, result)
}
func (s *SecureSuite) TestAuthorize_WithHttpMethod_Success_True() {
InsertAccessList(s.testDb, entity.AccessList{
AppId: 7,
HttpMethod: http.MethodGet,
Method: "endpoint/available_http",
Value: true,
})
result := domain.AuthorizeResponse{}
err := s.api.Invoke("system/secure/authorize").
JsonRequestBody(domain.AuthorizeRequest{
ApplicationId: 7,
HttpMethod: http.MethodGet,
Endpoint: "endpoint/available_http",
}).
JsonResponseBody(&result).
Do(s.T().Context())
s.Require().NoError(err)
s.Require().Equal(domain.AuthorizeResponse{
Authorized: true,
}, result)
}