Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f50fc8806 | ||
|
|
493116999c | ||
|
|
f06db36390 | ||
|
|
4e924575ce | ||
|
|
7abecf78ad | ||
|
|
657d430288 | ||
|
|
d2167d2f07 | ||
|
|
2fb58a7195 | ||
|
|
72f2d37920 | ||
|
|
1a1f764f75 | ||
|
|
fbf10c8722 | ||
|
|
227a2a069d | ||
|
|
cf4979560b | ||
|
|
7d936adaf0 | ||
|
|
a8af70f93c | ||
|
|
d6b8ed5f2d | ||
|
|
81e9195d79 | ||
|
|
c5626b5aca | ||
|
|
e0e3609185 | ||
|
|
6ec6987597 | ||
|
|
ac8a556442 | ||
|
|
5cb927d4dc | ||
|
|
587e369e08 | ||
|
|
87bfa22b52 | ||
|
|
cca6ce0ad1 | ||
|
|
f98ecd049e | ||
|
|
ff560441b2 | ||
|
|
81ece162cc | ||
|
|
48e5315986 | ||
|
|
da38b66d9a | ||
|
|
206e64f9e1 | ||
|
|
1b0651e42f | ||
|
|
215ccbd25b | ||
|
|
1b2b9c5817 | ||
|
|
23a4d94cff | ||
|
|
6186f7bdb5 | ||
|
|
2e0889491d | ||
|
|
3484276256 | ||
|
|
f13c1ced4f | ||
|
|
9d9353cf57 | ||
|
|
a185cb0878 | ||
|
|
41762113e7 | ||
|
|
7cca2eb773 | ||
|
|
eb6326c343 | ||
|
|
b67eb8137c | ||
|
|
8b672bdd30 | ||
|
|
1363935f66 | ||
|
|
77f3311401 | ||
|
|
c523d2347d | ||
|
|
7ff454d6d9 | ||
|
|
7b5ff23615 | ||
|
|
1bd032e5aa | ||
|
|
f160467e77 | ||
|
|
59875487ae | ||
|
|
b692728cc3 | ||
|
|
f5a5e7d8bb | ||
|
|
aae3c28225 | ||
|
|
d417e202e0 | ||
|
|
211b47d21e | ||
|
|
e623018b72 | ||
|
|
56548cbf4d | ||
|
|
e4869135b4 | ||
|
|
40e521462d | ||
|
|
c422de39b4 | ||
|
|
c0bb6fdc7e | ||
|
|
01b6263f29 | ||
|
|
30d731ebfa | ||
|
|
8a0dce574a | ||
|
|
e5e723811e | ||
|
|
56518b86f0 | ||
|
|
6acaf9c7ee | ||
|
|
2ddb3a3d1f | ||
|
|
29cdf42808 | ||
|
|
b2ffc15cfa | ||
|
|
7cb16f87e5 | ||
|
|
63c694e2a3 | ||
|
|
b7028f3c9e | ||
|
|
de80daad81 | ||
|
|
54a3ac5ed4 | ||
|
|
9e6846ac03 | ||
|
|
4f90477e73 | ||
|
|
8b92a460de | ||
|
|
68105a2179 | ||
|
|
1a274e79e5 | ||
|
|
690820b7c4 | ||
|
|
d4f5d7d66f | ||
|
|
e6c241f112 | ||
|
|
2b5ee66527 | ||
|
|
4ddc963481 | ||
|
|
16cdb18f43 | ||
|
|
e9c5c9b805 | ||
|
|
d447bb52bc | ||
|
|
102fa48a92 | ||
|
|
96f8e79d33 | ||
|
|
9b9b66c07c | ||
|
|
abfd06b407 | ||
|
|
325ededd86 | ||
|
|
069881f85f | ||
|
|
fa803e9cac | ||
|
|
a39036a051 | ||
|
|
c3e3ed9636 | ||
|
|
2d8e24ef2b | ||
|
|
566b601c85 | ||
|
|
181edb8823 | ||
|
|
d4a097a7a7 | ||
|
|
5f556dcde3 | ||
|
|
13db082fca | ||
|
|
bebd43dde2 | ||
|
|
b17e4b78aa | ||
|
|
dc61927345 | ||
|
|
5230e9ac42 | ||
|
|
f5bfe7d2ba | ||
|
|
0dfbe57af1 | ||
|
|
a4b6e5fd1d | ||
|
|
14f3c541e4 | ||
|
|
aa704effde | ||
|
|
9f485b5e57 | ||
|
|
52d8504089 | ||
|
|
26691b99de | ||
|
|
f45f62c4b1 | ||
|
|
66e6c4b9c4 | ||
|
|
61f11c0bda | ||
|
|
343f9d0cfa | ||
|
|
cd721daa81 | ||
|
|
e7bfd34e9e | ||
|
|
6491e79afd | ||
|
|
5fed5d7683 | ||
|
|
0c2bcc6cfe | ||
|
|
e56a2b829f | ||
|
|
944c7b7415 | ||
|
|
dbf094afd8 | ||
|
|
b7912dcd9f | ||
|
|
01f8dcdc36 | ||
|
|
dce66f423d | ||
|
|
4f8d2e9ae9 | ||
|
|
1c8ba2d700 | ||
|
|
16a0c66ab7 | ||
|
|
49d1bfaa3f | ||
|
|
c6685ddfb9 | ||
|
|
6a24a7bdd8 | ||
|
|
738146be5c | ||
|
|
357ce03935 | ||
|
|
ce4d8ec165 | ||
|
|
0793b8f90f | ||
|
|
d954b8d828 | ||
|
|
600b3d7808 | ||
|
|
9808e30cb9 | ||
|
|
7acd770e26 | ||
|
|
87af899a0d | ||
|
|
82ac257e91 | ||
|
|
3d22feec9c | ||
|
|
7b5fc0b416 | ||
|
|
576ef18526 | ||
|
|
03df79d7b3 | ||
|
|
136024c387 | ||
|
|
7cd5b507c4 | ||
|
|
02cc03e744 | ||
|
|
1999ea366b | ||
|
|
57e788e7dc | ||
|
|
93482f05d3 | ||
|
|
4898a95fc4 | ||
|
|
95f9e46f45 | ||
|
|
9ec52bd852 | ||
|
|
bf6ba426f6 | ||
|
|
744eaa2605 | ||
|
|
b21f96b8a5 | ||
|
|
45e6d9128b | ||
|
|
7f99b95cea | ||
|
|
ac8cbcef8a | ||
|
|
914e9e1226 | ||
|
|
d09e784ca8 | ||
|
|
875d3985bd | ||
|
|
f9b2632335 | ||
|
|
01159874b8 | ||
|
|
843c6d36c2 | ||
|
|
4480d932e1 | ||
|
|
54292a9597 | ||
|
|
27c825f705 | ||
|
|
0d0cf8f2a0 | ||
|
|
200f65a8ba | ||
|
|
d3624ee87e | ||
|
|
56d3e06e49 | ||
|
|
f6dbff900b | ||
|
|
6683d2dcd0 | ||
|
|
1f40e9d5d3 | ||
|
|
87690bbd12 | ||
|
|
e4892b737f | ||
|
|
f94672569b | ||
|
|
c390fe3948 | ||
|
|
8a83ba0b3a | ||
|
|
402c6c18cf | ||
|
|
0c62aa8b1b | ||
|
|
6ba1761634 | ||
|
|
ca5dc08fbd | ||
|
|
219d4ce382 | ||
|
|
3f88c01417 | ||
|
|
ac7f26f705 | ||
|
|
960ad5a253 | ||
|
|
365bddceda | ||
|
|
7069f43366 | ||
|
|
b938e2f81d | ||
|
|
011cdd022c | ||
|
|
5d2e6753a0 | ||
|
|
82a6d1959a | ||
|
|
c7295c6219 | ||
|
|
1f808ea387 | ||
|
|
9639b312b2 | ||
|
|
7039bf2cf7 | ||
|
|
2f74836b5c | ||
|
|
ed9ba371f7 | ||
|
|
0d430df928 | ||
|
|
037b3bebda | ||
|
|
1fa746c3e9 | ||
|
|
dfbc05cd7d | ||
|
|
0d60ec0798 | ||
|
|
2332737031 | ||
|
|
ae1bba7575 | ||
|
|
716428dd58 | ||
|
|
9e68e9662c | ||
|
|
3483b1f52b | ||
|
|
1d34dc6f2e | ||
|
|
5139158d7a | ||
|
|
3182cefbe2 | ||
|
|
bce6527dc7 | ||
|
|
d430e1e402 | ||
|
|
08c39a9b58 | ||
|
|
f78db86e39 | ||
|
|
02334b3617 | ||
|
|
cbbc03acb9 | ||
|
|
d298485722 | ||
|
|
390bd0423e | ||
|
|
35e9311cc7 | ||
|
|
0e51c54415 | ||
|
|
c650929476 | ||
|
|
2ab43de749 | ||
|
|
01027e6f29 | ||
|
|
2b329d5270 | ||
|
|
0910add54c | ||
|
|
b054257e06 | ||
|
|
614abce93f | ||
|
|
fa9a5b7633 | ||
|
|
9163d0749d | ||
|
|
57dff99bb5 | ||
|
|
8a269cd0e0 | ||
|
|
bb92f0628a | ||
|
|
8adec87573 | ||
|
|
1a1a200173 | ||
|
|
d4f8201bd5 | ||
|
|
2f714b32c8 | ||
|
|
9d400c4158 | ||
|
|
6283cc64a5 | ||
|
|
586752ac8c | ||
|
|
191e48d464 | ||
|
|
5a9fc1a59b | ||
|
|
4175a36bf8 | ||
|
|
203dbcb1bf | ||
|
|
f13e45762b | ||
|
|
aeb297065d | ||
|
|
1cb43ec54d | ||
|
|
4505292943 | ||
|
|
5bf5373056 | ||
|
|
8d2df6364b | ||
|
|
e2b2d05777 | ||
|
|
3c0e0386e1 | ||
|
|
773fbe7883 | ||
|
|
e663429dfe | ||
|
|
61f4d16ef8 | ||
|
|
ff7e47a64e | ||
|
|
d71dc62634 | ||
|
|
0367fa8ac7 | ||
|
|
14995e91dd | ||
|
|
e64a58e85a | ||
|
|
51d9cc0397 | ||
|
|
f9f127f6b9 | ||
|
|
a73b9c119e | ||
|
|
901f350adb | ||
|
|
0b08f532e1 | ||
|
|
2c29a2f0a3 | ||
|
|
71100e8c7b | ||
|
|
fd40a83e83 | ||
|
|
e7a165875d | ||
|
|
cd5e286fb0 | ||
|
|
9408f5d83f | ||
|
|
cd6b4729aa | ||
|
|
5d4729e0c7 | ||
|
|
4b0ff6f627 | ||
|
|
b415ce8acf | ||
|
|
9e205573ea | ||
|
|
6a8c628570 | ||
|
|
83668d944a | ||
|
|
a6c7ff3af3 | ||
|
|
5bda86fe46 | ||
|
|
46f447447b | ||
|
|
2ca358a4ea | ||
|
|
bd4b52e5cc | ||
|
|
ed77144fdf | ||
|
|
963d8a1dfe | ||
|
|
12908ef2dc | ||
|
|
a7e312b066 | ||
|
|
3a526a25cc | ||
|
|
363785db94 | ||
|
|
3999f9c514 | ||
|
|
f2928ddcf7 | ||
|
|
ba2aeaf556 | ||
|
|
1a63a616ee | ||
|
|
668cbb37d2 | ||
|
|
538e9a7aab | ||
|
|
c1dd4b1846 | ||
|
|
266f3cbc20 | ||
|
|
6940b30756 | ||
|
|
3f9d25c217 | ||
|
|
828ac1cd4f | ||
|
|
db3b6aa32f | ||
|
|
39a7899a98 | ||
|
|
39dbeda9d8 | ||
|
|
9307c80b2b | ||
|
|
d9605304d2 | ||
|
|
29ed65b193 | ||
|
|
ad57079fc6 | ||
|
|
6f511ddc53 | ||
|
|
b0f871d032 | ||
|
|
6a150402d2 | ||
|
|
626eda7990 | ||
|
|
d207e56e68 | ||
|
|
be6cce7bd1 | ||
|
|
f71e29f145 | ||
|
|
5157143904 | ||
|
|
0102206734 | ||
|
|
67d0512c6b | ||
|
|
0f002b5633 | ||
|
|
1fdc36d797 | ||
|
|
3fe2126eaa | ||
|
|
f82c264f95 | ||
|
|
104524855c | ||
|
|
468653eba8 | ||
|
|
d6e1356b2a | ||
|
|
97912e5d5a | ||
|
|
eeddba7858 | ||
|
|
63f14564b8 | ||
|
|
ed7a49ef04 | ||
|
|
7b5c6165f2 | ||
|
|
04a07377c1 | ||
|
|
24b22aa7f1 | ||
|
|
05bdf75e95 | ||
|
|
71e78d01e7 | ||
|
|
ed83722c76 | ||
|
|
43679853e7 | ||
|
|
13477fa8ca | ||
|
|
b25956d028 | ||
|
|
f2e9438605 | ||
|
|
0afe95786f | ||
|
|
814d8dc15a | ||
|
|
7db2eb84b5 | ||
|
|
77112d82f8 | ||
|
|
3125d7cd10 | ||
|
|
3608c729f7 | ||
|
|
248801bbf7 | ||
|
|
607ecf629c | ||
|
|
aa3bed6ff8 | ||
|
|
447d719a16 | ||
|
|
e6bdec3f1e | ||
|
|
2d45f210db | ||
|
|
2aff6210b5 | ||
|
|
8d8369b4cc | ||
|
|
b1c16e4901 | ||
|
|
48cbb5c25d | ||
|
|
037c5f3fcd | ||
|
|
8c732a15e2 | ||
|
|
896dd36025 | ||
|
|
f0b8407479 | ||
|
|
c31c6aaf81 | ||
|
|
478b1ce5d7 | ||
|
|
453aa44148 | ||
|
|
9cd697a40d | ||
|
|
97d971fe14 | ||
|
|
68259fa369 | ||
|
|
1794041802 | ||
|
|
72e6bbe6d7 | ||
|
|
665641c88b | ||
|
|
b8d0c8e6d0 | ||
|
|
9a9e941580 | ||
|
|
675a917c0c | ||
|
|
7e10fb5217 | ||
|
|
6d67d3a331 | ||
|
|
e2d45ecdd2 | ||
|
|
61ca62db75 | ||
|
|
e0ab3236d4 | ||
|
|
910fb81a0e | ||
|
|
f1c597bde9 | ||
|
|
f25ded3015 | ||
|
|
3f8e03eda4 | ||
|
|
50a7e32b48 | ||
|
|
df31719324 | ||
|
|
cc5da31e59 | ||
|
|
2d936e543c | ||
|
|
91a14f9f23 | ||
|
|
08c4fb9bee | ||
|
|
dbaa347162 | ||
|
|
78f1fe43b9 | ||
|
|
ab95347767 | ||
|
|
7dd989bac2 | ||
|
|
b9dc101141 | ||
|
|
b3452ef5f6 | ||
|
|
41357efef0 | ||
|
|
b0cac278d2 | ||
|
|
75abb294c0 | ||
|
|
3d02fa550d | ||
|
|
8a9accbdeb | ||
|
|
88bff98d25 | ||
|
|
bdb0c50a22 | ||
|
|
0cf2b61ce3 | ||
|
|
6ec99e8d1f | ||
|
|
a6c1fcb972 | ||
|
|
ed91071557 | ||
|
|
6e1770273e | ||
|
|
5a462ef158 | ||
|
|
a3415470f7 | ||
|
|
909a26eace | ||
|
|
1ffe9e4a62 | ||
|
|
909ff91b2b | ||
|
|
4c7e96813c | ||
|
|
244d8fbdc2 | ||
|
|
745a4ae1e2 | ||
|
|
38806190e7 | ||
|
|
3e593f759d | ||
|
|
0672da8e9c | ||
|
|
bc53089fce | ||
|
|
7a22e3558e | ||
|
|
3c801a4c09 | ||
|
|
b4541f6c1b | ||
|
|
7acc4ebbd6 | ||
|
|
1665cc78cf | ||
|
|
8dcb8eef68 | ||
|
|
37c08f4500 | ||
|
|
8af97e56d7 | ||
|
|
f9138cbbfe | ||
|
|
4d81fe7a26 | ||
|
|
3d2cee1ae8 | ||
|
|
9eb5a3030b | ||
|
|
bad913e339 | ||
|
|
0e3c14d099 | ||
|
|
23ede62f24 | ||
|
|
fc80638b76 | ||
|
|
8f57203d96 | ||
|
|
422bdb9831 | ||
|
|
8c68ffea8c | ||
|
|
f802b2000d | ||
|
|
1a46b678ef | ||
|
|
3d97f3789a | ||
|
|
2a81e83b2e | ||
|
|
1a8ed4e8ea | ||
|
|
e3c3b86b04 | ||
|
|
a9e03750ab | ||
|
|
0edf80ffed | ||
|
|
5b115440f1 | ||
|
|
4fdf7c0ca2 | ||
|
|
f3934e038e | ||
|
|
3461f20510 | ||
|
|
b6baa9e5e7 | ||
|
|
3a4931ca8c | ||
|
|
70f5ebeb4b | ||
|
|
b29f3c6dcd | ||
|
|
fe6f1f5e5a |
No files matched your search
@@ -21,12 +21,7 @@ linters:
|
||||
- wsl_v5 # расставление пробелов очень индивидуально
|
||||
- godoclint # ругается на // nolint, не удобно
|
||||
- prealloc # слишком аггресивный, в большинстве случаев не требуется
|
||||
- gomodguard # deprecated
|
||||
- goconst # слишком агрессивный
|
||||
settings:
|
||||
exhaustruct_v5:
|
||||
allow-empty: true
|
||||
explicit-mode: true
|
||||
cyclop:
|
||||
max-complexity: 15 # по умолчанию 10 мало
|
||||
funlen:
|
||||
|
||||
+3
-8
@@ -1,11 +1,6 @@
|
||||
### v5.11.6
|
||||
* Логирование запросов на незнакомые locations — `warn` `request to unknown location` при включённом `logging.requestLogEnable`
|
||||
* Добавлена настройка `logging.skipLoggingPathPrefixes` — полное отключение логирования запросов для путей с префиксом из списка (лог запросов, `warn` об неизвестном эндпоинте, лог незнакомых locations)
|
||||
* Исправлено `logging.skipBodyLoggingEndpointPrefixes`: значения с ведущим `/` теперь работают и для локаций без `SkipAuth`
|
||||
### v5.11.5
|
||||
* Обновлена версия go до версии 1.27
|
||||
* Обновлены правила для linter
|
||||
* Обновлены зависимости
|
||||
### v5.12.0
|
||||
* добавлена проверка пользовательских прав на эндпоинте: гейт вызывает `authorizeEndpoint` модуля из `userAuthSettings` и возвращает 403, если пользователь не имеет права, объявленного в дескрипторе эндпоинта; положительные результаты кэшируются на `caching.authorizationDataInSec`
|
||||
* добавлена очистка хедеров, совпадающих с хедерами пришедшими в `UserAuthData.ExtraHeaders`, перед добавлением
|
||||
### v5.11.4
|
||||
* добавлена возможность через переменную окружения `adminServiceName` переопределить название сервиса `msp-admin-service`
|
||||
### v5.11.3
|
||||
|
||||
+4
-8
@@ -67,10 +67,12 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
authentication := service.NewAuthentication(authenticationCache, systemRepo)
|
||||
|
||||
userAuthenticationCache := repository.NewUserAuthenticationCache(l.usersAuthCache)
|
||||
userAuthorizationCache := repository.NewUserAuthorizationCache(time.Duration(config.Caching.AuthorizationDataInSec) * time.Second)
|
||||
userAuthRepo := repository.NewUserAuth(l.routerLb)
|
||||
userAuthentication, err := service.NewUserAuthentication(
|
||||
config.CustomAuth,
|
||||
userAuthenticationCache,
|
||||
userAuthorizationCache,
|
||||
userAuthRepo,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -96,8 +98,6 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
skipBodyLoggingEndpointPrefixes = append(skipBodyLoggingEndpointPrefixes, strings.TrimPrefix(prefix, "/"))
|
||||
}
|
||||
|
||||
skipLogging := middleware.NewSkipLoggingPaths(config.Logging.SkipLoggingPathPrefixes)
|
||||
|
||||
mux := mux2.NewRouter()
|
||||
for _, location := range locations {
|
||||
var proxyFunc middleware.Handler
|
||||
@@ -138,13 +138,13 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
middleware.Logger(
|
||||
l.logger, config.Logging.RequestLogEnable,
|
||||
enableBodyLog,
|
||||
skipLogging,
|
||||
skipBodyLoggingEndpointPrefixes,
|
||||
config.Logging.SkipBodyLoggingEndpointPrefixes,
|
||||
config.Logging.EnableForceUnescapingUnicode,
|
||||
),
|
||||
middleware.RequestId(),
|
||||
middleware.ErrorHandler(l.logger),
|
||||
middleware.UserAuthenticate(userAuthentication, l.logger),
|
||||
middleware.UserAuthorize(userAuthentication),
|
||||
middleware.Authenticate(authentication),
|
||||
middleware.AdminAuthenticate(adminService),
|
||||
middleware.ClientRequestId(config.EnableClientRequestIdForwarding, forwardReqIdByAppId),
|
||||
@@ -163,7 +163,6 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
proxyFunc,
|
||||
middleware.Logger(l.logger, config.Logging.RequestLogEnable,
|
||||
enableBodyLog,
|
||||
skipLogging,
|
||||
skipBodyLoggingEndpointPrefixes,
|
||||
config.Logging.EnableForceUnescapingUnicode,
|
||||
),
|
||||
@@ -181,7 +180,6 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
PathPrefix: location.PathPrefix,
|
||||
ErrorOnUnknownEndpoint: errorOnUnknownEndpoint,
|
||||
WithLendingSlash: location.Protocol != conf.GrpcProtocol,
|
||||
SkipLogging: skipLogging,
|
||||
},
|
||||
l.routes,
|
||||
l.logger,
|
||||
@@ -189,7 +187,5 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
mux.PathPrefix(location.PathPrefix).Handler(entrypoint)
|
||||
}
|
||||
|
||||
mux.NotFoundHandler = middleware.UnknownLocation(l.logger, config.Logging.RequestLogEnable, skipLogging)
|
||||
|
||||
return mux, nil
|
||||
}
|
||||
@@ -4,8 +4,7 @@
|
||||
"requestLogEnable": true,
|
||||
"bodyLogEnable": false,
|
||||
"skipBodyLoggingEndpointPrefixes": [],
|
||||
"enableForceUnescapingUnicode": false,
|
||||
"skipLoggingPathPrefixes": []
|
||||
"enableForceUnescapingUnicode": false
|
||||
},
|
||||
"caching": {
|
||||
"authenticationDataInSec": 60,
|
||||
|
||||
+1
-1
@@ -49,7 +49,6 @@ type Logging struct {
|
||||
BodyLogEnable bool `schema:"Включить логирование тел запросов и ответов,должно быть включено логирование запросов"`
|
||||
SkipBodyLoggingEndpointPrefixes []string `schema:"Выключить логирование тел запросов и ответов для путей имеющих префикс из списка,'/' в начале игнорируется"`
|
||||
EnableForceUnescapingUnicode bool `schema:"Включить перевод тел запроса из unicode в utf-8, должно быть включено логирование тел запросов и ответов"`
|
||||
SkipLoggingPathPrefixes []string `schema:"Полностью не логировать запросы к путям с префиксом из списка (сырой path, query не учитывается, '/' в начале игнорируется). Применяется к логу запросов, предупреждению о неизвестном эндпоинте и логу незнакомых locations"`
|
||||
}
|
||||
|
||||
type Caching struct {
|
||||
@@ -97,6 +96,7 @@ type UserAuthSetting struct {
|
||||
ModuleNameList []string `schema:"Название модулей,для которых настраивается аутентификация/авторизация,название модулей должно быть уникальным" validate:"required"`
|
||||
TokenProviders []string `schema:"Список названий методов получения токена из запроса,используется первый провайдер, вернувший токен"`
|
||||
AuthenticateEndpoint string `schema:"Endpoint для аутентификации пользователя,вызывается через isp-router-service" validate:"required"`
|
||||
AuthorizeEndpoint string `schema:"Endpoint для проверки прав пользователя,вызывается через isp-router-service" validate:"required"`
|
||||
CacheDataInSec int `schema:"Время кеширования данных аутентификации/авторизации пользователя,отключен при значениях <=0,в секундах"`
|
||||
SkipAppAuth bool `schema:"Пропустить аутентификацию и авторизацию приложения"`
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ type EndpointMeta struct {
|
||||
|
||||
ModuleName string
|
||||
RequiredAdminPermission string
|
||||
RequiredUserPermission string
|
||||
// Объявляемый сервисом метод
|
||||
PathSchema string
|
||||
// Вызываемый метод
|
||||
|
||||
@@ -15,3 +15,12 @@ type UserAuthData struct {
|
||||
IdentityHeader string
|
||||
ExtraHeaders map[string][]string
|
||||
}
|
||||
|
||||
type UserAuthorizeRequest struct {
|
||||
Identity string
|
||||
Permission string
|
||||
}
|
||||
|
||||
type UserAuthorizeResponse struct {
|
||||
Authorized bool
|
||||
}
|
||||
@@ -1,78 +1,80 @@
|
||||
module isp-gate-service
|
||||
|
||||
go 1.27
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/mux v1.8.1
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/julienschmidt/httprouter v1.3.0
|
||||
github.com/redis/go-redis/v9 v9.18.0
|
||||
github.com/stretchr/testify v1.12.1
|
||||
github.com/stretchr/testify v1.11.1
|
||||
github.com/tomakado/websocketproxy v0.1.0
|
||||
github.com/txix-open/etp/v3 v3.2.0
|
||||
github.com/txix-open/isp-kit v1.76.0
|
||||
github.com/txix-open/isp-kit v1.74.0
|
||||
github.com/txix-open/jsonschema v1.3.0
|
||||
go.uber.org/zap v1.28.0
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f
|
||||
google.golang.org/grpc v1.85.0
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260729162451-8efbd57d26e0
|
||||
google.golang.org/grpc v1.83.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||
github.com/go-faker/faker/v4 v4.10.1 // indirect
|
||||
github.com/klauspost/compress v1.19.1 // indirect
|
||||
github.com/txix-open/etp/v4 v4.1.3 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
golang.org/x/net v0.57.0 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/buger/jsonparser v1.6.1 // indirect
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||
github.com/buger/jsonparser v1.6.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/coder/websocket v1.8.15 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.16 // indirect
|
||||
github.com/getsentry/sentry-go v0.50.0 // indirect
|
||||
github.com/go-faker/faker/v4 v4.12.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.15 // indirect
|
||||
github.com/getsentry/sentry-go v0.48.0 // indirect
|
||||
github.com/go-logr/logr v1.4.4 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-playground/locales v0.14.2 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.2 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.20.4 // indirect
|
||||
github.com/julienschmidt/httprouter v1.3.0
|
||||
github.com/leodido/go-urn v1.5.0 // indirect
|
||||
github.com/mailru/easyjson v0.9.2 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/pandatix/go-abnf v0.5.5 // indirect
|
||||
github.com/prometheus/client_golang v1.25.0 // indirect
|
||||
github.com/prometheus/client_model v0.6.3 // indirect
|
||||
github.com/prometheus/common v0.74.0 // indirect
|
||||
github.com/prometheus/procfs v0.23.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/prometheus/client_golang v1.24.1 // indirect
|
||||
github.com/prometheus/client_model v0.6.2 // indirect
|
||||
github.com/prometheus/common v0.70.1 // indirect
|
||||
github.com/prometheus/procfs v0.21.1 // indirect
|
||||
github.com/txix-open/bellows v1.2.0 // indirect
|
||||
github.com/txix-open/etp/v4 v4.1.3 // indirect
|
||||
github.com/txix-open/validator/v10 v10.0.0-20261027072444-85f3391fc5c3 // indirect
|
||||
github.com/txix-open/etp/v3 v3.2.0
|
||||
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb // indirect
|
||||
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
||||
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.1 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0 // indirect
|
||||
go.opentelemetry.io/otel v1.47.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 // indirect
|
||||
go.opentelemetry.io/otel/log v1.47.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.47.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.47.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.47.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.11.1 // indirect
|
||||
go.uber.org/atomic v1.12.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.69.0 // indirect
|
||||
go.opentelemetry.io/otel v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.44.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.11.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.6 // indirect
|
||||
golang.org/x/crypto v0.59.0 // indirect
|
||||
golang.org/x/net v0.63.0 // indirect
|
||||
golang.org/x/sys v0.50.0 // indirect
|
||||
golang.org/x/text v0.44.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f // indirect
|
||||
google.golang.org/protobuf v1.36.12 // indirect
|
||||
go.uber.org/zap v1.28.0 // indirect
|
||||
golang.org/x/crypto v0.54.0 // indirect
|
||||
golang.org/x/sys v0.47.0 // indirect
|
||||
golang.org/x/text v0.40.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260729162451-8efbd57d26e0 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
@@ -8,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/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||
github.com/buger/jsonparser v1.6.1 h1:I0phFv0PlbLHnM7TZAVjZ2MJ2/eWRTDyuO7GLR98IEs=
|
||||
github.com/buger/jsonparser v1.6.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||
github.com/buger/jsonparser v1.6.0 h1:IHTgLjkgckOjAp8p0aYfXkv+cqC+zrzALg/JywnPjxY=
|
||||
github.com/buger/jsonparser v1.6.0/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
|
||||
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
@@ -18,18 +18,20 @@ github.com/coder/websocket v1.8.15 h1:6B2JPeOGlpff2Uz6vOEH1Vzpi0iUz20A+lPVhPHtNU
|
||||
github.com/coder/websocket v1.8.15/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc=
|
||||
github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE=
|
||||
github.com/gabriel-vasile/mimetype v1.4.16 h1:5izNFuvA37st1dDRAcA7TtmngBmRgiIPDmTtiEvjx1E=
|
||||
github.com/gabriel-vasile/mimetype v1.4.16/go.mod h1:3oFFwxX8kTklZwzIl2aQEDZT0lKY8xH92ST88bAwba4=
|
||||
github.com/getsentry/sentry-go v0.50.0 h1:gkO59rn/i0RCAXUUTflC5QVbTQGPXbaFabs2olVzc9g=
|
||||
github.com/getsentry/sentry-go v0.50.0/go.mod h1:+xsDuN+SoRN/xfs1hdq78wnrE3omIZf+FCuh9FOW1C8=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/gabriel-vasile/mimetype v1.4.15 h1:05iP/CYtZ/w455R/KZM6rZ5ieAdh99UPtd+d3YzLmaI=
|
||||
github.com/gabriel-vasile/mimetype v1.4.15/go.mod h1:azpTcoLcDZRNgFou5j+APrqQx9HqVPWa6ijYQIIVswQ=
|
||||
github.com/getsentry/sentry-go v0.48.0 h1:FRZNr7Uk1C86ev1bSJmYlUkL9oyivQA6YOcdYfaaMmY=
|
||||
github.com/getsentry/sentry-go v0.48.0/go.mod h1:E5UkA5wp1qR2+MDydNYlVeUiNN2xEdjYMidkgf0Qoss=
|
||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
||||
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
||||
github.com/go-faker/faker/v4 v4.12.0 h1:yZXxuoQjxN+C2PVgYoDSHGiD9wj6dX1/Ful4p7QQV0k=
|
||||
github.com/go-faker/faker/v4 v4.12.0/go.mod h1:VFIEwWDd16EdYDLF6NJ5gAAzEp7vz5LgKgJ2iZ17Tdg=
|
||||
github.com/go-faker/faker/v4 v4.10.1 h1:mGH3y0X8AfrXsfgPsPuTkWBYIebomvdkWEN1uDLoFFg=
|
||||
github.com/go-faker/faker/v4 v4.10.1/go.mod h1:VFIEwWDd16EdYDLF6NJ5gAAzEp7vz5LgKgJ2iZ17Tdg=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
|
||||
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
@@ -37,10 +39,12 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.2 h1:d8UmcrM6Nip0hfGZKLGpAvZH37XB4TS0xzK9B56YNCY=
|
||||
github.com/go-playground/locales v0.14.2/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.2 h1:LCsMLC9RzmbUMNUPVYD15dmcjwYAJhmX8mPZRW4rAVU=
|
||||
github.com/go-playground/universal-translator v0.18.2/go.mod h1:67VZIMp5lQpDWlnStOct22q1bkdJGJqHghbOtmkawxk=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-resty/resty/v2 v2.17.2 h1:FQW5oHYcIlkCNrMD2lloGScxcHJ0gkjshV3qcQAyHQk=
|
||||
github.com/go-resty/resty/v2 v2.17.2/go.mod h1:kCKZ3wWmwJaNc7S29BRtUhJwy7iqmn+2mLtQrOyQlVA=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
@@ -52,14 +56,14 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 h1:vzlTzzi4tHLa/JQdIE5LeXw6SEX5EVVhq/VPqKHnKOk=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0/go.mod h1:FHXQZnW5pA0txiMr3jApv9uNJzZ+7mYZd+u+PPenCFU=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 h1:5VipnvEpbqr2gA2VbM+nYVbkIF28c5ZQfqCBQ5g2xfk=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0/go.mod h1:Hyl3n6Twe1hvtd9XUXDec4pTvgMSEixRuQKPTMH2bNs=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/klauspost/compress v1.20.4 h1:dD0v/bvxtjCBqQu6sx1TNWkalEY5lNTIe+HY9w8TeNI=
|
||||
github.com/klauspost/compress v1.20.4/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||
github.com/klauspost/compress v1.19.1 h1:VsB4HPswih7mmZ8WleSFQ75c/Ui1M4trX5oAsJnhSlk=
|
||||
github.com/klauspost/compress v1.19.1/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
@@ -81,23 +85,23 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/pandatix/go-abnf v0.5.5 h1:EXex5KkRQx4Dm6GnpAcQnIMBs9KiK0uf8p/wq+4t9PM=
|
||||
github.com/pandatix/go-abnf v0.5.5/go.mod h1:AE0KD3/VNoCjGzc1gqetRKshbI4SYErXQ/8kPenR5mc=
|
||||
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
|
||||
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.25.0 h1:cDtW1TcFsMi1RJc8khwCKB4VhzwV04aKqbYtNOXuiK0=
|
||||
github.com/prometheus/client_golang v1.25.0/go.mod h1:j2X/4/kaQHLPnmyEU8zjmkndo1T317VpCIQEml8LTKk=
|
||||
github.com/prometheus/client_model v0.6.3 h1:O0jaTVAYNxTHYInEPFJt5I3+sN8zqBtVMPTB1qyxiEo=
|
||||
github.com/prometheus/client_model v0.6.3/go.mod h1:gpN5P9S7Rr6Yr92PiQ+Ixvhf6JZEkF1dnxsYL2aPBEM=
|
||||
github.com/prometheus/common v0.74.0 h1:6iYW8MsYvmEnXFD9zLGgF0qmReaRhs3OMONu1c/nrLI=
|
||||
github.com/prometheus/common v0.74.0/go.mod h1:i/02C+FCst5B1etKgWesNrD49n+onplJCqUCtUKkOeA=
|
||||
github.com/prometheus/procfs v0.23.0 h1:ad+S6FTkzwaMgacKLM5h6bNKExS+DMH0YiUwXItH/o4=
|
||||
github.com/prometheus/procfs v0.23.0/go.mod h1:3AVXO0FqLafyYFU/V/IQRZlC8Rgqz8Dm/x6pKLK+RIk=
|
||||
github.com/rabbitmq/amqp091-go v1.17.0 h1:6KmTqrnJq93cGIE3Q3UnXgsqw6NtLu8MNfFoIbfBAIQ=
|
||||
github.com/rabbitmq/amqp091-go v1.17.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.24.1 h1:JnJkREXzWxUdCuPFpIWZiPispT9xVV59uiuyR2bPlnU=
|
||||
github.com/prometheus/client_golang v1.24.1/go.mod h1:F+oSRECHg4sse5ucfYpYDeIv/hu68Zo0uoHKetWnzcE=
|
||||
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
||||
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
||||
github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi/PY=
|
||||
github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc=
|
||||
github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI=
|
||||
github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY=
|
||||
github.com/rabbitmq/amqp091-go v1.13.0 h1:L8NA1WtF76C6KA3LAoufjfLgbist/If1UQYcsOjtxXA=
|
||||
github.com/rabbitmq/amqp091-go v1.13.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
||||
github.com/redis/go-redis/v9 v9.18.0 h1:pMkxYPkEbMPwRdenAzUNyFNrDgHx9U+DrBabWNfSRQs=
|
||||
github.com/redis/go-redis/v9 v9.18.0/go.mod h1:k3ufPphLU5YXwNTUcCRXGxUoF1fqxnhFQmscfkCoDA0=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
@@ -111,8 +115,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
|
||||
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/tomakado/websocketproxy v0.1.0 h1:e037TLXDvEYYHlxHE5pqmj/DytFKm2NRn7i4wbVzIyE=
|
||||
github.com/tomakado/websocketproxy v0.1.0/go.mod h1:EXg/3jcTJYZ04Hsf93RpY90FYA9lj1Sl+VM7lZI6xpM=
|
||||
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
|
||||
@@ -123,12 +127,12 @@ github.com/txix-open/etp/v4 v4.1.3 h1:u9ZyU2yKGgoQ1/DSaElhazWm8xASdqGEdWjoJ2xQlf
|
||||
github.com/txix-open/etp/v4 v4.1.3/go.mod h1:9GK+Aje8BmLFq8Hk4j6Qb976LdU9WECCWAuLK1vAKgM=
|
||||
github.com/txix-open/grmq v1.12.0 h1:lSPYvwLfTL0+b0xDQmuuN6RaKS3NCEJNK9ccWpOWa8Y=
|
||||
github.com/txix-open/grmq v1.12.0/go.mod h1:6m9CCTQao/HAFalu5rFOZGJ5KLEP6WzzIwj80Ml3KGE=
|
||||
github.com/txix-open/isp-kit v1.76.0 h1:kqhX2DuoTfeW7BIshedG26TRIfOgX0QOInm606ssGVg=
|
||||
github.com/txix-open/isp-kit v1.76.0/go.mod h1:hR9iAlh3x9gEg5GfALrrkN/2SbGkgZQCmwO2GZWjC1M=
|
||||
github.com/txix-open/isp-kit v1.74.0 h1:Gi1X8Jnf9ppV4TXq4kMCBgBjJjqSKh57X8038I+tQFw=
|
||||
github.com/txix-open/isp-kit v1.74.0/go.mod h1:Kob233jk1j/Js7UmopJ5b7JpVZrpWbagEAjasgfqTdk=
|
||||
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
|
||||
github.com/txix-open/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
||||
github.com/txix-open/validator/v10 v10.0.0-20261027072444-85f3391fc5c3 h1:1jE11HLmMHDYYAcE+UmQ5VHgz4stzz0+daJbDWS+sEs=
|
||||
github.com/txix-open/validator/v10 v10.0.0-20261027072444-85f3391fc5c3/go.mod h1:Yf41v210LFyYAj+tGmDh7PHdGsTaZjdBzHG0ptUvihw=
|
||||
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/go.mod h1:0biAFE0bgbcKeBBAwgEDhbZz6uT1vuSETCrFQlv2RiA=
|
||||
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
||||
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||
@@ -142,60 +146,58 @@ github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
|
||||
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0 h1:jva1c3z2ZFEQ5sTvnLG2tBALNehO+QvdXKQii6eKRoo=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0/go.mod h1:3pjFS5EnOVfjvYO6/NMdtJFHFQR+8uiGtrZ965nZP4w=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 h1:LxwW/9ctSCv+QkE/cLR7M91ZIkXNMqJtEMi1vCw9U8s=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0/go.mod h1:tOsftB4SslBwwErVEPaenU2RpThXWPIU8DoJHEC4dyw=
|
||||
go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM=
|
||||
go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 h1:julhjPeUH/q/7hinbSdDdqt5h7Zw9YWmRlWRhI0jd54=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0/go.mod h1:Ao2mz688LH/tFf0yMAenidq6k2YNSx6SIY2q6jDACck=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 h1:aXZXsZ012wOgVkqaiQv+Z/d8V0xKjmg70F6m4CE94lc=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0/go.mod h1:ziu1gUIJhAaxM3EV1e3Ralk5AAyL1UOYz3lJJ4VSI38=
|
||||
go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI=
|
||||
go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw=
|
||||
go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY=
|
||||
go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU=
|
||||
go.opentelemetry.io/otel/sdk v1.47.0 h1:zWXEr4j2lFefG87TU6Yg8a7ngfohIKFZHKp0Hf5hC6I=
|
||||
go.opentelemetry.io/otel/sdk v1.47.0/go.mod h1:VUc24kiOeoGsxG8G9ULx3fWKvB7jMhnGE8Oi607lgR0=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.47.0 h1:lfISg2j93VT6yqdk9OfUaZmw/GfcZqCCV3jdXtsPnKw=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.47.0/go.mod h1:ypLp+mW1Nt2x+Szt3b5/i1syodyts49lMOwxpDI3VGw=
|
||||
go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM=
|
||||
go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0=
|
||||
go.opentelemetry.io/proto/otlp v1.11.1 h1:SCrPqH9NE5CmBrOqpjNCiT0X5mGwMyGERXdogfR7Yjw=
|
||||
go.opentelemetry.io/proto/otlp v1.11.1/go.mod h1:wq8W4aSf6bOy8RZyESOeQFr9Pu7wydWX/TY4sgvrTPg=
|
||||
go.uber.org/atomic v1.12.0 h1:BvcXdFKuviU4fTL/f+SxdQ5qJX/Jix8pAkgdUcb3XOE=
|
||||
go.uber.org/atomic v1.12.0/go.mod h1:I6c4cg+6HCxRjfjSsYtApoFILnpc0CGUdGkXVqbYVNk=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.69.0 h1:MCcYL7J6Vt/X0kjqbMZkekCmwsurbQRbL69vkiye2lk=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.69.0/go.mod h1:3jnStNwSufK+f5ktjL4EPcwtig4rtd81NS70lqHuXl8=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 h1:8tvICD4vSTOOsNrsI4Ljf6C+6UKvpTEH5XY3JMoyPoo=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0/go.mod h1:z9+yiacE0IHRqM4qFfkbt/JYlmYXgss8GY/jXoNuPJI=
|
||||
go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU=
|
||||
go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0 h1:4YsVu3B8+3qtWYYrsUYgn0OG78pN0rnNPRGX4SbokQI=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0/go.mod h1:+wnlSn0mD1ADVMe3v9Z/WIaiz6q6gL2J/ejaAmdmv80=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.44.0 h1:lgh3PiVrRUWMLOVSkQicxzZll5NjF1r+AtsX1XRIHw0=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.44.0/go.mod h1:5Cnhth3m/AgOeTgE3ex12pPmiu/gGtZit03kSzx9X7s=
|
||||
go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc=
|
||||
go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo=
|
||||
go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58=
|
||||
go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA=
|
||||
go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk=
|
||||
go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE=
|
||||
go.opentelemetry.io/proto/otlp v1.11.0 h1:5rrYs0Ykyj50sdU/JU0x8etU+LubXWb+gED6TbEdMIk=
|
||||
go.opentelemetry.io/proto/otlp v1.11.0/go.mod h1:SmVizdCOAm3XBtG1g1NnOdhW6jtddT72hLMhv8VwA8E=
|
||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo=
|
||||
go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q=
|
||||
go.yaml.in/yaml/v2 v2.4.5 h1:a5nxWvYi94DRl6QSLlTbLpVmutgx2qg8EVjnJtuFpwI=
|
||||
go.yaml.in/yaml/v2 v2.4.5/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
|
||||
go.yaml.in/yaml/v3 v3.0.6 h1:zcDfvjXEqTQmpjniUBLc91xYJMB2c4QOFxEF/LCEckM=
|
||||
go.yaml.in/yaml/v3 v3.0.6/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
||||
golang.org/x/crypto v0.59.0 h1:xS2jhqYbzNrpvkWP2YTDf4TJwBy3ykR03i8vFDxEc7c=
|
||||
golang.org/x/crypto v0.59.0/go.mod h1:veDyUwATGs3c+vN3VfTbzViMGXeTBk3WyhBOkn+F/4U=
|
||||
golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0=
|
||||
golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig=
|
||||
golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs=
|
||||
golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
|
||||
golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
|
||||
golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
|
||||
go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ=
|
||||
go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
|
||||
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw=
|
||||
golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk=
|
||||
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
|
||||
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
|
||||
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
||||
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
|
||||
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
|
||||
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f h1:7CbYDSDM5xqpq8v2tNm+Q057COf1lvA0gorVk+304tY=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f/go.mod h1:CPxXEEQ1S9iJmInAF/8MNc8tKWnya8I8Kni9Zh2hV0M=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f h1:aDW6Vb2T1K0xbAgW+ED8iz39WlgjjX/OKiNh6tXv/+g=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc=
|
||||
google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw=
|
||||
google.golang.org/grpc v1.85.0/go.mod h1:0rQrOD58yjal/0EaVbGBANindixsCZNQPDV3VKtaKuQ=
|
||||
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
|
||||
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260729162451-8efbd57d26e0 h1:ybvH/ZpOcpCrjtkb7oW/fdlzbEmRVeumw19SRQmNFKU=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260729162451-8efbd57d26e0/go.mod h1:HJ9MpJLeDSstBkx1LILTpd5f41ADSMZcTPypw02qEGw=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260729162451-8efbd57d26e0 h1:mJiOtnGp0k/BcSgdu03G2NwnscCfCH+h2QKUBZr18KI=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260729162451-8efbd57d26e0/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||
google.golang.org/grpc v1.83.0 h1:JeNZEKJFbQxArAMl+hiytHauacDNqJUllNfmIMmpqnQ=
|
||||
google.golang.org/grpc v1.83.0/go.mod h1:kDyl6SKsiHKt0uylY5gtn5cEjkrIOhQOGDgIc4JGwzQ=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
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=
|
||||
|
||||
+10
-13
@@ -14,7 +14,6 @@ type EntryPointConfig struct {
|
||||
WithPrefix bool
|
||||
ErrorOnUnknownEndpoint bool
|
||||
WithLendingSlash bool
|
||||
SkipLogging SkipLoggingPaths
|
||||
}
|
||||
|
||||
type EndpointResolver interface {
|
||||
@@ -34,18 +33,16 @@ func Entrypoint(
|
||||
|
||||
endpoint, err := entryPointResolver.ResolveEndpoint(req.Method, req.URL.Path, cfg)
|
||||
if err != nil {
|
||||
if !cfg.SkipLogging.ShouldSkip(req.URL.Path) {
|
||||
lookupPath, endpoint := entryPointResolver.GetPaths(req.URL.Path, cfg)
|
||||
logger.Warn(
|
||||
req.Context(),
|
||||
"call unknown method",
|
||||
log.String("pathPrefix", cfg.PathPrefix),
|
||||
log.String("httpMethod", req.Method),
|
||||
log.String("originalPath", req.URL.Path),
|
||||
log.String("lookupPath", lookupPath),
|
||||
log.String("enpoint", endpoint),
|
||||
)
|
||||
}
|
||||
lookupPath, endpoint := entryPointResolver.GetPaths(req.URL.Path, cfg)
|
||||
logger.Warn(
|
||||
req.Context(),
|
||||
"call unknown method",
|
||||
log.String("pathPrefix", cfg.PathPrefix),
|
||||
log.String("httpMethod", req.Method),
|
||||
log.String("originalPath", req.URL.Path),
|
||||
log.String("lookupPath", lookupPath),
|
||||
log.String("enpoint", endpoint),
|
||||
)
|
||||
|
||||
http.Error(writer, err.Error(), http.StatusNotImplemented)
|
||||
return
|
||||
|
||||
@@ -54,7 +54,6 @@ func Logger( // nolint:gocognit,funlen
|
||||
logger log.Logger,
|
||||
enableRequestLogging bool,
|
||||
enableBodyLogging bool,
|
||||
skipLogging SkipLoggingPaths,
|
||||
skipBodyLoggingEndpointPrefixes []string,
|
||||
enableForceUnescapingUnicode bool,
|
||||
) Middleware {
|
||||
@@ -66,10 +65,6 @@ func Logger( // nolint:gocognit,funlen
|
||||
|
||||
r := ctx.Request()
|
||||
|
||||
if skipLogging.ShouldSkip(r.URL.Path) {
|
||||
return next.Handle(ctx)
|
||||
}
|
||||
|
||||
endpoint := ctx.EndpointMeta().NormalizedEndpoint
|
||||
logBodyFromCurrenRequest := enableBodyLogging
|
||||
if logBodyFromCurrenRequest {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"slices"
|
||||
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
@@ -18,10 +16,10 @@ func (f HandlerFunc) Handle(ctx *request.Context) error {
|
||||
|
||||
type Middleware func(next Handler) Handler
|
||||
|
||||
//nolint:ireturn // Chain по определению возвращает Handler-интерфейс
|
||||
// nolint:ireturn
|
||||
func Chain(root Handler, middlewares ...Middleware) Handler {
|
||||
for _, m := range slices.Backward(middlewares) {
|
||||
root = m(root)
|
||||
for i := len(middlewares) - 1; i >= 0; i-- {
|
||||
root = middlewares[i](root)
|
||||
}
|
||||
return root
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import "strings"
|
||||
|
||||
// SkipLoggingPaths — префиксы сырого request path, для которых
|
||||
// полностью отключено логирование (строка лога, не только тела).
|
||||
type SkipLoggingPaths struct {
|
||||
prefixes []string
|
||||
}
|
||||
|
||||
// NewSkipLoggingPaths нормализует значения конфы: обрезает ведущий '/',
|
||||
// отбрасывает пустые.
|
||||
func NewSkipLoggingPaths(rawPrefixes []string) SkipLoggingPaths {
|
||||
prefixes := make([]string, 0, len(rawPrefixes))
|
||||
for _, p := range rawPrefixes {
|
||||
p = strings.TrimPrefix(p, "/")
|
||||
if p != "" {
|
||||
prefixes = append(prefixes, p)
|
||||
}
|
||||
}
|
||||
return SkipLoggingPaths{prefixes: prefixes}
|
||||
}
|
||||
|
||||
// ShouldSkip — case-sensitive prefix-match. path — сырой r.URL.Path.
|
||||
func (s SkipLoggingPaths) ShouldSkip(path string) bool {
|
||||
path = strings.TrimPrefix(path, "/")
|
||||
for _, p := range s.prefixes {
|
||||
if strings.HasPrefix(path, p) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package middleware_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"isp-gate-service/middleware"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSkipLoggingPaths_ShouldSkip(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
prefixes []string
|
||||
path string
|
||||
wantSkip bool
|
||||
}{
|
||||
{name: "prefix without leading slash", prefixes: []string{"health"}, path: "/health", wantSkip: true},
|
||||
{name: "prefix with leading slash is equivalent", prefixes: []string{"/health"}, path: "/health", wantSkip: true},
|
||||
{name: "no match", prefixes: []string{"health"}, path: "/other", wantSkip: false},
|
||||
{name: "empty value is discarded", prefixes: []string{""}, path: "/health", wantSkip: false},
|
||||
{name: "root slash value is discarded", prefixes: []string{"/"}, path: "/health", wantSkip: false},
|
||||
{name: "case sensitive", prefixes: []string{"Health"}, path: "/health/x", wantSkip: false},
|
||||
{name: "plain prefix matches longer name", prefixes: []string{"health"}, path: "/healthz", wantSkip: true},
|
||||
{name: "plain prefix matches nested path", prefixes: []string{"health"}, path: "/health/x", wantSkip: true},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
matcher := middleware.NewSkipLoggingPaths(test.prefixes)
|
||||
require.Equal(t, test.wantSkip, matcher.ShouldSkip(test.path))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSkipLoggingPaths_ShouldSkip_EmptyList(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
matcher := middleware.NewSkipLoggingPaths(nil)
|
||||
for _, path := range []string{"/", "/health", "/health/x", "/unknown"} {
|
||||
require.False(t, matcher.ShouldSkip(path))
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
)
|
||||
|
||||
// UnknownLocation — catch-all для запросов, не попавших ни в один location.
|
||||
// Warn пишется при включённом логировании запросов (как у log request).
|
||||
func UnknownLocation(logger log.Logger, enableRequestLogging bool, skipLogging SkipLoggingPaths) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if enableRequestLogging && !skipLogging.ShouldSkip(r.URL.Path) {
|
||||
logger.Warn(r.Context(), "request to unknown location",
|
||||
log.String("httpMethod", r.Method),
|
||||
log.String("path", r.URL.Path),
|
||||
log.String("remoteAddr", r.RemoteAddr),
|
||||
log.String("xForwardedFor", r.Header.Get("X-Forwarded-For")),
|
||||
log.String("userAgent", r.Header.Get("User-Agent")),
|
||||
log.Int("statusCode", http.StatusNotFound),
|
||||
)
|
||||
}
|
||||
|
||||
// Ответ идентичен текущему дефолтному NotFoundHandler gorilla/mux
|
||||
http.Error(w, "404 page not found", http.StatusNotFound)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,7 @@ func setHttpHeaders(ctx *request.Context, header http.Header, skipAuth bool) {
|
||||
userAuthData, err := ctx.GetUserAuthData()
|
||||
if err == nil {
|
||||
for key, values := range userAuthData.ExtraHeaders {
|
||||
header.Del(key)
|
||||
for _, value := range values {
|
||||
header.Add(key, value)
|
||||
}
|
||||
|
||||
+2
-3
@@ -6,12 +6,11 @@ import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/tomakado/websocketproxy"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
type Ws struct {
|
||||
|
||||
@@ -49,3 +49,31 @@ func (r UserAuth) Authenticate(
|
||||
}
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
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)
|
||||
}
|
||||
@@ -106,11 +106,13 @@ func (s *Routes) registerEndpoint(
|
||||
}()
|
||||
|
||||
requiredAdminPerm, _ := cluster.GetRequiredAdminPermission(descriptor)
|
||||
requiredUserPerm, _ := cluster.GetRequiredUserPermission(descriptor)
|
||||
meta := domain.EndpointMeta{
|
||||
Inner: descriptor.Inner,
|
||||
UserAuthRequired: descriptor.UserAuthRequired,
|
||||
ModuleName: moduleName,
|
||||
RequiredAdminPermission: requiredAdminPerm,
|
||||
RequiredUserPermission: requiredUserPerm,
|
||||
PathSchema: descriptor.Path,
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,14 @@ type UserAuthenticationCache interface {
|
||||
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 {
|
||||
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 {
|
||||
@@ -31,12 +37,14 @@ type TokenProvider interface {
|
||||
type userAuthSetting struct {
|
||||
tokenProviders []TokenProvider
|
||||
authEndpoint string
|
||||
authorizeEndpoint string
|
||||
authCacheDuration time.Duration
|
||||
skipAppAuth bool
|
||||
}
|
||||
|
||||
type UserAuthentication struct {
|
||||
cache UserAuthenticationCache
|
||||
authzCache UserAuthorizationCache
|
||||
repo UserAuthenticationRepo
|
||||
settingsByModuleName map[string]userAuthSetting
|
||||
}
|
||||
@@ -44,6 +52,7 @@ type UserAuthentication struct {
|
||||
func NewUserAuthentication(
|
||||
cfg conf.CustomAuth,
|
||||
cache UserAuthenticationCache,
|
||||
authzCache UserAuthorizationCache,
|
||||
repo UserAuthenticationRepo,
|
||||
) (UserAuthentication, error) {
|
||||
tokenProviders := make(map[string]TokenProvider, len(cfg.TokenProviders))
|
||||
@@ -87,6 +96,7 @@ func NewUserAuthentication(
|
||||
settingsByModuleName[moduleName] = userAuthSetting{
|
||||
tokenProviders: settingTokenProviders,
|
||||
authEndpoint: setting.AuthenticateEndpoint,
|
||||
authorizeEndpoint: setting.AuthorizeEndpoint,
|
||||
authCacheDuration: cacheDuration,
|
||||
skipAppAuth: setting.SkipAppAuth,
|
||||
}
|
||||
@@ -95,6 +105,7 @@ func NewUserAuthentication(
|
||||
|
||||
return UserAuthentication{
|
||||
cache: cache,
|
||||
authzCache: authzCache,
|
||||
repo: repo,
|
||||
settingsByModuleName: settingsByModuleName,
|
||||
}, nil
|
||||
@@ -132,6 +143,58 @@ func (s UserAuthentication) Authenticate(ctx *request.Context) (*domain.Authenti
|
||||
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) {
|
||||
for _, provider := range providers {
|
||||
token, err := provider.ExtractToken(ctx)
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -382,11 +383,13 @@ func (s *HappyPathTestSuite) TestUserAuthorization() { // nolint:funlen
|
||||
ModuleNameList: []string{"target"},
|
||||
TokenProviders: []string{"test_provider"},
|
||||
AuthenticateEndpoint: "test-user-auth/authenticate",
|
||||
AuthorizeEndpoint: "test-user-auth/authorize",
|
||||
},
|
||||
{
|
||||
ModuleNameList: []string{"target2"},
|
||||
TokenProviders: []string{"test_provider"},
|
||||
AuthenticateEndpoint: "failed-user-auth/authenticate",
|
||||
AuthorizeEndpoint: "failed-user-auth/authorize",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -521,12 +524,14 @@ func (s *HappyPathTestSuite) TestUserAuthorization_SkipAppAuth() { // nolint:fun
|
||||
ModuleNameList: []string{"target"},
|
||||
TokenProviders: []string{"test_provider"},
|
||||
AuthenticateEndpoint: "test-user-auth/authenticate",
|
||||
AuthorizeEndpoint: "test-user-auth/authorize",
|
||||
SkipAppAuth: true,
|
||||
},
|
||||
{
|
||||
ModuleNameList: []string{"target2"},
|
||||
TokenProviders: []string{"test_provider"},
|
||||
AuthenticateEndpoint: "test-user-auth/authenticate",
|
||||
AuthorizeEndpoint: "test-user-auth/authorize",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -579,6 +584,163 @@ func (s *HappyPathTestSuite) TestUserAuthorization_SkipAppAuth() { // nolint:fun
|
||||
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
|
||||
func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, *client.Client, *client.Client) {
|
||||
config := conf.Remote{
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
type capturedLogEntry struct {
|
||||
level zapcore.Level
|
||||
message string
|
||||
fields map[string]any
|
||||
}
|
||||
|
||||
// logCapture ловит лог-записи в память. Zap-hook поля не получает,
|
||||
// поэтому логгер реализован напрямую через интерфейс log.Logger.
|
||||
type logCapture struct {
|
||||
mu sync.Mutex
|
||||
entries []capturedLogEntry
|
||||
}
|
||||
|
||||
func (c *logCapture) Error(_ context.Context, message any, fields ...log.Field) {
|
||||
c.log(zapcore.ErrorLevel, message, fields...)
|
||||
}
|
||||
|
||||
func (c *logCapture) Warn(_ context.Context, message any, fields ...log.Field) {
|
||||
c.log(zapcore.WarnLevel, message, fields...)
|
||||
}
|
||||
|
||||
func (c *logCapture) Info(_ context.Context, message any, fields ...log.Field) {
|
||||
c.log(zapcore.InfoLevel, message, fields...)
|
||||
}
|
||||
|
||||
func (c *logCapture) Debug(_ context.Context, message any, fields ...log.Field) {
|
||||
c.log(zapcore.DebugLevel, message, fields...)
|
||||
}
|
||||
|
||||
func (c *logCapture) log(level zapcore.Level, message any, fields ...log.Field) {
|
||||
encoder := zapcore.NewMapObjectEncoder()
|
||||
for _, field := range fields {
|
||||
field.AddTo(encoder)
|
||||
}
|
||||
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
c.entries = append(c.entries, capturedLogEntry{
|
||||
level: level,
|
||||
message: captureMessage(message),
|
||||
fields: encoder.Fields,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *logCapture) entriesWithMessage(message string) []capturedLogEntry {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
found := make([]capturedLogEntry, 0, len(c.entries))
|
||||
for _, entry := range c.entries {
|
||||
if entry.message == message {
|
||||
found = append(found, entry)
|
||||
}
|
||||
}
|
||||
return found
|
||||
}
|
||||
|
||||
func captureMessage(message any) string {
|
||||
if msg, ok := message.(string); ok {
|
||||
return msg
|
||||
}
|
||||
return fmt.Sprintf("%v", message)
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"isp-gate-service/assembly"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/entity"
|
||||
"isp-gate-service/routes"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
"github.com/txix-open/isp-kit/http/httpcli"
|
||||
"github.com/txix-open/isp-kit/lb"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"github.com/txix-open/isp-kit/test"
|
||||
"github.com/txix-open/isp-kit/test/grpct"
|
||||
"github.com/txix-open/isp-kit/test/httpt"
|
||||
)
|
||||
|
||||
type SkipBodyLoggingTestSuite struct {
|
||||
suite.Suite
|
||||
}
|
||||
|
||||
// Regression: skipBodyLoggingEndpointPrefixes с ведущим '/' должны
|
||||
// работать и в non-skipAuth цепочках — лог-строка пишется, тела нет.
|
||||
func (s *SkipBodyLoggingTestSuite) Test_KnownEndpoint_BodySkip_StrippedPrefix() {
|
||||
test, require := test.New(s.T())
|
||||
capture := &logCapture{}
|
||||
|
||||
config, systemCli, adminCli := s.authDependencies(test)
|
||||
|
||||
targetService := httpt.NewMock(test)
|
||||
targetService.POST("/endpoint", func(ctx context.Context, httpReq *http.Request, req request) response {
|
||||
return response{Id: req.Id}
|
||||
})
|
||||
targetUrl, err := url.Parse(targetService.BaseURL())
|
||||
require.NoError(err)
|
||||
targetHosts := map[string]*lb.RoundRobin{"target": lb.NewRoundRobin([]string{targetUrl.Host})}
|
||||
|
||||
routes := routes.NewRoutes(test.Logger())
|
||||
err = routes.ReceiveRoutes(s.T().Context(), cluster.RoutingConfig{{
|
||||
Endpoints: []cluster.EndpointDescriptor{{Path: "/endpoint"}},
|
||||
}})
|
||||
require.NoError(err)
|
||||
|
||||
locator := assembly.NewLocator(capture, nil, targetHosts, routes, systemCli, adminCli, nil, nil, nil)
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/api",
|
||||
Protocol: "http",
|
||||
TargetModule: "target",
|
||||
}}
|
||||
handler, err := locator.Handler(config, locations)
|
||||
require.NoError(err)
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
defer srv.Close()
|
||||
|
||||
resp, err := httpcli.New().Post(srv.URL+"/api/endpoint").
|
||||
Header("x-application-token", "token").
|
||||
Header("x-auth-admin", "mock-token").
|
||||
JsonRequestBody(request{Id: "test"}).
|
||||
Do(s.T().Context())
|
||||
require.NoError(err)
|
||||
require.EqualValues(http.StatusOK, resp.StatusCode())
|
||||
|
||||
// ровно одна лог-строка на запрос — без тел
|
||||
require.Len(capture.entries, 1)
|
||||
entries := capture.entriesWithMessage("log request")
|
||||
require.Len(entries, 1)
|
||||
require.NotContains(entries[0].fields, "request")
|
||||
require.NotContains(entries[0].fields, "response")
|
||||
}
|
||||
|
||||
// nolint:ireturn
|
||||
func (s *SkipBodyLoggingTestSuite) authDependencies(test *test.Test) (conf.Remote, *client.Client, *client.Client) {
|
||||
config := conf.Remote{
|
||||
Http: conf.Http{MaxRequestBodySizeInMb: 1, ProxyTimeoutInSec: 15},
|
||||
Logging: conf.Logging{
|
||||
LogLevel: log.DebugLevel,
|
||||
RequestLogEnable: true,
|
||||
BodyLogEnable: true,
|
||||
SkipBodyLoggingEndpointPrefixes: []string{"/endpoint"},
|
||||
},
|
||||
Caching: conf.Caching{AuthorizationDataInSec: 1, AuthenticationDataInSec: 1},
|
||||
}
|
||||
|
||||
systemService, systemCli := grpct.NewMock(test)
|
||||
systemService.Mock("system/secure/authenticate", func() entity.AuthenticateResponse {
|
||||
return entity.AuthenticateResponse{
|
||||
Authenticated: true,
|
||||
ErrorReason: "",
|
||||
AuthData: &entity.AppAuthData{
|
||||
SystemId: 1,
|
||||
DomainId: 2,
|
||||
ServiceId: 3,
|
||||
ApplicationId: 4,
|
||||
AppName: "test",
|
||||
},
|
||||
}
|
||||
}).Mock("system/secure/authorize", func() entity.AuthorizeResponse {
|
||||
return entity.AuthorizeResponse{Authorized: true}
|
||||
})
|
||||
|
||||
adminService, adminCli := grpct.NewMock(test)
|
||||
adminService.Mock("admin/secure/authenticate", func(req entity.AdminAuthorizeRequest) entity.AdminAuthenticateResponse {
|
||||
return entity.AdminAuthenticateResponse{
|
||||
Authenticated: true,
|
||||
ErrorReason: "",
|
||||
AdminId: 1,
|
||||
}
|
||||
}).Mock("admin/secure/authorize", func(req entity.AdminAuthorizeRequest) entity.AdminAuthorizeResponse {
|
||||
return entity.AdminAuthorizeResponse{Authorized: true}
|
||||
})
|
||||
|
||||
return config, systemCli, adminCli
|
||||
}
|
||||
|
||||
func TestSkipBodyLoggingTestSuite(t *testing.T) {
|
||||
t.Parallel()
|
||||
suite.Run(t, new(SkipBodyLoggingTestSuite))
|
||||
}
|
||||
@@ -1,275 +0,0 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"isp-gate-service/assembly"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/routes"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/http/httpcli"
|
||||
"github.com/txix-open/isp-kit/lb"
|
||||
"github.com/txix-open/isp-kit/test"
|
||||
"github.com/txix-open/isp-kit/test/httpt"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
type UnknownLocationsLoggingTestSuite struct {
|
||||
suite.Suite
|
||||
}
|
||||
|
||||
func (s *UnknownLocationsLoggingTestSuite) Test_UnknownPath_LogsWarn() {
|
||||
test, require := test.New(s.T())
|
||||
capture := &logCapture{}
|
||||
|
||||
locator := assembly.NewLocator(capture, nil, nil, routes.NewRoutes(test.Logger()), nil, nil, nil, nil, nil)
|
||||
handler, err := locator.Handler(conf.Remote{
|
||||
Http: conf.Http{MaxRequestBodySizeInMb: 1},
|
||||
Logging: conf.Logging{RequestLogEnable: true},
|
||||
}, nil)
|
||||
require.NoError(err)
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
defer srv.Close()
|
||||
|
||||
resp, err := httpcli.New().Get(srv.URL + "/unknown/path").Do(s.T().Context())
|
||||
require.NoError(err)
|
||||
require.EqualValues(http.StatusNotFound, resp.StatusCode())
|
||||
body, err := resp.BodyCopy()
|
||||
require.NoError(err)
|
||||
require.EqualValues("404 page not found\n", string(body))
|
||||
|
||||
// ровно одна лог-строка на запрос, и это warn о незнакомой location
|
||||
require.Len(capture.entries, 1)
|
||||
entries := capture.entriesWithMessage("request to unknown location")
|
||||
require.Len(entries, 1)
|
||||
require.EqualValues(zapcore.WarnLevel, entries[0].level)
|
||||
require.EqualValues(http.MethodGet, entries[0].fields["httpMethod"])
|
||||
require.EqualValues("/unknown/path", entries[0].fields["path"])
|
||||
require.EqualValues(http.StatusNotFound, entries[0].fields["statusCode"])
|
||||
require.NotEmpty(entries[0].fields["remoteAddr"])
|
||||
}
|
||||
|
||||
func (s *UnknownLocationsLoggingTestSuite) Test_UnknownPath_SuppressionSkipsWarn() {
|
||||
test, require := test.New(s.T())
|
||||
capture := &logCapture{}
|
||||
|
||||
config := conf.Remote{
|
||||
Http: conf.Http{MaxRequestBodySizeInMb: 1},
|
||||
Logging: conf.Logging{
|
||||
RequestLogEnable: true,
|
||||
SkipLoggingPathPrefixes: []string{"/unknown"},
|
||||
},
|
||||
}
|
||||
locator := assembly.NewLocator(capture, nil, nil, routes.NewRoutes(test.Logger()), nil, nil, nil, nil, nil)
|
||||
handler, err := locator.Handler(config, nil)
|
||||
require.NoError(err)
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
defer srv.Close()
|
||||
|
||||
resp, err := httpcli.New().Get(srv.URL + "/unknown/path").Do(s.T().Context())
|
||||
require.NoError(err)
|
||||
require.EqualValues(http.StatusNotFound, resp.StatusCode())
|
||||
|
||||
// запрос полностью не логируется
|
||||
require.Empty(capture.entries)
|
||||
}
|
||||
|
||||
// Warn о незнакомой location привязан к requestLogEnable как обычный лог запросов:
|
||||
// при выключенном флаге запрос не логируется, но ответ 404 — без изменений.
|
||||
func (s *UnknownLocationsLoggingTestSuite) Test_UnknownPath_RequestLoggingDisabled_NoWarn() {
|
||||
test, require := test.New(s.T())
|
||||
capture := &logCapture{}
|
||||
|
||||
locator := assembly.NewLocator(capture, nil, nil, routes.NewRoutes(test.Logger()), nil, nil, nil, nil, nil)
|
||||
handler, err := locator.Handler(conf.Remote{Http: conf.Http{MaxRequestBodySizeInMb: 1}}, nil)
|
||||
require.NoError(err)
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
defer srv.Close()
|
||||
|
||||
resp, err := httpcli.New().Get(srv.URL + "/unknown/path").Do(s.T().Context())
|
||||
require.NoError(err)
|
||||
require.EqualValues(http.StatusNotFound, resp.StatusCode())
|
||||
body, err := resp.BodyCopy()
|
||||
require.NoError(err)
|
||||
require.EqualValues("404 page not found\n", string(body))
|
||||
|
||||
require.Empty(capture.entries)
|
||||
}
|
||||
|
||||
func (s *UnknownLocationsLoggingTestSuite) Test_UnknownEndpoint_LogsWarn() {
|
||||
test, require := test.New(s.T())
|
||||
capture := &logCapture{}
|
||||
|
||||
routes := routes.NewRoutes(test.Logger())
|
||||
err := routes.ReceiveRoutes(s.T().Context(), cluster.RoutingConfig{{
|
||||
Endpoints: []cluster.EndpointDescriptor{{Path: "endpoint"}},
|
||||
}})
|
||||
require.NoError(err)
|
||||
|
||||
config := conf.Remote{Http: conf.Http{MaxRequestBodySizeInMb: 1}}
|
||||
locator := assembly.NewLocator(capture, nil, nil, routes, nil, nil, nil, nil, nil)
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/api",
|
||||
Protocol: "grpc",
|
||||
TargetModule: "target",
|
||||
}}
|
||||
handler, err := locator.Handler(config, locations)
|
||||
require.NoError(err)
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
defer srv.Close()
|
||||
|
||||
resp, err := httpcli.New().Post(srv.URL + "/api/nope").Do(s.T().Context())
|
||||
require.NoError(err)
|
||||
require.EqualValues(http.StatusNotImplemented, resp.StatusCode())
|
||||
|
||||
// ровно одна лог-строка на запрос — warn о неизвестном эндпоинте
|
||||
require.Len(capture.entries, 1)
|
||||
entries := capture.entriesWithMessage("call unknown method")
|
||||
require.Len(entries, 1)
|
||||
require.EqualValues(zapcore.WarnLevel, entries[0].level)
|
||||
}
|
||||
|
||||
func (s *UnknownLocationsLoggingTestSuite) Test_UnknownEndpoint_SuppressionSkipsWarn() {
|
||||
test, require := test.New(s.T())
|
||||
capture := &logCapture{}
|
||||
|
||||
routes := routes.NewRoutes(test.Logger())
|
||||
err := routes.ReceiveRoutes(s.T().Context(), cluster.RoutingConfig{{
|
||||
Endpoints: []cluster.EndpointDescriptor{{Path: "endpoint"}},
|
||||
}})
|
||||
require.NoError(err)
|
||||
|
||||
config := conf.Remote{
|
||||
Http: conf.Http{MaxRequestBodySizeInMb: 1},
|
||||
Logging: conf.Logging{SkipLoggingPathPrefixes: []string{"/api/nope"}},
|
||||
}
|
||||
locator := assembly.NewLocator(capture, nil, nil, routes, nil, nil, nil, nil, nil)
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/api",
|
||||
Protocol: "grpc",
|
||||
TargetModule: "target",
|
||||
}}
|
||||
handler, err := locator.Handler(config, locations)
|
||||
require.NoError(err)
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
defer srv.Close()
|
||||
|
||||
resp, err := httpcli.New().Post(srv.URL + "/api/nope").Do(s.T().Context())
|
||||
require.NoError(err)
|
||||
require.EqualValues(http.StatusNotImplemented, resp.StatusCode())
|
||||
|
||||
require.Empty(capture.entries)
|
||||
}
|
||||
|
||||
func (s *UnknownLocationsLoggingTestSuite) Test_KnownEndpoint_LogsRequest() {
|
||||
test, require := test.New(s.T())
|
||||
capture := &logCapture{}
|
||||
|
||||
targetService := httpt.NewMock(test)
|
||||
targetService.POST("/endpoint", func(ctx context.Context, httpReq *http.Request, req request) response {
|
||||
return response{Id: req.Id}
|
||||
})
|
||||
targetUrl, err := url.Parse(targetService.BaseURL())
|
||||
require.NoError(err)
|
||||
targetHosts := map[string]*lb.RoundRobin{"target": lb.NewRoundRobin([]string{targetUrl.Host})}
|
||||
|
||||
routes := routes.NewRoutes(test.Logger())
|
||||
err = routes.ReceiveRoutes(s.T().Context(), cluster.RoutingConfig{{
|
||||
Endpoints: []cluster.EndpointDescriptor{{Path: "/endpoint"}},
|
||||
}})
|
||||
require.NoError(err)
|
||||
|
||||
config := conf.Remote{
|
||||
Http: conf.Http{MaxRequestBodySizeInMb: 1, ProxyTimeoutInSec: 15},
|
||||
Logging: conf.Logging{RequestLogEnable: true},
|
||||
}
|
||||
locator := assembly.NewLocator(capture, nil, targetHosts, routes, nil, nil, nil, nil, nil)
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: true,
|
||||
PathPrefix: "/api",
|
||||
Protocol: "http",
|
||||
TargetModule: "target",
|
||||
}}
|
||||
handler, err := locator.Handler(config, locations)
|
||||
require.NoError(err)
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
defer srv.Close()
|
||||
|
||||
resp, err := httpcli.New().Post(srv.URL + "/api/endpoint").
|
||||
JsonRequestBody(request{Id: "test"}).
|
||||
Do(s.T().Context())
|
||||
require.NoError(err)
|
||||
require.EqualValues(http.StatusOK, resp.StatusCode())
|
||||
|
||||
// ровно одна лог-строка на запрос — log request
|
||||
require.Len(capture.entries, 1)
|
||||
entries := capture.entriesWithMessage("log request")
|
||||
require.Len(entries, 1)
|
||||
require.EqualValues("/api/endpoint", entries[0].fields["path"])
|
||||
}
|
||||
|
||||
func (s *UnknownLocationsLoggingTestSuite) Test_KnownEndpoint_SuppressionSkipsRequestLog() {
|
||||
test, require := test.New(s.T())
|
||||
capture := &logCapture{}
|
||||
|
||||
targetService := httpt.NewMock(test)
|
||||
targetService.POST("/endpoint", func(ctx context.Context, httpReq *http.Request, req request) response {
|
||||
return response{Id: req.Id}
|
||||
})
|
||||
targetUrl, err := url.Parse(targetService.BaseURL())
|
||||
require.NoError(err)
|
||||
targetHosts := map[string]*lb.RoundRobin{"target": lb.NewRoundRobin([]string{targetUrl.Host})}
|
||||
|
||||
routes := routes.NewRoutes(test.Logger())
|
||||
err = routes.ReceiveRoutes(s.T().Context(), cluster.RoutingConfig{{
|
||||
Endpoints: []cluster.EndpointDescriptor{{Path: "/endpoint"}},
|
||||
}})
|
||||
require.NoError(err)
|
||||
|
||||
config := conf.Remote{
|
||||
Http: conf.Http{MaxRequestBodySizeInMb: 1, ProxyTimeoutInSec: 15},
|
||||
Logging: conf.Logging{
|
||||
RequestLogEnable: true,
|
||||
SkipLoggingPathPrefixes: []string{"/api/endpoint"},
|
||||
},
|
||||
}
|
||||
locator := assembly.NewLocator(capture, nil, targetHosts, routes, nil, nil, nil, nil, nil)
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: true,
|
||||
PathPrefix: "/api",
|
||||
Protocol: "http",
|
||||
TargetModule: "target",
|
||||
}}
|
||||
handler, err := locator.Handler(config, locations)
|
||||
require.NoError(err)
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
defer srv.Close()
|
||||
|
||||
resp, err := httpcli.New().Post(srv.URL + "/api/endpoint").
|
||||
JsonRequestBody(request{Id: "test"}).
|
||||
Do(s.T().Context())
|
||||
require.NoError(err)
|
||||
require.EqualValues(http.StatusOK, resp.StatusCode())
|
||||
|
||||
require.Empty(capture.entries)
|
||||
}
|
||||
|
||||
func TestUnknownLocationsLoggingTestSuite(t *testing.T) {
|
||||
t.Parallel()
|
||||
suite.Run(t, new(UnknownLocationsLoggingTestSuite))
|
||||
}
|
||||
Reference in new issue
Block a user