Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f891fd52b1 | ||
|
|
6bf8c4e6e3 | ||
|
|
a7427d73de | ||
|
|
1776a6a8e3 | ||
|
|
48af0bb132 | ||
|
|
8012ad57fe | ||
|
|
34e3ef7687 | ||
|
|
81472ca819 | ||
|
|
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
@@ -74,3 +74,5 @@ package.json
|
|||||||
yarn.lock
|
yarn.lock
|
||||||
|
|
||||||
conf/config_dev.yml
|
conf/config_dev.yml
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
include:
|
||||||
|
- project: '$CI_PROJECT_PATH'
|
||||||
|
file: '/ci-isp-go-service.yml'
|
||||||
+85
-60
@@ -1,66 +1,91 @@
|
|||||||
|
version: "2"
|
||||||
run:
|
run:
|
||||||
allow-parallel-runners: true
|
allow-parallel-runners: true
|
||||||
issues:
|
|
||||||
exclude-rules:
|
|
||||||
- path: controller #достаточное кол-во контекса на уровне контроллеров
|
|
||||||
linters:
|
|
||||||
- wrapcheck
|
|
||||||
- path: transaction #транзакции прозрачны
|
|
||||||
linters:
|
|
||||||
- wrapcheck
|
|
||||||
- path: middleware #отсутствует необходимость оборачивать ошибки
|
|
||||||
linters:
|
|
||||||
- wrapcheck
|
|
||||||
- path: proxy
|
|
||||||
linters:
|
|
||||||
- gochecknoglobals
|
|
||||||
- mnd
|
|
||||||
- path: httperrors #отсутствует необходимость оборачивать ошибки
|
|
||||||
linters:
|
|
||||||
- wrapcheck
|
|
||||||
linters:
|
linters:
|
||||||
enable-all: true
|
default: all
|
||||||
disable:
|
disable:
|
||||||
- goimports #у нас собственные правила форматирования импортов
|
- contextcheck # не имеет смысла
|
||||||
- wsl #расставление пробелов очень индивидуально
|
- depguard # не всегда имеет смысл
|
||||||
- exhaustivestruct #не имеет смысла
|
- dupword # не имеет смысла
|
||||||
- varnamelen #очень индивидуально (db)
|
- exhaustruct # не имеет смысла
|
||||||
- exhaustruct #не имеет смысла
|
- godot # не актуально для swagger
|
||||||
- golint #устарел
|
- godox # не позволяет оставлять todo
|
||||||
- contextcheck #не имеет смысла
|
- musttag # у нас собственное правило: не используем теги, если работаем с пакетом isp-kit/json и с внутренними структурами(между нашими сервисами), при этом теги обязательный для всех внешних для нас структур
|
||||||
- gci #у нас собственные правила форматирования импортов
|
- nlreturn # не всегда имеет смысл
|
||||||
- gofumpt #у нас собственные правила форматирования импортов
|
- nolintlint # Goland все равно форматирует с отступом
|
||||||
- nolintlint #Goland все равно форматирует с отступом
|
- perfsprint # мнимая производительность в угоду читаемости
|
||||||
- nlreturn #не всегда имеет смысл
|
- tagalign # не всегда имеет смысл
|
||||||
- godot #не актуально для свагера
|
|
||||||
- ifshort #приняли решение, что мы так не пишем if err := ...; err != nil {}
|
|
||||||
- godox #не позволяет оставлять todo
|
|
||||||
- maligned #аллокацией памяти для структур конфликтует с удобством их чтения
|
|
||||||
- nosnakecase #не позволяет заводить пакеты используя snake_case
|
|
||||||
- depguard #не всегда имеет смысл
|
|
||||||
- dupword #не имеет смысла
|
|
||||||
- tagalign #не всегда имеет смысл
|
|
||||||
- musttag #у нас собственные правило: не используем теги, если работаем с пакетом isp-kit/json и с внутренними структурами(между нашими сервисами), при этом теги обязательный для всех внених для нас структур
|
|
||||||
- perfsprint #мнимая производительность в угоду читаемости
|
|
||||||
- testpackage
|
- testpackage
|
||||||
linters-settings:
|
- varnamelen # очень индивидуально (db)
|
||||||
funlen:
|
- wsl # расставление пробелов очень индивидуально
|
||||||
lines: 80
|
- wsl_v5 # расставление пробелов очень индивидуально
|
||||||
lll:
|
- godoclint # ругается на // nolint, не удобно
|
||||||
line-length: 150
|
- prealloc # слишком аггресивный, в большинстве случаев не требуется
|
||||||
cyclop:
|
- gomodguard # deprecated
|
||||||
max-complexity: 15 #по умолчанию 10 мало
|
- goconst # слишком агрессивный
|
||||||
revive:
|
settings:
|
||||||
|
exhaustruct_v5:
|
||||||
|
allow-empty: true
|
||||||
|
explicit-mode: true
|
||||||
|
cyclop:
|
||||||
|
max-complexity: 15 # по умолчанию 10 мало
|
||||||
|
funlen:
|
||||||
|
lines: 80
|
||||||
|
lll:
|
||||||
|
line-length: 150
|
||||||
|
revive:
|
||||||
|
rules:
|
||||||
|
- name: var-naming # отключаем Id -> ID
|
||||||
|
disabled: true
|
||||||
|
staticcheck:
|
||||||
|
checks: # отключаем Id -> ID
|
||||||
|
- -ST1000
|
||||||
|
- -ST1016
|
||||||
|
- -ST1020
|
||||||
|
- -ST1021
|
||||||
|
- -ST1022
|
||||||
|
testifylint:
|
||||||
|
disable:
|
||||||
|
- compares
|
||||||
|
- equal-values
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
presets:
|
||||||
|
- comments
|
||||||
|
- common-false-positives
|
||||||
|
- legacy
|
||||||
|
- std-error-handling
|
||||||
rules:
|
rules:
|
||||||
- name: var-naming #отключаем Id -> ID
|
- linters:
|
||||||
disabled: true
|
- wrapcheck
|
||||||
stylecheck:
|
path: controller # достаточное кол-во контекста на уровне контроллеров
|
||||||
checks: #отключаем Id -> ID
|
- linters:
|
||||||
- "-ST1000"
|
- wrapcheck
|
||||||
- "-ST1016"
|
path: transaction # транзакции прозрачны
|
||||||
- "-ST1020"
|
- linters:
|
||||||
- "-ST1021"
|
- unqueryvet
|
||||||
- "-ST1022"
|
- prealloc
|
||||||
testifylint:
|
path: ".*_test\\.go$"
|
||||||
disable:
|
- linters:
|
||||||
- compares
|
- wrapcheck
|
||||||
|
path: middleware #отсутствует необходимость оборачивать ошибки
|
||||||
|
- linters:
|
||||||
|
- gochecknoglobals
|
||||||
|
- mnd
|
||||||
|
path: proxy
|
||||||
|
- linters:
|
||||||
|
- wrapcheck
|
||||||
|
path: httperrors #отсутствует необходимость оборачивать ошибки
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
formatters:
|
||||||
|
enable:
|
||||||
|
- gofmt
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
@@ -1,3 +1,88 @@
|
|||||||
|
### 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.11.4
|
||||||
|
* добавлена возможность через переменную окружения `adminServiceName` переопределить название сервиса `msp-admin-service`
|
||||||
|
### v5.11.3
|
||||||
|
* добавлена настройка для преопределения content-type в ответе с `application/json` на `application/json; charset=utf-8` для конкретных приложений
|
||||||
|
### v5.11.2
|
||||||
|
* обновлены зависимости
|
||||||
|
### v5.11.1
|
||||||
|
* Обновлен isp-kit
|
||||||
|
### v5.11.0
|
||||||
|
* Добавлена поддержка нескольких `tokenProvider` для `customAuth.userAuthSettings`: используется первый провайдер, вернувший токен
|
||||||
|
### v5.10.2
|
||||||
|
* Убрано дублирование поля `requestId` при логгировании
|
||||||
|
### v5.10.1
|
||||||
|
* Изменен нейминг настройки `customAuth.userAuthSettings.authenticateMethodPath` на `customAuth.userAuthSettings.authenticateEndpoint`
|
||||||
|
### v5.10.0
|
||||||
|
* Добавлена конфигурируемая аутентификация/авторизация пользователя
|
||||||
|
### v5.9.3
|
||||||
|
* Исправлена опечатка при вызове `strings.TrimPrefix`
|
||||||
|
### v5.9.2
|
||||||
|
* При проверке `logging.skipBodyLoggingEndpointPrefixes` игнорируется `/` в начале, путь для проверки берётся из `pathSchema`, если `pathSchema` пустая, берётся вызываемый `endpoint`
|
||||||
|
* В логе `log request` из значения в поле `endpoint` удаляется `/` в начале, путь берётся из `pathSchema`, если `pathSchema` пустая, берётся вызываемый `endpoint`
|
||||||
|
### v5.9.1
|
||||||
|
* Добавлен `warn` лог на неизвестный endpoint
|
||||||
|
### v5.9.0
|
||||||
|
* Теперь в зависимоси от `StatusCode` выводится соотвествующий уровень логирования: 400 -> warn, 500 -> error
|
||||||
|
* Исправлен порядок мидлварей, для корректного проброса `requestId`
|
||||||
|
### v5.8.1
|
||||||
|
* Обновлены зависимости
|
||||||
|
### v5.8.0
|
||||||
|
* Изменён resolve для endpoint'ов, теперь используется `lookup` у `github.com/julienschmidt/httprouter`
|
||||||
|
* Добавлен http метод в запрос авторизации (`system/secure/authorize`)
|
||||||
|
### v5.7.0
|
||||||
|
* Добавлено лог поле `applicationName` в логи `log request` и `bypassing unauthorized request because it has admin privilege`
|
||||||
|
### v5.6.2
|
||||||
|
* Обновлено заполнение заголовка `x-application-name` для поддержки кириллических символов
|
||||||
|
### v5.6.1
|
||||||
|
* Добавлен проброс заголовка `x-application-name`
|
||||||
|
### v5.6.0
|
||||||
|
* Добавлена поддержка метрик для http запросов
|
||||||
|
### v5.5.1
|
||||||
|
* повышен приоритет `x-application-token` над basic-auth, при поиске в запросе токена приложения
|
||||||
|
### v5.5.0
|
||||||
|
* Добавлена поддержка basic-auth, где `username` - название приложения, `password` - токен приложения
|
||||||
|
### v5.4.1
|
||||||
|
* Оптимизация очистки тела запроса от экранирования unicode символов для корректного логирования
|
||||||
|
### v5.4.0
|
||||||
|
* Добавлена настройка `forwardReqIdClientSettings` для разрешения прокидывания `requestId` определённым приложениям по их идентификаторам (`requestId` клиента прокидывается если в `forwardReqIdClientSettings` для приложения включено прокидывание или включен глобальный флаг `enableClientRequestIdForwarding`)
|
||||||
|
* Обновлена версия go до 1.25
|
||||||
|
### v5.3.0
|
||||||
|
* обновлены зависимости
|
||||||
|
### v5.2.10
|
||||||
|
* добавлен контекст ошибки для grpc
|
||||||
|
### v5.2.9
|
||||||
|
* взаимодействие напрямую с `redis` заменено на взаимодействие с `isp-lock-service`
|
||||||
|
### v5.2.8
|
||||||
|
* добавлена обработка эндпоинта в двух форматах: с `/` в начале и без
|
||||||
|
* обновлены зависимости
|
||||||
|
### v5.2.7
|
||||||
|
* добавлен `Dockerfile` и скрипт для сборки и публикации образа в `GitHub Contaier Registry`
|
||||||
|
* обновлены зависимости
|
||||||
|
### v5.2.6
|
||||||
|
* исправлен баг с отсутствием проверки разрешенных действий
|
||||||
|
### v5.2.5
|
||||||
|
* добавлено новое поле `enableForceUnescapingUnicode` в конфигурации для очистки тела запроса от экранирования unicode символов при логирование
|
||||||
|
* реализована поддержка очистки тела запроса от экранирования unicode символов для корректного логирования
|
||||||
|
* обновлены зависимости
|
||||||
|
### v5.2.4
|
||||||
|
* обновлены зависимости
|
||||||
|
### v5.2.3
|
||||||
|
* добавлен заголовок `X-Request-Id` в ответ при проксировании grpc
|
||||||
|
* обновлены зависимости
|
||||||
|
* обновлена версия go до 1.24
|
||||||
|
### v5.2.1
|
||||||
|
* добавлен параметр для настройки проброса `requestId` из заголовка запроса
|
||||||
|
* добавлено логирование содержимого заголовка `requestId` из заголовка запроса (поле `clientRequestId`)
|
||||||
|
* обновлены зависимости
|
||||||
|
* обновлена версия go до 1.23
|
||||||
### v5.2.0
|
### v5.2.0
|
||||||
* изменён формат логов с `snake_case` на `camelCase`
|
* изменён формат логов с `snake_case` на `camelCase`
|
||||||
### v5.1.1
|
### v5.1.1
|
||||||
|
|||||||
+54
-59
@@ -2,19 +2,26 @@ package assembly
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/redis/go-redis/v9"
|
"isp-gate-service/cache"
|
||||||
"isp-gate-service/conf"
|
"isp-gate-service/conf"
|
||||||
"isp-gate-service/routes"
|
"isp-gate-service/routes"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/app"
|
"github.com/txix-open/isp-kit/app"
|
||||||
"github.com/integration-system/isp-kit/bootstrap"
|
"github.com/txix-open/isp-kit/bootstrap"
|
||||||
"github.com/integration-system/isp-kit/cluster"
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
"github.com/integration-system/isp-kit/grpc/client"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/integration-system/isp-kit/http"
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
"github.com/integration-system/isp-kit/lb"
|
"github.com/txix-open/isp-kit/http"
|
||||||
"github.com/integration-system/isp-kit/log"
|
"github.com/txix-open/isp-kit/lb"
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
routerModuleName = "isp-router-service"
|
||||||
|
defaultAdminServiceName = "msp-admin-service"
|
||||||
|
usersAuthCachePurgeInterval = 5 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
type Assembly struct {
|
type Assembly struct {
|
||||||
@@ -22,13 +29,16 @@ type Assembly struct {
|
|||||||
server *http.Server
|
server *http.Server
|
||||||
logger *log.Adapter
|
logger *log.Adapter
|
||||||
routes *routes.Routes
|
routes *routes.Routes
|
||||||
redisCli redis.UniversalClient
|
|
||||||
systemCli *client.Client
|
systemCli *client.Client
|
||||||
adminCli *client.Client
|
adminCli *client.Client
|
||||||
|
lockerCli *client.Client
|
||||||
|
routerLb *lb.RoundRobin
|
||||||
|
|
||||||
locations []conf.Location
|
localConfig conf.Local
|
||||||
grpcClientByModuleName map[string]*client.Client
|
grpcClientByModuleName map[string]*client.Client
|
||||||
httpHostManagerByModuleName map[string]*lb.RoundRobin
|
httpHostManagerByModuleName map[string]*lb.RoundRobin
|
||||||
|
|
||||||
|
usersAuthCache *cache.Cache
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
||||||
@@ -62,22 +72,28 @@ func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "create system cli")
|
return nil, errors.WithMessage(err, "create system cli")
|
||||||
}
|
}
|
||||||
|
|
||||||
adminCli, err := client.Default()
|
adminCli, err := client.Default()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "create admin cli")
|
return nil, errors.WithMessage(err, "create admin cli")
|
||||||
}
|
}
|
||||||
|
lockerCli, err := client.Default()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "create isp-lock-service client")
|
||||||
|
}
|
||||||
|
|
||||||
return &Assembly{
|
return &Assembly{
|
||||||
boot: boot,
|
boot: boot,
|
||||||
server: server,
|
server: server,
|
||||||
logger: boot.App.Logger(),
|
logger: boot.App.Logger(),
|
||||||
routes: routes.NewRoutes(),
|
routes: routes.NewRoutes(boot.App.Logger()),
|
||||||
locations: localConfig.Locations,
|
localConfig: localConfig,
|
||||||
grpcClientByModuleName: grpcClientByModuleName,
|
grpcClientByModuleName: grpcClientByModuleName,
|
||||||
httpHostManagerByModuleName: httpHostManagerByModuleName,
|
httpHostManagerByModuleName: httpHostManagerByModuleName,
|
||||||
systemCli: systemCli,
|
systemCli: systemCli,
|
||||||
adminCli: adminCli,
|
adminCli: adminCli,
|
||||||
|
lockerCli: lockerCli,
|
||||||
|
routerLb: lb.NewRoundRobin(nil),
|
||||||
|
usersAuthCache: cache.New(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,32 +106,26 @@ func (a *Assembly) ReceiveConfig(ctx context.Context, remoteConfig []byte) error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
a.logger.Fatal(ctx, errors.WithMessage(err, "upgrade remote config"))
|
a.logger.Fatal(ctx, errors.WithMessage(err, "upgrade remote config"))
|
||||||
}
|
}
|
||||||
err = newCfg.Validate()
|
|
||||||
if err != nil {
|
|
||||||
a.logger.Fatal(ctx, errors.WithMessage(err, "invalid remote config"))
|
|
||||||
}
|
|
||||||
|
|
||||||
a.logger.SetLevel(newCfg.Logging.LogLevel)
|
a.logger.SetLevel(newCfg.Logging.LogLevel)
|
||||||
|
|
||||||
var newRedisCli redis.UniversalClient
|
locator := NewLocator(
|
||||||
if newCfg.Redis != nil {
|
a.logger,
|
||||||
newRedisCli = a.redisClient(*newCfg.Redis)
|
a.grpcClientByModuleName,
|
||||||
}
|
a.httpHostManagerByModuleName,
|
||||||
|
a.routes,
|
||||||
locator := NewLocator(a.logger, a.grpcClientByModuleName, a.httpHostManagerByModuleName, a.routes, a.systemCli, a.adminCli)
|
a.systemCli,
|
||||||
|
a.adminCli,
|
||||||
handler, err := locator.Handler(newCfg, a.locations, newRedisCli)
|
a.lockerCli,
|
||||||
|
a.routerLb,
|
||||||
|
a.usersAuthCache,
|
||||||
|
)
|
||||||
|
handler, err := locator.Handler(newCfg, a.localConfig.Locations)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "locator handler")
|
return errors.WithMessage(err, "locator handler")
|
||||||
}
|
}
|
||||||
|
|
||||||
a.server.Upgrade(handler)
|
a.server.Upgrade(handler)
|
||||||
|
|
||||||
if a.redisCli != nil {
|
|
||||||
_ = a.redisCli.Close()
|
|
||||||
a.redisCli = newRedisCli
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,9 +140,14 @@ func (a *Assembly) Runners() []app.Runner {
|
|||||||
for moduleName, upgrader := range a.httpHostManagerByModuleName {
|
for moduleName, upgrader := range a.httpHostManagerByModuleName {
|
||||||
eventHandler.RequireModule(moduleName, upgrader)
|
eventHandler.RequireModule(moduleName, upgrader)
|
||||||
}
|
}
|
||||||
|
adminServiceName := a.localConfig.AdminServiceName
|
||||||
|
if adminServiceName == "" {
|
||||||
|
adminServiceName = defaultAdminServiceName
|
||||||
|
}
|
||||||
eventHandler.RequireModule("isp-system-service", a.systemCli)
|
eventHandler.RequireModule("isp-system-service", a.systemCli)
|
||||||
eventHandler.RequireModule("msp-admin-service", a.adminCli)
|
eventHandler.RequireModule(adminServiceName, a.adminCli)
|
||||||
|
eventHandler.RequireModule("isp-lock-service", a.lockerCli)
|
||||||
|
eventHandler.RequireModule(routerModuleName, a.routerLb)
|
||||||
|
|
||||||
return []app.Runner{
|
return []app.Runner{
|
||||||
app.RunnerFunc(func(ctx context.Context) error {
|
app.RunnerFunc(func(ctx context.Context) error {
|
||||||
@@ -141,6 +156,10 @@ func (a *Assembly) Runners() []app.Runner {
|
|||||||
app.RunnerFunc(func(ctx context.Context) error {
|
app.RunnerFunc(func(ctx context.Context) error {
|
||||||
return a.boot.ClusterCli.Run(ctx, eventHandler)
|
return a.boot.ClusterCli.Run(ctx, eventHandler)
|
||||||
}),
|
}),
|
||||||
|
app.RunnerFunc(func(ctx context.Context) error {
|
||||||
|
a.usersAuthCache.StartCleaner(ctx, usersAuthCachePurgeInterval)
|
||||||
|
return nil
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,31 +173,7 @@ func (a *Assembly) Closers() []app.Closer {
|
|||||||
for _, cliCloser := range a.grpcClientByModuleName {
|
for _, cliCloser := range a.grpcClientByModuleName {
|
||||||
closers = append(closers, cliCloser)
|
closers = append(closers, cliCloser)
|
||||||
}
|
}
|
||||||
closers = append(closers, a.systemCli, a.adminCli, app.CloserFunc(func() error {
|
closers = append(closers, a.systemCli, a.adminCli, a.lockerCli)
|
||||||
if a.redisCli != nil {
|
|
||||||
return a.redisCli.Close()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}))
|
|
||||||
|
|
||||||
return closers
|
return closers
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint:ireturn
|
|
||||||
func (a *Assembly) redisClient(config conf.Redis) redis.UniversalClient {
|
|
||||||
if config.Sentinel != nil {
|
|
||||||
return redis.NewFailoverClient(&redis.FailoverOptions{
|
|
||||||
MasterName: config.Sentinel.MasterName,
|
|
||||||
SentinelAddrs: config.Sentinel.Addresses,
|
|
||||||
SentinelUsername: config.Sentinel.Username,
|
|
||||||
SentinelPassword: config.Sentinel.Password,
|
|
||||||
Username: config.Username,
|
|
||||||
Password: config.Password,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return redis.NewClient(&redis.Options{
|
|
||||||
Addr: config.Address,
|
|
||||||
Username: config.Username,
|
|
||||||
Password: config.Password,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
+88
-20
@@ -2,10 +2,13 @@ package assembly
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
mux2 "github.com/gorilla/mux"
|
"github.com/txix-open/isp-kit/metrics"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/txix-open/isp-kit/metrics/http_metrics"
|
||||||
|
|
||||||
|
"isp-gate-service/cache"
|
||||||
"isp-gate-service/conf"
|
"isp-gate-service/conf"
|
||||||
"isp-gate-service/middleware"
|
"isp-gate-service/middleware"
|
||||||
"isp-gate-service/proxy"
|
"isp-gate-service/proxy"
|
||||||
@@ -13,10 +16,11 @@ import (
|
|||||||
"isp-gate-service/routes"
|
"isp-gate-service/routes"
|
||||||
"isp-gate-service/service"
|
"isp-gate-service/service"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/grpc/client"
|
mux2 "github.com/gorilla/mux"
|
||||||
"github.com/integration-system/isp-kit/lb"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/integration-system/isp-kit/log"
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/lb"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Locator struct {
|
type Locator struct {
|
||||||
@@ -26,6 +30,9 @@ type Locator struct {
|
|||||||
routes *routes.Routes
|
routes *routes.Routes
|
||||||
systemCli *client.Client
|
systemCli *client.Client
|
||||||
adminCli *client.Client
|
adminCli *client.Client
|
||||||
|
lockerCli *client.Client
|
||||||
|
routerLb *lb.RoundRobin
|
||||||
|
usersAuthCache *cache.Cache
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLocator(
|
func NewLocator(
|
||||||
@@ -35,6 +42,9 @@ func NewLocator(
|
|||||||
routes *routes.Routes,
|
routes *routes.Routes,
|
||||||
systemCli *client.Client,
|
systemCli *client.Client,
|
||||||
adminCli *client.Client,
|
adminCli *client.Client,
|
||||||
|
lockerCli *client.Client,
|
||||||
|
routerLb *lb.RoundRobin,
|
||||||
|
usersAuthCache *cache.Cache,
|
||||||
) Locator {
|
) Locator {
|
||||||
return Locator{
|
return Locator{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
@@ -43,16 +53,30 @@ func NewLocator(
|
|||||||
routes: routes,
|
routes: routes,
|
||||||
systemCli: systemCli,
|
systemCli: systemCli,
|
||||||
adminCli: adminCli,
|
adminCli: adminCli,
|
||||||
|
lockerCli: lockerCli,
|
||||||
|
routerLb: routerLb,
|
||||||
|
usersAuthCache: usersAuthCache,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli redis.UniversalClient) (http.Handler, error) {
|
func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Handler, error) { // nolint:funlen
|
||||||
systemRepo := repository.NewSystem(l.systemCli)
|
systemRepo := repository.NewSystem(l.systemCli)
|
||||||
adminRepo := repository.NewAdmin(l.adminCli)
|
adminRepo := repository.NewAdmin(l.adminCli)
|
||||||
|
|
||||||
authenticationCache := repository.NewAuthenticationCache(time.Duration(config.Caching.AuthenticationDataInSec) * time.Second)
|
authenticationCache := repository.NewAuthenticationCache(time.Duration(config.Caching.AuthenticationDataInSec) * time.Second)
|
||||||
authentication := service.NewAuthentication(authenticationCache, systemRepo)
|
authentication := service.NewAuthentication(authenticationCache, systemRepo)
|
||||||
|
|
||||||
|
userAuthenticationCache := repository.NewUserAuthenticationCache(l.usersAuthCache)
|
||||||
|
userAuthRepo := repository.NewUserAuth(l.routerLb)
|
||||||
|
userAuthentication, err := service.NewUserAuthentication(
|
||||||
|
config.CustomAuth,
|
||||||
|
userAuthenticationCache,
|
||||||
|
userAuthRepo,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "new user authentication")
|
||||||
|
}
|
||||||
|
|
||||||
adminService := service.NewAdmin(
|
adminService := service.NewAdmin(
|
||||||
repository.NewAuthorizationCache(time.Duration(config.Caching.AuthorizationDataInSec)*time.Second),
|
repository.NewAuthorizationCache(time.Duration(config.Caching.AuthorizationDataInSec)*time.Second),
|
||||||
adminRepo,
|
adminRepo,
|
||||||
@@ -63,11 +87,16 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli
|
|||||||
systemRepo,
|
systemRepo,
|
||||||
)
|
)
|
||||||
|
|
||||||
dailyLimitRepo := repository.NewDailyLimit(redisCli)
|
lockRepo := repository.NewLocker(l.lockerCli)
|
||||||
dailyLimitService := service.NewDailyLimit(dailyLimitRepo, config.DailyLimits)
|
dailyLimitService := service.NewDailyLimit(lockRepo, config.DailyLimits)
|
||||||
|
throttlingService := service.NewThrottling(lockRepo, config.Throttling)
|
||||||
|
|
||||||
throttlingRepo := repository.NewThrottling(redisCli)
|
skipBodyLoggingEndpointPrefixes := make([]string, 0, len(config.Logging.SkipBodyLoggingEndpointPrefixes))
|
||||||
throttlingService := service.NewThrottling(throttlingRepo, config.Throttling)
|
for _, prefix := range config.Logging.SkipBodyLoggingEndpointPrefixes {
|
||||||
|
skipBodyLoggingEndpointPrefixes = append(skipBodyLoggingEndpointPrefixes, strings.TrimPrefix(prefix, "/"))
|
||||||
|
}
|
||||||
|
|
||||||
|
skipLogging := middleware.NewSkipLoggingPaths(config.Logging.SkipLoggingPathPrefixes)
|
||||||
|
|
||||||
mux := mux2.NewRouter()
|
mux := mux2.NewRouter()
|
||||||
for _, location := range locations {
|
for _, location := range locations {
|
||||||
@@ -80,6 +109,9 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli
|
|||||||
proxyFunc = proxy.NewGrpc(cli, location.SkipAuth, time.Duration(config.Http.ProxyTimeoutInSec)*time.Second)
|
proxyFunc = proxy.NewGrpc(cli, location.SkipAuth, time.Duration(config.Http.ProxyTimeoutInSec)*time.Second)
|
||||||
case conf.HttpProtocol:
|
case conf.HttpProtocol:
|
||||||
hostManager := l.httpHostManagerByModuleName[location.TargetModule]
|
hostManager := l.httpHostManagerByModuleName[location.TargetModule]
|
||||||
|
if location.TargetModule == routerModuleName {
|
||||||
|
hostManager = l.routerLb
|
||||||
|
}
|
||||||
proxyFunc = proxy.NewHttp(hostManager, location.SkipAuth, time.Duration(config.Http.ProxyTimeoutInSec)*time.Second)
|
proxyFunc = proxy.NewHttp(hostManager, location.SkipAuth, time.Duration(config.Http.ProxyTimeoutInSec)*time.Second)
|
||||||
case conf.WsProtocol:
|
case conf.WsProtocol:
|
||||||
hostManager := l.httpHostManagerByModuleName[location.TargetModule]
|
hostManager := l.httpHostManagerByModuleName[location.TargetModule]
|
||||||
@@ -89,39 +121,75 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli
|
|||||||
return nil, errors.Errorf("not supported protocol %s", location.Protocol)
|
return nil, errors.Errorf("not supported protocol %s", location.Protocol)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
forwardReqIdByAppId := make(map[int]bool, len(config.ForwardReqIdClientSettings))
|
||||||
|
for _, setting := range config.ForwardReqIdClientSettings {
|
||||||
|
forwardReqIdByAppId[setting.ApplicationId] = setting.ForwardRequestId
|
||||||
|
}
|
||||||
|
|
||||||
|
enableUtf8JsonCharsetByApp := make(map[int]bool, len(config.ResponseContentTypeSettings))
|
||||||
|
for _, setting := range config.ResponseContentTypeSettings {
|
||||||
|
enableUtf8JsonCharsetByApp[setting.ApplicationId] = setting.AddJsonUtf8Charset
|
||||||
|
}
|
||||||
|
|
||||||
|
metricsStorage := http_metrics.NewServerStorage(metrics.DefaultRegistry)
|
||||||
|
|
||||||
handler := middleware.Chain(
|
handler := middleware.Chain(
|
||||||
proxyFunc,
|
proxyFunc,
|
||||||
|
middleware.Logger(
|
||||||
|
l.logger, config.Logging.RequestLogEnable,
|
||||||
|
enableBodyLog,
|
||||||
|
skipLogging,
|
||||||
|
skipBodyLoggingEndpointPrefixes,
|
||||||
|
config.Logging.EnableForceUnescapingUnicode,
|
||||||
|
),
|
||||||
middleware.RequestId(),
|
middleware.RequestId(),
|
||||||
middleware.Logger(l.logger, config.Logging.RequestLogEnable, enableBodyLog,
|
|
||||||
config.Logging.SkipBodyLoggingEndpointPrefixes),
|
|
||||||
middleware.ErrorHandler(l.logger),
|
middleware.ErrorHandler(l.logger),
|
||||||
|
middleware.UserAuthenticate(userAuthentication, l.logger),
|
||||||
middleware.Authenticate(authentication),
|
middleware.Authenticate(authentication),
|
||||||
middleware.AdminAuthenticate(adminService),
|
middleware.AdminAuthenticate(adminService),
|
||||||
|
middleware.ClientRequestId(config.EnableClientRequestIdForwarding, forwardReqIdByAppId),
|
||||||
|
middleware.JsonResponseUtf8Charset(enableUtf8JsonCharsetByApp),
|
||||||
middleware.Authorize(authorization, l.logger),
|
middleware.Authorize(authorization, l.logger),
|
||||||
middleware.AdminAuthorize(l.routes, adminService),
|
middleware.AdminAuthorize(adminService),
|
||||||
middleware.Throttling(throttlingService),
|
middleware.Throttling(throttlingService),
|
||||||
middleware.DailyLimit(dailyLimitService),
|
middleware.DailyLimit(dailyLimitService),
|
||||||
|
middleware.Metrics(metricsStorage),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
errorOnUnknownEndpoint := true
|
||||||
if location.SkipAuth {
|
if location.SkipAuth {
|
||||||
|
errorOnUnknownEndpoint = false
|
||||||
handler = middleware.Chain(
|
handler = middleware.Chain(
|
||||||
proxyFunc,
|
proxyFunc,
|
||||||
|
middleware.Logger(l.logger, config.Logging.RequestLogEnable,
|
||||||
|
enableBodyLog,
|
||||||
|
skipLogging,
|
||||||
|
skipBodyLoggingEndpointPrefixes,
|
||||||
|
config.Logging.EnableForceUnescapingUnicode,
|
||||||
|
),
|
||||||
middleware.RequestId(),
|
middleware.RequestId(),
|
||||||
middleware.Logger(l.logger, config.Logging.RequestLogEnable, enableBodyLog,
|
|
||||||
config.Logging.SkipBodyLoggingEndpointPrefixes),
|
|
||||||
middleware.ErrorHandler(l.logger),
|
middleware.ErrorHandler(l.logger),
|
||||||
|
middleware.ClientRequestId(config.EnableClientRequestIdForwarding, forwardReqIdByAppId),
|
||||||
|
middleware.Metrics(metricsStorage),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
entrypoint := middleware.Entrypoint(
|
entrypoint := middleware.Entrypoint(
|
||||||
config.Http.MaxRequestBodySizeInMb*1024*1024, //nolint:mnd,gomnd
|
config.Http.MaxRequestBodySizeInMb*1024*1024, //nolint:mnd
|
||||||
handler,
|
handler,
|
||||||
l.logger,
|
|
||||||
middleware.EntryPointConfig{
|
middleware.EntryPointConfig{
|
||||||
WithPrefix: location.WithPrefix,
|
WithPrefix: location.WithPrefix,
|
||||||
PathPrefix: location.PathPrefix,
|
PathPrefix: location.PathPrefix,
|
||||||
|
ErrorOnUnknownEndpoint: errorOnUnknownEndpoint,
|
||||||
|
WithLendingSlash: location.Protocol != conf.GrpcProtocol,
|
||||||
|
SkipLogging: skipLogging,
|
||||||
},
|
},
|
||||||
|
l.routes,
|
||||||
|
l.logger,
|
||||||
)
|
)
|
||||||
mux.PathPrefix(location.PathPrefix).Handler(entrypoint)
|
mux.PathPrefix(location.PathPrefix).Handler(entrypoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mux.NotFoundHandler = middleware.UnknownLocation(l.logger, config.Logging.RequestLogEnable, skipLogging)
|
||||||
|
|
||||||
return mux, nil
|
return mux, nil
|
||||||
}
|
}
|
||||||
Vendored
+29
@@ -1,6 +1,7 @@
|
|||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -48,6 +49,34 @@ func (c *Cache) Set(key string, data []byte, lifeTime time.Duration) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StartCleaner runs periodic cleanup.
|
||||||
|
// Blocking call: intended to be run in a separate goroutine.
|
||||||
|
func (c *Cache) StartCleaner(ctx context.Context, interval time.Duration) {
|
||||||
|
ticker := time.NewTicker(interval)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
case <-ticker.C:
|
||||||
|
c.cleanup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Cache) cleanup() {
|
||||||
|
c.lock.Lock()
|
||||||
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
|
now := c.now()
|
||||||
|
for k, v := range c.store {
|
||||||
|
if now.After(v.expiredAt) {
|
||||||
|
delete(c.store, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Cache) now() time.Time {
|
func (c *Cache) now() time.Time {
|
||||||
return time.Now()
|
return time.Now()
|
||||||
}
|
}
|
||||||
+2
-1
@@ -17,8 +17,9 @@ logfile:
|
|||||||
maxBackups: 4
|
maxBackups: 4
|
||||||
compress: true
|
compress: true
|
||||||
|
|
||||||
|
adminServiceName: msp-admin-service
|
||||||
|
|
||||||
locations:
|
locations:
|
||||||
- pathPrefix: /api
|
- pathPrefix: /api
|
||||||
protocol: grpc
|
protocol: grpc
|
||||||
targetModule: router
|
targetModule: router
|
||||||
@@ -24,6 +24,14 @@ locations:
|
|||||||
- pathPrefix: /api/kkd-configuration-service
|
- pathPrefix: /api/kkd-configuration-service
|
||||||
protocol: http
|
protocol: http
|
||||||
targetModule: kkd-configuration-service
|
targetModule: kkd-configuration-service
|
||||||
|
- withPrefix: false
|
||||||
|
pathPrefix: /api/kkd-storage-service/report/download
|
||||||
|
protocol: http
|
||||||
|
targetModule: kkd-storage-service
|
||||||
|
skipAuth: true
|
||||||
|
- pathPrefix: /api/kkd-storage-service
|
||||||
|
protocol: http
|
||||||
|
targetModule: kkd-storage-service
|
||||||
- pathPrefix: /api
|
- pathPrefix: /api
|
||||||
protocol: grpc
|
protocol: grpc
|
||||||
skipAuth: false
|
skipAuth: false
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
"logLevel": "debug",
|
"logLevel": "debug",
|
||||||
"requestLogEnable": true,
|
"requestLogEnable": true,
|
||||||
"bodyLogEnable": false,
|
"bodyLogEnable": false,
|
||||||
"skipBodyLoggingEndpointPrefixes": []
|
"skipBodyLoggingEndpointPrefixes": [],
|
||||||
|
"enableForceUnescapingUnicode": false,
|
||||||
|
"skipLoggingPathPrefixes": []
|
||||||
},
|
},
|
||||||
"caching": {
|
"caching": {
|
||||||
"authenticationDataInSec": 60,
|
"authenticationDataInSec": 60,
|
||||||
|
|||||||
+2
-1
@@ -7,7 +7,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Local struct {
|
type Local struct {
|
||||||
Locations []Location
|
Locations []Location
|
||||||
|
AdminServiceName string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Location struct {
|
type Location struct {
|
||||||
|
|||||||
+59
-30
@@ -4,26 +4,38 @@ package conf
|
|||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"github.com/integration-system/isp-kit/rc/schema"
|
"github.com/txix-open/isp-kit/rc/schema"
|
||||||
"github.com/integration-system/jsonschema"
|
"github.com/txix-open/jsonschema"
|
||||||
"github.com/pkg/errors"
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
HeaderTokenProviderType = "HEADER"
|
||||||
|
CookieTokenProviderType = "COOKIE"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
schema.CustomGenerators.Register("logLevel", func(field reflect.StructField, t *jsonschema.Schema) {
|
schema.CustomGenerators.Register("logLevel", func(field reflect.StructField, t *jsonschema.Schema) {
|
||||||
t.Type = "string"
|
t.Type = "string"
|
||||||
t.Enum = []interface{}{"debug", "info", "warn", "error", "fatal"}
|
t.Enum = []any{"debug", "info", "warn", "error", "fatal"}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type Remote struct {
|
type Remote struct {
|
||||||
Redis *Redis `schema:"Настройки Redis,обязательно, если используется механизм суточных ограничений или ограничений пропускной способности"`
|
Http Http `schema:"Настройки HTTP"`
|
||||||
Http Http `schema:"Настройки HTTP"`
|
Logging Logging `schema:"Настройки логирования"`
|
||||||
Logging Logging `schema:"Настройки логирования"`
|
Caching Caching `schema:"Настройки кеширования"`
|
||||||
Caching Caching `schema:"Настройки кеширования"`
|
DailyLimits []DailyLimit `schema:"Настройки суточных ограничений,сбрасываются раз в сутки в 00:00"`
|
||||||
DailyLimits []DailyLimit `schema:"Настройки суточных ограничений,сбрасываются раз в сутки в 00:00"`
|
Throttling []Throttling `schema:"Настройки пропускной способности"`
|
||||||
Throttling []Throttling `schema:"Настройки пропускной способности"`
|
EnableClientRequestIdForwarding bool `schema:"Включить проброс requestId из заголовка запроса"`
|
||||||
|
ForwardReqIdClientSettings []ForwardReqIdClientSettings `schema:"Настройки проброcа requestId для приложений"`
|
||||||
|
CustomAuth CustomAuth `schema:"Настройка кастомной аутентификации/авторизации"`
|
||||||
|
ResponseContentTypeSettings []ResponseContentTypeSetting `schema:"Настройки Content-Type ответов"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ForwardReqIdClientSettings struct {
|
||||||
|
ApplicationId int `schema:"Идентификатор приложения"`
|
||||||
|
ForwardRequestId bool `schema:"Включить проброс requestId из заголовка запроса"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Http struct {
|
type Http struct {
|
||||||
@@ -35,7 +47,9 @@ type Logging struct {
|
|||||||
LogLevel log.Level `schemaGen:"logLevel" schema:"Уровень логирования,логирование запросов осуществляется на уровне debug"`
|
LogLevel log.Level `schemaGen:"logLevel" schema:"Уровень логирования,логирование запросов осуществляется на уровне debug"`
|
||||||
RequestLogEnable bool `schema:"Включить логирование запросов"`
|
RequestLogEnable bool `schema:"Включить логирование запросов"`
|
||||||
BodyLogEnable bool `schema:"Включить логирование тел запросов и ответов,должно быть включено логирование запросов"`
|
BodyLogEnable bool `schema:"Включить логирование тел запросов и ответов,должно быть включено логирование запросов"`
|
||||||
SkipBodyLoggingEndpointPrefixes []string `schema:"регулярные выражения для отключения логирования"`
|
SkipBodyLoggingEndpointPrefixes []string `schema:"Выключить логирование тел запросов и ответов для путей имеющих префикс из списка,'/' в начале игнорируется"`
|
||||||
|
EnableForceUnescapingUnicode bool `schema:"Включить перевод тел запроса из unicode в utf-8, должно быть включено логирование тел запросов и ответов"`
|
||||||
|
SkipLoggingPathPrefixes []string `schema:"Полностью не логировать запросы к путям с префиксом из списка (сырой path, query не учитывается, '/' в начале игнорируется). Применяется к логу запросов, предупреждению о неизвестном эндпоинте и логу незнакомых locations"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Caching struct {
|
type Caching struct {
|
||||||
@@ -53,26 +67,41 @@ type Throttling struct {
|
|||||||
RequestsPerSeconds int `validate:"required,min=1,max=1000" schema:"Запросов в секунду,не конфликтует с суточными ограничениями, алгоритм не работает на значениях больше 1000"`
|
RequestsPerSeconds int `validate:"required,min=1,max=1000" schema:"Запросов в секунду,не конфликтует с суточными ограничениями, алгоритм не работает на значениях больше 1000"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Redis struct {
|
type CustomAuth struct {
|
||||||
Address string `schema:"Адрес,обязателено, если sentinel не указан"`
|
TokenProviders []TokenProvider `schema:"Настройки получения токена из запроса"`
|
||||||
Username string `schema:"Имя пользовтаеля"`
|
UserAuthSettings []UserAuthSetting `schema:"Настройка пользовательской аутентификации/авторизации"`
|
||||||
Password string `schema:"Пароль"`
|
|
||||||
Sentinel *RedisSentinel `schema:"Настройки sentinel,обязательно, если address не указан"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type RedisSentinel struct {
|
type AuthProvider struct {
|
||||||
Addresses []string `validate:"required" schema:"Адреса нод в кластере"`
|
Name string `schema:"Название настройки аутентификации/авторизации,должно быть уникальным" validate:"required"`
|
||||||
MasterName string `validate:"required" schema:"Имя мастера"`
|
ModuleName string `schema:"Название модуля,реализующего аутентификацию/авторизацию" validate:"required"`
|
||||||
Username string `schema:"Имя пользовтаеля в sentinel"`
|
|
||||||
Password string `schema:"Пароль в sentinel"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Remote) Validate() error {
|
type TokenProvider struct {
|
||||||
if (len(r.Throttling) > 0 || len(r.DailyLimits) > 0) && r.Redis == nil {
|
Name string `schema:"Название метода получения токена из запроса,должно быть уникальным" validate:"required"`
|
||||||
return errors.New("redis is required if dailyLimits or throttling were specified")
|
Type string `schema:"Тип метода получения токена,один из: HEADER COOKIE" validate:"required,oneof=HEADER COOKIE"`
|
||||||
}
|
HeaderProvider *HeaderTokenProvider `schema:"Настройки для получения токена из заголовка"`
|
||||||
if r.Redis != nil && r.Redis.Sentinel == nil && r.Redis.Address == "" {
|
CookieProvider *CookieTokenProvider `schema:"Настройки для получения токена из cookie"`
|
||||||
return errors.New("invalid redis config. sentinel or address are required")
|
}
|
||||||
}
|
|
||||||
return nil
|
type HeaderTokenProvider struct {
|
||||||
|
HeaderName string `schema:"Название заголовка,из которого берётся токен" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CookieTokenProvider struct {
|
||||||
|
CookieName string `schema:"Название cookie,из которого берётся токен" validate:"required"`
|
||||||
|
Validate bool `schema:"Проверить валидность cookie"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserAuthSetting struct {
|
||||||
|
ModuleNameList []string `schema:"Название модулей,для которых настраивается аутентификация/авторизация,название модулей должно быть уникальным" validate:"required"`
|
||||||
|
TokenProviders []string `schema:"Список названий методов получения токена из запроса,используется первый провайдер, вернувший токен"`
|
||||||
|
AuthenticateEndpoint string `schema:"Endpoint для аутентификации пользователя,вызывается через isp-router-service" validate:"required"`
|
||||||
|
CacheDataInSec int `schema:"Время кеширования данных аутентификации/авторизации пользователя,отключен при значениях <=0,в секундах"`
|
||||||
|
SkipAppAuth bool `schema:"Пропустить аутентификацию и авторизацию приложения"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResponseContentTypeSetting struct {
|
||||||
|
ApplicationId int `validate:"required" schema:"ID приложения"`
|
||||||
|
AddJsonUtf8Charset bool `schema:"Добавлять charset=utf-8 в Content-Type ответа: application/json для locations с protocol=http"`
|
||||||
}
|
}
|
||||||
+1
-1
@@ -3,7 +3,7 @@ package conf_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/test/rct"
|
"github.com/txix-open/isp-kit/test/rct"
|
||||||
"isp-gate-service/conf"
|
"isp-gate-service/conf"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+31
-1
@@ -1,8 +1,38 @@
|
|||||||
package domain
|
package domain
|
||||||
|
|
||||||
type AuthData struct {
|
type AuthenticateAppResponse struct {
|
||||||
|
Authenticated bool
|
||||||
|
ErrorReason string
|
||||||
|
AuthData *AppAuthData
|
||||||
|
}
|
||||||
|
|
||||||
|
type AppAuthData struct {
|
||||||
|
AppName string
|
||||||
SystemId int
|
SystemId int
|
||||||
DomainId int
|
DomainId int
|
||||||
ServiceId int
|
ServiceId int
|
||||||
ApplicationId int
|
ApplicationId int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ApplicationToken struct {
|
||||||
|
AppToken string
|
||||||
|
AppName string
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserToken struct {
|
||||||
|
Token string
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuthenticateUserResponse struct {
|
||||||
|
Authenticated bool
|
||||||
|
SkipUserAuth bool
|
||||||
|
ErrorReason string
|
||||||
|
AuthData *UserAuthData
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserAuthData struct {
|
||||||
|
SkipAppAuth bool
|
||||||
|
Identity string
|
||||||
|
IdentityHeader string
|
||||||
|
ExtraHeaders map[string][]string
|
||||||
|
}
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package domain
|
package domain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
type EndpointMeta struct {
|
||||||
|
Inner bool
|
||||||
|
UserAuthRequired bool
|
||||||
|
|
||||||
|
ModuleName string
|
||||||
|
RequiredAdminPermission string
|
||||||
|
// Объявляемый сервисом метод
|
||||||
|
PathSchema string
|
||||||
|
// Вызываемый метод
|
||||||
|
Endpoint string
|
||||||
|
// Нормализованный путь, для известных путей берётся объявляемый метод, для неизвестных - вызываемый
|
||||||
|
// Удаляет '/' из начала пути
|
||||||
|
NormalizedEndpoint string
|
||||||
|
}
|
||||||
|
|
||||||
|
type endpointMetaKey struct{}
|
||||||
|
|
||||||
|
func (m EndpointMeta) ToContext(ctx context.Context) context.Context {
|
||||||
|
return context.WithValue(ctx, endpointMetaKey{}, m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func EndpointMetaFromContext(ctx context.Context) EndpointMeta {
|
||||||
|
meta, _ := ctx.Value(endpointMetaKey{}).(EndpointMeta)
|
||||||
|
return meta
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
import "github.com/txix-open/isp-kit/errors"
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrUserAuthSettingNotFound = errors.New("user auth setting not found")
|
||||||
|
ErrEmptyUserToken = errors.New("failed to extract user token")
|
||||||
|
ErrInvalidUserToken = errors.New("invalid user token")
|
||||||
|
)
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package entity
|
||||||
|
|
||||||
|
type AdminAuthenticateResponse struct {
|
||||||
|
Authenticated bool
|
||||||
|
ErrorReason string
|
||||||
|
AdminId int
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package entity
|
||||||
|
|
||||||
|
type AppAuthData struct {
|
||||||
|
AppName string
|
||||||
|
SystemId int
|
||||||
|
DomainId int
|
||||||
|
ServiceId int
|
||||||
|
ApplicationId int
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package entity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IncrementRequest struct {
|
||||||
|
Key string
|
||||||
|
Today time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
type IncrementResponse struct {
|
||||||
|
Value uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type RateLimiterRequest struct {
|
||||||
|
Key string
|
||||||
|
MaxRps int
|
||||||
|
}
|
||||||
|
|
||||||
|
type RateLimiterResponse struct {
|
||||||
|
Allow bool
|
||||||
|
Remaining int
|
||||||
|
RetryAfter time.Duration
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package domain
|
package entity
|
||||||
|
|
||||||
type AuthenticateRequest struct {
|
type AuthenticateRequest struct {
|
||||||
Token string
|
Token string
|
||||||
@@ -7,11 +7,12 @@ type AuthenticateRequest struct {
|
|||||||
type AuthenticateResponse struct {
|
type AuthenticateResponse struct {
|
||||||
Authenticated bool
|
Authenticated bool
|
||||||
ErrorReason string
|
ErrorReason string
|
||||||
AuthData *AuthData
|
AuthData *AppAuthData
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthorizeRequest struct {
|
type AuthorizeRequest struct {
|
||||||
ApplicationId int
|
ApplicationId int
|
||||||
|
HttpMethod string
|
||||||
Endpoint string
|
Endpoint string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package entity
|
||||||
|
|
||||||
|
type UserAuthenticateRequest struct {
|
||||||
|
Token string
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserAuthenticateResponse struct {
|
||||||
|
Authenticated bool
|
||||||
|
ErrorReason string
|
||||||
|
AuthData *UserAuthData
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserAuthData struct {
|
||||||
|
Identity string
|
||||||
|
IdentityHeader string
|
||||||
|
ExtraHeaders map[string][]string
|
||||||
|
}
|
||||||
@@ -1,77 +1,78 @@
|
|||||||
module isp-gate-service
|
module isp-gate-service
|
||||||
|
|
||||||
go 1.21
|
go 1.27
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-redis/redis_rate/v10 v10.0.1
|
github.com/google/uuid v1.6.0
|
||||||
github.com/google/uuid v1.4.0
|
|
||||||
github.com/gorilla/mux v1.8.1
|
github.com/gorilla/mux v1.8.1
|
||||||
github.com/gorilla/websocket v1.5.1
|
github.com/gorilla/websocket v1.5.3
|
||||||
github.com/integration-system/isp-etp-go/v2 v2.1.3
|
github.com/julienschmidt/httprouter v1.3.0
|
||||||
github.com/integration-system/isp-kit v1.27.0
|
github.com/redis/go-redis/v9 v9.18.0
|
||||||
github.com/integration-system/jsonschema v1.1.0
|
github.com/stretchr/testify v1.12.1
|
||||||
github.com/pkg/errors v0.9.1
|
|
||||||
github.com/redis/go-redis/v9 v9.3.0
|
|
||||||
github.com/stretchr/testify v1.9.0
|
|
||||||
github.com/tomakado/websocketproxy v0.1.0
|
github.com/tomakado/websocketproxy v0.1.0
|
||||||
golang.org/x/net v0.26.0
|
github.com/txix-open/etp/v3 v3.2.0
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4
|
github.com/txix-open/isp-kit v1.76.0
|
||||||
google.golang.org/grpc v1.59.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
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/buger/jsonparser v1.1.1 // indirect
|
github.com/buger/jsonparser v1.6.1 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/coder/websocket v1.8.15 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.16 // indirect
|
||||||
github.com/getsentry/sentry-go v0.25.0 // indirect
|
github.com/getsentry/sentry-go v0.50.0 // indirect
|
||||||
github.com/go-logr/logr v1.3.0 // indirect
|
github.com/go-faker/faker/v4 v4.12.0 // indirect
|
||||||
|
github.com/go-logr/logr v1.4.4 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.2 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.2 // indirect
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
|
|
||||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
|
||||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
|
||||||
github.com/integration-system/bellows v1.0.1 // indirect
|
|
||||||
github.com/integration-system/validator/v10 v10.0.0-20231205122740-49807820d98b // indirect
|
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/julienschmidt/httprouter v1.3.0 // indirect
|
github.com/klauspost/compress v1.20.4 // indirect
|
||||||
github.com/leodido/go-urn v1.2.4 // indirect
|
github.com/leodido/go-urn v1.5.0 // indirect
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.9.2 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pandatix/go-abnf v0.5.5 // indirect
|
||||||
github.com/prometheus/client_golang v1.19.1 // indirect
|
github.com/prometheus/client_golang v1.25.0 // indirect
|
||||||
github.com/prometheus/client_model v0.6.1 // indirect
|
github.com/prometheus/client_model v0.6.3 // indirect
|
||||||
github.com/prometheus/common v0.55.0 // indirect
|
github.com/prometheus/common v0.74.0 // indirect
|
||||||
github.com/prometheus/procfs v0.15.1 // indirect
|
github.com/prometheus/procfs v0.23.0 // 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/wk8/go-ordered-map/v2 v2.1.8 // 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/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.46.1 // indirect
|
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||||
go.opentelemetry.io/otel v1.21.0 // indirect
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
|
go.opentelemetry.io/otel v1.47.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.21.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 // indirect
|
||||||
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
|
go.opentelemetry.io/otel/log v1.47.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.21.0 // indirect
|
go.opentelemetry.io/otel/metric v1.47.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v1.0.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.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
go.uber.org/zap v1.26.0 // indirect
|
go.yaml.in/yaml/v3 v3.0.6 // indirect
|
||||||
golang.org/x/crypto v0.24.0 // indirect
|
golang.org/x/crypto v0.59.0 // indirect
|
||||||
golang.org/x/sys v0.21.0 // indirect
|
golang.org/x/net v0.63.0 // indirect
|
||||||
golang.org/x/text v0.16.0 // indirect
|
golang.org/x/sys v0.50.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 // indirect
|
golang.org/x/text v0.44.0 // indirect
|
||||||
google.golang.org/protobuf v1.34.2 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f // indirect
|
||||||
|
google.golang.org/protobuf v1.36.12 // indirect
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
nhooyr.io/websocket v1.8.10 // indirect
|
|
||||||
)
|
)
|
||||||
@@ -8,150 +8,127 @@ github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
|||||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||||
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
github.com/buger/jsonparser v1.6.1 h1:I0phFv0PlbLHnM7TZAVjZ2MJ2/eWRTDyuO7GLR98IEs=
|
||||||
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
github.com/buger/jsonparser v1.6.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||||
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
|
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
|
||||||
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
|
github.com/coder/websocket v1.8.15 h1:6B2JPeOGlpff2Uz6vOEH1Vzpi0iUz20A+lPVhPHtNUA=
|
||||||
|
github.com/coder/websocket v1.8.15/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/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 h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc=
|
||||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
|
github.com/gabriel-vasile/mimetype v1.4.16 h1:5izNFuvA37st1dDRAcA7TtmngBmRgiIPDmTtiEvjx1E=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
|
github.com/gabriel-vasile/mimetype v1.4.16/go.mod h1:3oFFwxX8kTklZwzIl2aQEDZT0lKY8xH92ST88bAwba4=
|
||||||
github.com/getsentry/sentry-go v0.25.0 h1:q6Eo+hS+yoJlTO3uu/azhQadsD8V+jQn2D8VvX1eOyI=
|
github.com/getsentry/sentry-go v0.50.0 h1:gkO59rn/i0RCAXUUTflC5QVbTQGPXbaFabs2olVzc9g=
|
||||||
github.com/getsentry/sentry-go v0.25.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
|
github.com/getsentry/sentry-go v0.50.0/go.mod h1:+xsDuN+SoRN/xfs1hdq78wnrE3omIZf+FCuh9FOW1C8=
|
||||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
|
||||||
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
|
||||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
||||||
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
||||||
|
github.com/go-faker/faker/v4 v4.12.0 h1:yZXxuoQjxN+C2PVgYoDSHGiD9wj6dX1/Ful4p7QQV0k=
|
||||||
|
github.com/go-faker/faker/v4 v4.12.0/go.mod h1:VFIEwWDd16EdYDLF6NJ5gAAzEp7vz5LgKgJ2iZ17Tdg=
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
|
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
|
||||||
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
|
||||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
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/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
github.com/go-playground/locales v0.14.2 h1:d8UmcrM6Nip0hfGZKLGpAvZH37XB4TS0xzK9B56YNCY=
|
||||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
github.com/go-playground/locales v0.14.2/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/go-playground/universal-translator v0.18.2 h1:LCsMLC9RzmbUMNUPVYD15dmcjwYAJhmX8mPZRW4rAVU=
|
||||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
github.com/go-playground/universal-translator v0.18.2/go.mod h1:67VZIMp5lQpDWlnStOct22q1bkdJGJqHghbOtmkawxk=
|
||||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||||
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
github.com/go-redis/redis_rate/v10 v10.0.1 h1:calPxi7tVlxojKunJwQ72kwfozdy25RjA0bCj1h0MUo=
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
github.com/go-redis/redis_rate/v10 v10.0.1/go.mod h1:EMiuO9+cjRkR7UvdvwMO7vbgqJkltQHtwbdIQvaBKIU=
|
|
||||||
github.com/go-resty/resty/v2 v2.10.0 h1:Qla4W/+TMmv0fOeeRqzEpXPLfTUnR5HZ1+lGs+CkiCo=
|
|
||||||
github.com/go-resty/resty/v2 v2.10.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5BGXiVdTu+A=
|
|
||||||
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
|
|
||||||
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
|
||||||
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
|
|
||||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
|
||||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
|
||||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
|
||||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
|
||||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||||
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 h1:vzlTzzi4tHLa/JQdIE5LeXw6SEX5EVVhq/VPqKHnKOk=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 h1:6UKoz5ujsI55KNpsJH3UwCq3T8kKbZwNZBNPuTTje8U=
|
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.18.1/go.mod h1:YvJ2f6MplWDhfxiUC3KpyTy76kYUZA4W3pTv/wdKQ9Y=
|
|
||||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
|
||||||
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
|
|
||||||
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
|
||||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
|
||||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
|
||||||
github.com/integration-system/bellows v1.0.1 h1:7g1lhD/6EcvsSo9iuiFqw98XGS78Sko6kUKPzfte/SY=
|
|
||||||
github.com/integration-system/bellows v1.0.1/go.mod h1:qHPg1ptN3AHHr0f/wvoicfA2LOCprOyrbXnIa5QIRe0=
|
|
||||||
github.com/integration-system/grmq v1.4.2 h1:BFO9ahqnb3SpMCt5zxaRAh1iiILkC8tqmNcxRHHpmh8=
|
|
||||||
github.com/integration-system/grmq v1.4.2/go.mod h1:DeE6Ceo/A+MuvzdPkuZzqajy0VJhOyH7rRxksQqhEYk=
|
|
||||||
github.com/integration-system/isp-etp-go/v2 v2.1.3 h1:vcHP/PE7p1G3rxqoVKrKtXzoSxFA4ryxigd+zPkAb3w=
|
|
||||||
github.com/integration-system/isp-etp-go/v2 v2.1.3/go.mod h1:ZpB+FIH3hy7md+f8ylVSQx5zwZVjczhkc45f1B2z9nw=
|
|
||||||
github.com/integration-system/isp-kit v1.27.0 h1:NgxEUBrL+1Rv4C1nyfFb5TKu9M7DO3WmTYx5Mk1Vc00=
|
|
||||||
github.com/integration-system/isp-kit v1.27.0/go.mod h1:/2CMMhgRnNehijkUcJLePZGTgTTIiotg2NiUm7rM30o=
|
|
||||||
github.com/integration-system/jsonschema v1.1.0 h1:l9jshYRkImMHfHTPWaUEhP37gX9yW5l7cRHOcIH4g8k=
|
|
||||||
github.com/integration-system/jsonschema v1.1.0/go.mod h1:vrRpWq+l1NFXffXnodH4fYWyt9sLtlx+UJ39S3b/jsA=
|
|
||||||
github.com/integration-system/validator/v10 v10.0.0-20231205122740-49807820d98b h1:/N1rgICVeP04g3+2ATmILUfD2clpHCJ9bzmwqeBw21s=
|
|
||||||
github.com/integration-system/validator/v10 v10.0.0-20231205122740-49807820d98b/go.mod h1:vLdiU06b11Kfto2J+XD6o76cIkGtwQmCBNj65fRuQl4=
|
|
||||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
|
||||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
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/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||||
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
github.com/klauspost/compress v1.20.4 h1:dD0v/bvxtjCBqQu6sx1TNWkalEY5lNTIe+HY9w8TeNI=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/klauspost/compress v1.20.4/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||||
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
|
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||||
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
|
github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0=
|
||||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
github.com/leodido/go-urn v1.5.0/go.mod h1:9BORnCDhdPBJNDEX+w1bJisa8yOKYi116VeO96s4ifE=
|
||||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
github.com/mailru/easyjson v0.9.2 h1:dX8U45hQsZpxd80nLvDGihsQ/OxlvTkVUXH2r/8cb2M=
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
github.com/mailru/easyjson v0.9.2/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
|
||||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
|
||||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
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 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
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 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
|
||||||
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
|
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 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
|
github.com/prometheus/client_golang v1.25.0 h1:cDtW1TcFsMi1RJc8khwCKB4VhzwV04aKqbYtNOXuiK0=
|
||||||
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
|
github.com/prometheus/client_golang v1.25.0/go.mod h1:j2X/4/kaQHLPnmyEU8zjmkndo1T317VpCIQEml8LTKk=
|
||||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
github.com/prometheus/client_model v0.6.3 h1:O0jaTVAYNxTHYInEPFJt5I3+sN8zqBtVMPTB1qyxiEo=
|
||||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
github.com/prometheus/client_model v0.6.3/go.mod h1:gpN5P9S7Rr6Yr92PiQ+Ixvhf6JZEkF1dnxsYL2aPBEM=
|
||||||
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
|
github.com/prometheus/common v0.74.0 h1:6iYW8MsYvmEnXFD9zLGgF0qmReaRhs3OMONu1c/nrLI=
|
||||||
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
|
github.com/prometheus/common v0.74.0/go.mod h1:i/02C+FCst5B1etKgWesNrD49n+onplJCqUCtUKkOeA=
|
||||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
github.com/prometheus/procfs v0.23.0 h1:ad+S6FTkzwaMgacKLM5h6bNKExS+DMH0YiUwXItH/o4=
|
||||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
github.com/prometheus/procfs v0.23.0/go.mod h1:3AVXO0FqLafyYFU/V/IQRZlC8Rgqz8Dm/x6pKLK+RIk=
|
||||||
github.com/rabbitmq/amqp091-go v1.9.0 h1:qrQtyzB4H8BQgEuJwhmVQqVHB9O4+MNDJCCAcpc3Aoo=
|
github.com/rabbitmq/amqp091-go v1.17.0 h1:6KmTqrnJq93cGIE3Q3UnXgsqw6NtLu8MNfFoIbfBAIQ=
|
||||||
github.com/rabbitmq/amqp091-go v1.9.0/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc=
|
github.com/rabbitmq/amqp091-go v1.17.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
||||||
github.com/redis/go-redis/v9 v9.3.0 h1:RiVDjmig62jIWp7Kk4XVLs0hzV6pI3PyTnnL0cnn0u0=
|
github.com/redis/go-redis/v9 v9.18.0 h1:pMkxYPkEbMPwRdenAzUNyFNrDgHx9U+DrBabWNfSRQs=
|
||||||
github.com/redis/go-redis/v9 v9.3.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
|
github.com/redis/go-redis/v9 v9.18.0/go.mod h1:k3ufPphLU5YXwNTUcCRXGxUoF1fqxnhFQmscfkCoDA0=
|
||||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
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/tomakado/websocketproxy v0.1.0 h1:e037TLXDvEYYHlxHE5pqmj/DytFKm2NRn7i4wbVzIyE=
|
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/tomakado/websocketproxy v0.1.0/go.mod h1:EXg/3jcTJYZ04Hsf93RpY90FYA9lj1Sl+VM7lZI6xpM=
|
||||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
|
||||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
|
||||||
|
github.com/txix-open/etp/v3 v3.2.0 h1:EgTchT8VtCYV1iEo/y4jII3/NybrXiQDE0y6pmS350M=
|
||||||
|
github.com/txix-open/etp/v3 v3.2.0/go.mod h1:lgen0TJmiturgBhvlxH1/PQ7iLL/OebKbxPAQYkuKI0=
|
||||||
|
github.com/txix-open/etp/v4 v4.1.3 h1:u9ZyU2yKGgoQ1/DSaElhazWm8xASdqGEdWjoJ2xQlfo=
|
||||||
|
github.com/txix-open/etp/v4 v4.1.3/go.mod h1:9GK+Aje8BmLFq8Hk4j6Qb976LdU9WECCWAuLK1vAKgM=
|
||||||
|
github.com/txix-open/grmq v1.12.0 h1:lSPYvwLfTL0+b0xDQmuuN6RaKS3NCEJNK9ccWpOWa8Y=
|
||||||
|
github.com/txix-open/grmq v1.12.0/go.mod h1:6m9CCTQao/HAFalu5rFOZGJ5KLEP6WzzIwj80Ml3KGE=
|
||||||
|
github.com/txix-open/isp-kit v1.76.0 h1:kqhX2DuoTfeW7BIshedG26TRIfOgX0QOInm606ssGVg=
|
||||||
|
github.com/txix-open/isp-kit v1.76.0/go.mod h1:hR9iAlh3x9gEg5GfALrrkN/2SbGkgZQCmwO2GZWjC1M=
|
||||||
|
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/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
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/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=
|
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||||
@@ -161,79 +138,69 @@ 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/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 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.46.1 h1:gbhw/u49SS3gkPWiYweQNJGm/uJN5GkI/FrosxSHT7A=
|
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.46.1/go.mod h1:GnOaBaFQ2we3b9AGWJpsBa7v1S5RlQzlC3O7dRMxZhM=
|
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJMNjENlcleuuOkGAPH82y0yULBScfXcIEdS24=
|
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1/go.mod h1:sEGXWArGqc3tVa+ekntsN65DmVbVeW+7lTKTjZF3/Fo=
|
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||||
go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc=
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0 h1:jva1c3z2ZFEQ5sTvnLG2tBALNehO+QvdXKQii6eKRoo=
|
||||||
go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo=
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0/go.mod h1:3pjFS5EnOVfjvYO6/NMdtJFHFQR+8uiGtrZ965nZP4w=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 h1:cl5P5/GIfFh4t6xyruOgJP5QiA1pw4fYYdv6nc6CBWw=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 h1:LxwW/9ctSCv+QkE/cLR7M91ZIkXNMqJtEMi1vCw9U8s=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0/go.mod h1:zgBdWWAu7oEEMC06MMKc5NLbA/1YDXV1sMpSqEeLQLg=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0/go.mod h1:tOsftB4SslBwwErVEPaenU2RpThXWPIU8DoJHEC4dyw=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 h1:digkEZCJWobwBqMwC0cwCq8/wkkRy/OowZg5OArWZrM=
|
go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0/go.mod h1:/OpE/y70qVkndM0TrxT4KBoN3RsFZP0QaofcfYrj76I=
|
go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU=
|
||||||
go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 h1:julhjPeUH/q/7hinbSdDdqt5h7Zw9YWmRlWRhI0jd54=
|
||||||
go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0/go.mod h1:Ao2mz688LH/tFf0yMAenidq6k2YNSx6SIY2q6jDACck=
|
||||||
go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 h1:aXZXsZ012wOgVkqaiQv+Z/d8V0xKjmg70F6m4CE94lc=
|
||||||
go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0/go.mod h1:ziu1gUIJhAaxM3EV1e3Ralk5AAyL1UOYz3lJJ4VSI38=
|
||||||
go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc=
|
go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI=
|
||||||
go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ=
|
go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw=
|
||||||
go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I=
|
go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY=
|
||||||
go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM=
|
go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU=
|
||||||
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
|
go.opentelemetry.io/otel/sdk v1.47.0 h1:zWXEr4j2lFefG87TU6Yg8a7ngfohIKFZHKp0Hf5hC6I=
|
||||||
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
|
go.opentelemetry.io/otel/sdk v1.47.0/go.mod h1:VUc24kiOeoGsxG8G9ULx3fWKvB7jMhnGE8Oi607lgR0=
|
||||||
go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo=
|
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.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 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
|
go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo=
|
||||||
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
|
go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
go.yaml.in/yaml/v2 v2.4.5 h1:a5nxWvYi94DRl6QSLlTbLpVmutgx2qg8EVjnJtuFpwI=
|
||||||
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
|
go.yaml.in/yaml/v2 v2.4.5/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
|
||||||
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
|
go.yaml.in/yaml/v3 v3.0.6 h1:zcDfvjXEqTQmpjniUBLc91xYJMB2c4QOFxEF/LCEckM=
|
||||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
go.yaml.in/yaml/v3 v3.0.6/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/crypto v0.59.0 h1:xS2jhqYbzNrpvkWP2YTDf4TJwBy3ykR03i8vFDxEc7c=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/crypto v0.59.0/go.mod h1:veDyUwATGs3c+vN3VfTbzViMGXeTBk3WyhBOkn+F/4U=
|
||||||
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
|
golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0=
|
||||||
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
|
golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs=
|
||||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
|
||||||
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
|
golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
|
||||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f h1:7CbYDSDM5xqpq8v2tNm+Q057COf1lvA0gorVk+304tY=
|
||||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f/go.mod h1:CPxXEEQ1S9iJmInAF/8MNc8tKWnya8I8Kni9Zh2hV0M=
|
||||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f h1:aDW6Vb2T1K0xbAgW+ED8iz39WlgjjX/OKiNh6tXv/+g=
|
||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw=
|
||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
google.golang.org/grpc v1.85.0/go.mod h1:0rQrOD58yjal/0EaVbGBANindixsCZNQPDV3VKtaKuQ=
|
||||||
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f h1:Vn+VyHU5guc9KjB5KrjI2q0wCOWEOIh0OEsleqakHJg=
|
|
||||||
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f/go.mod h1:nWSwAFPb+qfNJXsoeO3Io7zf4tMSfN8EA8RlDA04GhY=
|
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 h1:ZcOkrmX74HbKFYnpPY8Qsw93fC29TbJXspYKaBkSXDQ=
|
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4/go.mod h1:k2dtGpRrbsSyKcNPKKI5sstZkrNCZwpU/ns96JoHbGg=
|
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 h1:DC7wcm+i+P1rN3Ff07vL+OndGg5OhNddHyTA+ocPqYE=
|
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4/go.mod h1:eJVxU6o+4G1PSczBr85xmyvSNYAKvAYgkub40YGomFM=
|
|
||||||
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
|
|
||||||
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
|
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
|
||||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
|
||||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/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 h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
|
|
||||||
nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
|
|
||||||
nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
|
|
||||||
@@ -0,0 +1,402 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1977-02-22\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"38924\",\"flat\":\"185\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Сергей\",\"middleName\":\"Петрович\",\"birthDay\":\"1977-02-22\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"38924\",\"flat\":\"185\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1950-08-18\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"63988\",\"flat\":\"78\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Петров\",\"firstName\":\"Иван\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1950-08-18\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"63988\",\"flat\":\"78\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1991-01-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"07460\",\"flat\":\"39\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Сергей\",\"middleName\":\"Козлович\",\"birthDay\":\"1991-01-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"07460\",\"flat\":\"39\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1982-05-17\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"31319\",\"flat\":\"191\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Иван\",\"middleName\":\"Петрович\",\"birthDay\":\"1982-05-17\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"31319\",\"flat\":\"191\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1993-01-13\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"70892\",\"flat\":\"51\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Алексей\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1993-01-13\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"70892\",\"flat\":\"51\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1963-10-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"64647\",\"flat\":\"176\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Петров\",\"firstName\":\"Петр\",\"middleName\":\"Михайлович\",\"birthDay\":\"1963-10-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"64647\",\"flat\":\"176\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1997-01-27\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"05466\",\"flat\":\"101\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Петров\",\"firstName\":\"Алексей\",\"middleName\":\"Козлович\",\"birthDay\":\"1997-01-27\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"05466\",\"flat\":\"101\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1985-06-07\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"62526\",\"flat\":\"40\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Петр\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1985-06-07\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"62526\",\"flat\":\"40\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1964-02-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"67088\",\"flat\":\"111\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Иван\",\"middleName\":\"Петрович\",\"birthDay\":\"1964-02-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"67088\",\"flat\":\"111\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1985-11-07\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"59230\",\"flat\":\"143\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Михаил\",\"middleName\":\"Козлович\",\"birthDay\":\"1985-11-07\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"59230\",\"flat\":\"143\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1988-10-25\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"03392\",\"flat\":\"180\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Сергей\",\"middleName\":\"Козлович\",\"birthDay\":\"1988-10-25\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"03392\",\"flat\":\"180\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1977-06-16\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"20665\",\"flat\":\"166\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Алексей\",\"middleName\":\"Козлович\",\"birthDay\":\"1977-06-16\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"20665\",\"flat\":\"166\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1987-12-12\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"66035\",\"flat\":\"90\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Сергей\",\"middleName\":\"Козлович\",\"birthDay\":\"1987-12-12\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"66035\",\"flat\":\"90\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1974-02-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"39439\",\"flat\":\"148\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Алексей\",\"middleName\":\"Петрович\",\"birthDay\":\"1974-02-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"39439\",\"flat\":\"148\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1989-02-21\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"01481\",\"flat\":\"147\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Сергей\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1989-02-21\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"01481\",\"flat\":\"147\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1952-11-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"54019\",\"flat\":\"67\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Петр\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1952-11-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"54019\",\"flat\":\"67\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1967-04-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"80312\",\"flat\":\"79\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Сергей\",\"middleName\":\"Иванович\",\"birthDay\":\"1967-04-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"80312\",\"flat\":\"79\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1951-12-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"60752\",\"flat\":\"136\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Иван\",\"middleName\":\"Козлович\",\"birthDay\":\"1951-12-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"60752\",\"flat\":\"136\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1989-07-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"52236\",\"flat\":\"49\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Петров\",\"firstName\":\"Михаил\",\"middleName\":\"Козлович\",\"birthDay\":\"1989-07-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"52236\",\"flat\":\"49\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1961-06-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"48602\",\"flat\":\"159\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Петр\",\"middleName\":\"Козлович\",\"birthDay\":\"1961-06-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"48602\",\"flat\":\"159\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1966-11-11\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"30072\",\"flat\":\"58\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Сергей\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1966-11-11\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"30072\",\"flat\":\"58\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1974-08-21\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"22508\",\"flat\":\"80\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Михаил\",\"middleName\":\"Петрович\",\"birthDay\":\"1974-08-21\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"22508\",\"flat\":\"80\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1993-04-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"31222\",\"flat\":\"130\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Михаил\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1993-04-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"31222\",\"flat\":\"130\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1969-11-17\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"43510\",\"flat\":\"98\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Петр\",\"middleName\":\"Петрович\",\"birthDay\":\"1969-11-17\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"43510\",\"flat\":\"98\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1965-04-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"93733\",\"flat\":\"39\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Алексей\",\"middleName\":\"Петрович\",\"birthDay\":\"1965-04-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"93733\",\"flat\":\"39\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1969-05-28\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"87093\",\"flat\":\"167\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Алексей\",\"middleName\":\"Михайлович\",\"birthDay\":\"1969-05-28\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"87093\",\"flat\":\"167\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1951-12-24\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"27732\",\"flat\":\"112\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Сергей\",\"middleName\":\"Михайлович\",\"birthDay\":\"1951-12-24\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"27732\",\"flat\":\"112\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1989-07-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"31765\",\"flat\":\"51\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Михаил\",\"middleName\":\"Михайлович\",\"birthDay\":\"1989-07-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"31765\",\"flat\":\"51\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1978-05-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"96998\",\"flat\":\"180\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Алексей\",\"middleName\":\"Иванович\",\"birthDay\":\"1978-05-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"96998\",\"flat\":\"180\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1993-10-12\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"01064\",\"flat\":\"100\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Михаил\",\"middleName\":\"Михайлович\",\"birthDay\":\"1993-10-12\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"01064\",\"flat\":\"100\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1993-04-19\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"45967\",\"flat\":\"82\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Петр\",\"middleName\":\"Иванович\",\"birthDay\":\"1993-04-19\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"45967\",\"flat\":\"82\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1981-08-21\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"74957\",\"flat\":\"64\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Петров\",\"firstName\":\"Петр\",\"middleName\":\"Михайлович\",\"birthDay\":\"1981-08-21\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"74957\",\"flat\":\"64\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1993-01-10\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"19023\",\"flat\":\"22\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Алексей\",\"middleName\":\"Михайлович\",\"birthDay\":\"1993-01-10\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"19023\",\"flat\":\"22\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1962-01-27\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"73929\",\"flat\":\"198\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Сергей\",\"middleName\":\"Козлович\",\"birthDay\":\"1962-01-27\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"73929\",\"flat\":\"198\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1956-08-03\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"46793\",\"flat\":\"83\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Петр\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1956-08-03\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"46793\",\"flat\":\"83\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1954-04-17\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"22410\",\"flat\":\"162\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Сергей\",\"middleName\":\"Петрович\",\"birthDay\":\"1954-04-17\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"22410\",\"flat\":\"162\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1991-12-20\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"92089\",\"flat\":\"62\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Петров\",\"firstName\":\"Иван\",\"middleName\":\"Петрович\",\"birthDay\":\"1991-12-20\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"92089\",\"flat\":\"62\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1970-10-10\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"91849\",\"flat\":\"22\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Иван\",\"middleName\":\"Иванович\",\"birthDay\":\"1970-10-10\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"91849\",\"flat\":\"22\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1952-07-25\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"49639\",\"flat\":\"87\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Сергей\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1952-07-25\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"49639\",\"flat\":\"87\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1967-03-09\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"43225\",\"flat\":\"165\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Иван\",\"middleName\":\"Петрович\",\"birthDay\":\"1967-03-09\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"43225\",\"flat\":\"165\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1969-05-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"90629\",\"flat\":\"102\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Алексей\",\"middleName\":\"Иванович\",\"birthDay\":\"1969-05-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"90629\",\"flat\":\"102\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1989-07-13\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"14363\",\"flat\":\"38\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Михаил\",\"middleName\":\"Козлович\",\"birthDay\":\"1989-07-13\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"14363\",\"flat\":\"38\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1992-12-26\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"80159\",\"flat\":\"66\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Алексей\",\"middleName\":\"Козлович\",\"birthDay\":\"1992-12-26\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"80159\",\"flat\":\"66\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1982-05-14\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"76418\",\"flat\":\"69\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Сергей\",\"middleName\":\"Михайлович\",\"birthDay\":\"1982-05-14\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"76418\",\"flat\":\"69\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1966-08-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"63785\",\"flat\":\"185\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Михаил\",\"middleName\":\"Петрович\",\"birthDay\":\"1966-08-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"63785\",\"flat\":\"185\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1985-06-22\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"35007\",\"flat\":\"72\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Иван\",\"middleName\":\"Михайлович\",\"birthDay\":\"1985-06-22\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"35007\",\"flat\":\"72\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1966-07-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"78468\",\"flat\":\"85\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Алексей\",\"middleName\":\"Козлович\",\"birthDay\":\"1966-07-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"78468\",\"flat\":\"85\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1959-10-28\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"40385\",\"flat\":\"40\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Михаил\",\"middleName\":\"Михайлович\",\"birthDay\":\"1959-10-28\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"40385\",\"flat\":\"40\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1982-07-15\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"20633\",\"flat\":\"74\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Алексей\",\"middleName\":\"Козлович\",\"birthDay\":\"1982-07-15\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"20633\",\"flat\":\"74\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1983-11-27\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"61366\",\"flat\":\"140\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Иван\",\"middleName\":\"Петрович\",\"birthDay\":\"1983-11-27\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"61366\",\"flat\":\"140\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1991-10-02\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"05236\",\"flat\":\"4\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Сергей\",\"middleName\":\"Михайлович\",\"birthDay\":\"1991-10-02\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"05236\",\"flat\":\"4\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1960-08-17\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"01631\",\"flat\":\"93\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Петров\",\"firstName\":\"Петр\",\"middleName\":\"Козлович\",\"birthDay\":\"1960-08-17\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"01631\",\"flat\":\"93\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1999-09-17\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"76893\",\"flat\":\"170\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Сергей\",\"middleName\":\"Козлович\",\"birthDay\":\"1999-09-17\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"76893\",\"flat\":\"170\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1966-01-20\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"72424\",\"flat\":\"98\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Алексей\",\"middleName\":\"Козлович\",\"birthDay\":\"1966-01-20\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"72424\",\"flat\":\"98\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1977-06-24\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"04063\",\"flat\":\"82\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Михаил\",\"middleName\":\"Петрович\",\"birthDay\":\"1977-06-24\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"04063\",\"flat\":\"82\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1969-04-13\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"43443\",\"flat\":\"80\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Сергей\",\"middleName\":\"Петрович\",\"birthDay\":\"1969-04-13\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"43443\",\"flat\":\"80\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1950-11-03\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"83732\",\"flat\":\"46\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Иван\",\"middleName\":\"Иванович\",\"birthDay\":\"1950-11-03\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"83732\",\"flat\":\"46\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1958-04-03\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"91863\",\"flat\":\"47\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Иван\",\"middleName\":\"Михайлович\",\"birthDay\":\"1958-04-03\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"91863\",\"flat\":\"47\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1953-10-26\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"67751\",\"flat\":\"61\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Алексей\",\"middleName\":\"Иванович\",\"birthDay\":\"1953-10-26\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"67751\",\"flat\":\"61\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1988-01-28\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"14661\",\"flat\":\"58\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Михаил\",\"middleName\":\"Козлович\",\"birthDay\":\"1988-01-28\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"14661\",\"flat\":\"58\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1981-12-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"10812\",\"flat\":\"57\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Алексей\",\"middleName\":\"Козлович\",\"birthDay\":\"1981-12-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"10812\",\"flat\":\"57\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1970-01-20\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"87418\",\"flat\":\"150\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Михаил\",\"middleName\":\"Иванович\",\"birthDay\":\"1970-01-20\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"87418\",\"flat\":\"150\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1952-02-20\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"71225\",\"flat\":\"39\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Иван\",\"middleName\":\"Иванович\",\"birthDay\":\"1952-02-20\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"71225\",\"flat\":\"39\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1993-08-15\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"80780\",\"flat\":\"188\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Иван\",\"middleName\":\"Михайлович\",\"birthDay\":\"1993-08-15\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"80780\",\"flat\":\"188\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1981-07-07\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"17884\",\"flat\":\"138\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Петр\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1981-07-07\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"17884\",\"flat\":\"138\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1963-01-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"75966\",\"flat\":\"12\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Петр\",\"middleName\":\"Михайлович\",\"birthDay\":\"1963-01-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"75966\",\"flat\":\"12\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1962-11-13\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"80065\",\"flat\":\"79\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Михаил\",\"middleName\":\"Иванович\",\"birthDay\":\"1962-11-13\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"80065\",\"flat\":\"79\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1963-07-18\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"42476\",\"flat\":\"4\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Алексей\",\"middleName\":\"Иванович\",\"birthDay\":\"1963-07-18\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"42476\",\"flat\":\"4\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1961-12-18\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"34741\",\"flat\":\"200\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Иван\",\"middleName\":\"Козлович\",\"birthDay\":\"1961-12-18\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"34741\",\"flat\":\"200\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1998-06-17\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"46796\",\"flat\":\"144\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Петр\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1998-06-17\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"46796\",\"flat\":\"144\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1965-07-24\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"98293\",\"flat\":\"188\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Михаил\",\"middleName\":\"Козлович\",\"birthDay\":\"1965-07-24\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"98293\",\"flat\":\"188\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1980-12-27\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"67475\",\"flat\":\"122\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Петров\",\"firstName\":\"Иван\",\"middleName\":\"Петрович\",\"birthDay\":\"1980-12-27\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"67475\",\"flat\":\"122\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1981-02-25\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"90604\",\"flat\":\"63\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Иван\",\"middleName\":\"Козлович\",\"birthDay\":\"1981-02-25\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"90604\",\"flat\":\"63\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1954-05-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"37669\",\"flat\":\"28\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Алексей\",\"middleName\":\"Козлович\",\"birthDay\":\"1954-05-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"37669\",\"flat\":\"28\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1981-09-22\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"32425\",\"flat\":\"25\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Петров\",\"firstName\":\"Иван\",\"middleName\":\"Козлович\",\"birthDay\":\"1981-09-22\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"32425\",\"flat\":\"25\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1964-11-16\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"41589\",\"flat\":\"105\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Иван\",\"middleName\":\"Михайлович\",\"birthDay\":\"1964-11-16\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"41589\",\"flat\":\"105\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1969-12-25\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"06495\",\"flat\":\"32\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Петров\",\"firstName\":\"Петр\",\"middleName\":\"Петрович\",\"birthDay\":\"1969-12-25\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"06495\",\"flat\":\"32\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1969-01-19\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"58569\",\"flat\":\"79\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Петр\",\"middleName\":\"Иванович\",\"birthDay\":\"1969-01-19\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"58569\",\"flat\":\"79\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1983-01-11\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"39765\",\"flat\":\"162\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Алексей\",\"middleName\":\"Козлович\",\"birthDay\":\"1983-01-11\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"39765\",\"flat\":\"162\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1956-07-20\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"24412\",\"flat\":\"118\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Петр\",\"middleName\":\"Михайлович\",\"birthDay\":\"1956-07-20\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"24412\",\"flat\":\"118\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1981-08-20\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"45511\",\"flat\":\"88\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Михаил\",\"middleName\":\"Иванович\",\"birthDay\":\"1981-08-20\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"45511\",\"flat\":\"88\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1951-12-02\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"19511\",\"flat\":\"53\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Сергей\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1951-12-02\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"19511\",\"flat\":\"53\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1963-06-22\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"17982\",\"flat\":\"62\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Иван\",\"middleName\":\"Михайлович\",\"birthDay\":\"1963-06-22\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"17982\",\"flat\":\"62\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1960-11-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"52978\",\"flat\":\"30\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Алексей\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1960-11-06\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"52978\",\"flat\":\"30\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1966-01-25\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"75948\",\"flat\":\"49\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Михаил\",\"middleName\":\"Иванович\",\"birthDay\":\"1966-01-25\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"75948\",\"flat\":\"49\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1986-06-02\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"23634\",\"flat\":\"64\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Сергей\",\"middleName\":\"Иванович\",\"birthDay\":\"1986-06-02\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"23634\",\"flat\":\"64\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1969-11-07\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"26792\",\"flat\":\"87\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Михаил\",\"middleName\":\"Иванович\",\"birthDay\":\"1969-11-07\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"26792\",\"flat\":\"87\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1956-09-07\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"70768\",\"flat\":\"108\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Иван\",\"middleName\":\"Петрович\",\"birthDay\":\"1956-09-07\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"70768\",\"flat\":\"108\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0410\\u043B\\u0435\\u043A\\u0441\\u0435\\u0439\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1998-07-14\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"18771\",\"flat\":\"178\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Алексей\",\"middleName\":\"Михайлович\",\"birthDay\":\"1998-07-14\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"18771\",\"flat\":\"178\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1999-02-19\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"01147\",\"flat\":\"162\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Михаил\",\"middleName\":\"Петрович\",\"birthDay\":\"1999-02-19\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"01147\",\"flat\":\"162\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1959-02-10\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"45931\",\"flat\":\"179\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Иван\",\"middleName\":\"Михайлович\",\"birthDay\":\"1959-02-10\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"45931\",\"flat\":\"179\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0421\\u0438\\u0434\\u043E\\u0440\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1967-07-19\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"42295\",\"flat\":\"130\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Сидоров\",\"firstName\":\"Михаил\",\"middleName\":\"Петрович\",\"birthDay\":\"1967-07-19\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"42295\",\"flat\":\"130\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1961-11-21\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"14998\",\"flat\":\"185\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Сергей\",\"middleName\":\"Иванович\",\"birthDay\":\"1961-11-21\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"14998\",\"flat\":\"185\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041C\\u0438\\u0445\\u0430\\u0438\\u043B\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1963-08-11\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"31521\",\"flat\":\"198\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Михаил\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1963-08-11\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"31521\",\"flat\":\"198\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1965-09-26\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"50495\",\"flat\":\"67\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Сергей\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1965-09-26\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"50495\",\"flat\":\"67\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0418\\u0432\\u0430\\u043D\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1950-05-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"96951\",\"flat\":\"179\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Иван\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1950-05-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"96951\",\"flat\":\"179\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1998-01-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"59966\",\"flat\":\"108\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Петр\",\"middleName\":\"Козлович\",\"birthDay\":\"1998-01-23\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"59966\",\"flat\":\"108\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u0418\\u0432\\u0430\\u043D\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1981-02-14\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"49056\",\"flat\":\"113\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Иванов\",\"firstName\":\"Сергей\",\"middleName\":\"Петрович\",\"birthDay\":\"1981-02-14\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"49056\",\"flat\":\"113\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041A\\u043E\\u0437\\u043B\\u043E\\u0432\",\"firstName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0439\",\"middleName\":\"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432\\u0438\\u0447\",\"birthDay\":\"1995-08-26\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"27045\",\"flat\":\"107\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Козлов\",\"firstName\":\"Сергей\",\"middleName\":\"Петрович\",\"birthDay\":\"1995-08-26\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"27045\",\"flat\":\"107\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"raw": "{\"fiodr\":{\"lastName\":\"\\u041C\\u0438\\u0445\\u0430\\u0439\\u043B\\u043E\\u0432\",\"firstName\":\"\\u041F\\u0435\\u0442\\u0440\",\"middleName\":\"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447\",\"birthDay\":\"1958-07-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"35022\",\"flat\":\"180\"}}",
|
||||||
|
"expected": "{\"fiodr\":{\"lastName\":\"Михайлов\",\"firstName\":\"Петр\",\"middleName\":\"Сергеевич\",\"birthDay\":\"1958-07-05\"},\"objectType\":\"addresses.addr_registration\",\"params\":{\"unom\":\"35022\",\"flat\":\"180\"}}"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
// nolint:mnd,gosec
|
||||||
|
package helpers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/json"
|
||||||
|
)
|
||||||
|
|
||||||
|
func UnescapeUnicodeJson(data []byte) []byte {
|
||||||
|
var body any
|
||||||
|
err := json.Unmarshal(data, &body)
|
||||||
|
if err != nil {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
newData, err := json.Marshal(body)
|
||||||
|
if err != nil {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
return newData
|
||||||
|
}
|
||||||
|
|
||||||
|
func UnescapeUnicode(data []byte) []byte {
|
||||||
|
n := len(data)
|
||||||
|
out := make([]byte, len(data)) // максимально возможный размер
|
||||||
|
j := 0 // индекс записи
|
||||||
|
|
||||||
|
for i := 0; i < n; {
|
||||||
|
if data[i] != '\\' {
|
||||||
|
// копируем весь блок до следующего '\'
|
||||||
|
start := i
|
||||||
|
for i < n && data[i] != '\\' {
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
j += copy(out[j:], data[start:i])
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if isUnicodeEscape(data, i) {
|
||||||
|
r, consumed := decodeUnicodeEscape(data[i:])
|
||||||
|
if r >= 0 {
|
||||||
|
j = appendRuneAt(out, j, uint32(r))
|
||||||
|
i += consumed
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// обычный байт (одиночный '\')
|
||||||
|
out[j] = data[i]
|
||||||
|
j++
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
|
||||||
|
return out[:j]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Проверяет, начинается ли здесь \uXXXX
|
||||||
|
func isUnicodeEscape(data []byte, i int) bool {
|
||||||
|
return i+5 < len(data) && data[i] == '\\' && data[i+1] == 'u'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Декодирует \uXXXX, учитывая суррогатную пару.
|
||||||
|
// Возвращает руну и сколько байт было прочитано.
|
||||||
|
func decodeUnicodeEscape(data []byte) (rune, int) {
|
||||||
|
v1, ok := parseHex4(data[2:6])
|
||||||
|
if !ok {
|
||||||
|
return -1, 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Проверка суррогатной пары
|
||||||
|
if 0xD800 <= v1 && v1 <= 0xDBFF && isUnicodeEscape(data, 6) {
|
||||||
|
v2, ok2 := parseHex4(data[8:12])
|
||||||
|
if ok2 && 0xDC00 <= v2 && v2 <= 0xDFFF {
|
||||||
|
r := 0x10000 + ((uint32(v1)-0xD800)<<10 | (uint32(v2) - 0xDC00))
|
||||||
|
return rune(r), 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rune(v1), 6
|
||||||
|
}
|
||||||
|
|
||||||
|
// Парсим 4 hex-символа через hexValue
|
||||||
|
func parseHex4(b []byte) (uint16, bool) {
|
||||||
|
v := uint16(0)
|
||||||
|
for _, c := range b {
|
||||||
|
h, ok := hexValue(c)
|
||||||
|
if !ok {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
v = v<<4 | h
|
||||||
|
}
|
||||||
|
return v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
func hexValue(b byte) (uint16, bool) {
|
||||||
|
switch {
|
||||||
|
case '0' <= b && b <= '9':
|
||||||
|
return uint16(b - '0'), true
|
||||||
|
case 'a' <= b && b <= 'f':
|
||||||
|
return uint16(b - 'a' + 10), true
|
||||||
|
case 'A' <= b && b <= 'F':
|
||||||
|
return uint16(b - 'A' + 10), true
|
||||||
|
default:
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// appendRune добавляет руну в UTF-8
|
||||||
|
func appendRuneAt(buf []byte, j int, r uint32) int {
|
||||||
|
p := (*[4]byte)(unsafe.Pointer(&buf[j]))
|
||||||
|
switch {
|
||||||
|
case r < 0x80:
|
||||||
|
p[0] = byte(r)
|
||||||
|
return j + 1
|
||||||
|
case r < 0x800:
|
||||||
|
p[0] = 0xC0 | byte(r>>6)
|
||||||
|
p[1] = 0x80 | byte(r&0x3F)
|
||||||
|
return j + 2
|
||||||
|
case r < 0x10000:
|
||||||
|
p[0] = 0xE0 | byte(r>>12)
|
||||||
|
p[1] = 0x80 | byte((r>>6)&0x3F)
|
||||||
|
p[2] = 0x80 | byte(r&0x3F)
|
||||||
|
return j + 3
|
||||||
|
default:
|
||||||
|
p[0] = 0xF0 | byte(r>>18)
|
||||||
|
p[1] = 0x80 | byte((r>>12)&0x3F)
|
||||||
|
p[2] = 0x80 | byte((r>>6)&0x3F)
|
||||||
|
p[3] = 0x80 | byte(r&0x3F)
|
||||||
|
return j + 4
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package helpers_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"isp-gate-service/helpers"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// nolint:gochecknoglobals,lll
|
||||||
|
var (
|
||||||
|
rawUnicode = []byte(`{"fiodr":{"lastName":"\\u041F\\u0435\\u0442\\u0440\\u043E\\u0432","firstName":"\\u0418\\u0432\\u0430\\u043D","middleName":"\\u0421\\u0435\\u0440\\u0433\\u0435\\u0435\\u0432\\u0438\\u0447","birthDay":"1950-08-18"},"objectType":"addresses.addr_registration","params":{"unom":"63988","flat":"78"}}`)
|
||||||
|
rawAscii = []byte(`{"fiodr":{"lastName":"Петров","firstName":"Иван","middleName":"Сергеевич","birthDay":"1950-08-18"},"objectType":"addresses.addr_registration","params":{"unom":"63988","flat":"78"}}`)
|
||||||
|
)
|
||||||
|
|
||||||
|
func Benchmark_UnescapeUnicodeJson_Unicode(b *testing.B) {
|
||||||
|
for b.Loop() {
|
||||||
|
_ = helpers.UnescapeUnicodeJson(rawUnicode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_UnescapeUnicodeJson_Anscii(b *testing.B) {
|
||||||
|
for b.Loop() {
|
||||||
|
_ = helpers.UnescapeUnicodeJson(rawAscii)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_UnescapeUnicode_Unicode(b *testing.B) {
|
||||||
|
for b.Loop() {
|
||||||
|
_ = helpers.UnescapeUnicode(rawUnicode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_UnescapeUnicode_Anscii(b *testing.B) {
|
||||||
|
for b.Loop() {
|
||||||
|
_ = helpers.UnescapeUnicode(rawAscii)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package helpers_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"isp-gate-service/helpers"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/json"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestForceUnescapingUnicode(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
type testCase struct {
|
||||||
|
Raw string
|
||||||
|
Expected string
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := os.ReadFile("./test_data/json_cases.json")
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
var testCases []testCase
|
||||||
|
require.NoError(t, json.Unmarshal(data, &testCases))
|
||||||
|
|
||||||
|
for i, tt := range testCases {
|
||||||
|
t.Run(fmt.Sprintf("case_%d", i), func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
out := helpers.UnescapeUnicode([]byte(tt.Raw))
|
||||||
|
require.JSONEq(t, tt.Expected, string(out))
|
||||||
|
|
||||||
|
jsonOut := helpers.UnescapeUnicodeJson([]byte(tt.Raw))
|
||||||
|
require.JSONEq(t, tt.Expected, string(jsonOut))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,32 +3,32 @@ package httperrors
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/json"
|
"github.com/txix-open/isp-kit/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HttpError struct {
|
type HttpError struct {
|
||||||
statusCode int
|
statusCode int
|
||||||
userMessage string
|
userMessage string
|
||||||
details []interface{}
|
details []any
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(statusCode int, userMessage string, internalError error) HttpError {
|
func New(statusCode int, userMessage string, internalError error) *HttpError {
|
||||||
return HttpError{
|
return &HttpError{
|
||||||
statusCode: statusCode,
|
statusCode: statusCode,
|
||||||
userMessage: userMessage,
|
userMessage: userMessage,
|
||||||
err: internalError,
|
err: internalError,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e HttpError) Error() string {
|
func (e *HttpError) Error() string {
|
||||||
return e.err.Error()
|
return e.err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e HttpError) WriteError(w http.ResponseWriter) error {
|
func (e *HttpError) WriteError(w http.ResponseWriter) error {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.WriteHeader(e.statusCode)
|
w.WriteHeader(e.statusCode)
|
||||||
data := map[string]interface{}{
|
data := map[string]any{
|
||||||
"errorCode": http.StatusText(e.statusCode),
|
"errorCode": http.StatusText(e.statusCode),
|
||||||
"errorMessage": e.userMessage,
|
"errorMessage": e.userMessage,
|
||||||
"details": e.details,
|
"details": e.details,
|
||||||
@@ -36,6 +36,6 @@ func (e HttpError) WriteError(w http.ResponseWriter) error {
|
|||||||
return json.NewEncoder(w).Encode(data)
|
return json.NewEncoder(w).Encode(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *HttpError) WithDetails(details ...interface{}) {
|
func (e *HttpError) WithDetails(details ...any) {
|
||||||
e.details = details
|
e.details = details
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/integration-system/isp-kit/bootstrap"
|
|
||||||
"github.com/integration-system/isp-kit/shutdown"
|
|
||||||
"isp-gate-service/assembly"
|
"isp-gate-service/assembly"
|
||||||
"isp-gate-service/conf"
|
"isp-gate-service/conf"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/bootstrap"
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/shutdown"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -12,7 +14,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
boot := bootstrap.New(version, conf.Remote{}, nil)
|
boot := bootstrap.New(version, conf.Remote{}, nil, cluster.HttpTransport)
|
||||||
app := boot.App
|
app := boot.App
|
||||||
logger := app.Logger()
|
logger := app.Logger()
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -4,24 +4,21 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AdminMethodStore interface {
|
|
||||||
IsInnerEndpoint(path string) bool
|
|
||||||
RequiredAdminPermission(path string) (string, bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
type AdminAuthorizer interface {
|
type AdminAuthorizer interface {
|
||||||
AdminAuthorize(ctx context.Context, adminId int, permission string) (bool, error)
|
AdminAuthorize(ctx context.Context, adminId int, permission string) (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func AdminAuthorize(store AdminMethodStore, authorizer AdminAuthorizer) Middleware {
|
func AdminAuthorize(authorizer AdminAuthorizer) Middleware {
|
||||||
return func(next Handler) Handler {
|
return func(next Handler) Handler {
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
return HandlerFunc(func(ctx *request.Context) error {
|
||||||
isInner := store.IsInnerEndpoint(ctx.Endpoint())
|
endpointMeta := ctx.EndpointMeta()
|
||||||
|
|
||||||
|
isInner := endpointMeta.Inner
|
||||||
if !isInner {
|
if !isInner {
|
||||||
return next.Handle(ctx)
|
return next.Handle(ctx)
|
||||||
}
|
}
|
||||||
@@ -30,12 +27,13 @@ func AdminAuthorize(store AdminMethodStore, authorizer AdminAuthorizer) Middlewa
|
|||||||
return httperrors.New(
|
return httperrors.New(
|
||||||
http.StatusForbidden,
|
http.StatusForbidden,
|
||||||
"admin authentication required",
|
"admin authentication required",
|
||||||
errors.Errorf("admin authorization: admin authentication required for '%s'", ctx.Endpoint()),
|
errors.Errorf("admin authorization: admin authentication required for '%s'",
|
||||||
|
endpointMeta.Endpoint),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
requiredPerm, ok := store.RequiredAdminPermission(ctx.Endpoint())
|
requiredPerm := endpointMeta.RequiredAdminPermission
|
||||||
if !ok {
|
if requiredPerm == "" {
|
||||||
return next.Handle(ctx)
|
return next.Handle(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +47,7 @@ func AdminAuthorize(store AdminMethodStore, authorizer AdminAuthorizer) Middlewa
|
|||||||
"endpoint is not allowed",
|
"endpoint is not allowed",
|
||||||
errors.Errorf(
|
errors.Errorf(
|
||||||
"admin authorization: endpoint '%s' requires '%s' permission, but admin '%d' doesn't have it",
|
"admin authorization: endpoint '%s' requires '%s' permission, but admin '%d' doesn't have it",
|
||||||
ctx.Endpoint(), requiredPerm, ctx.AdminId(),
|
endpointMeta.Endpoint, requiredPerm, ctx.AdminId(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -15,13 +16,20 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Authenticator interface {
|
type Authenticator interface {
|
||||||
Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error)
|
Authenticate(ctx context.Context, token string) (*domain.AuthenticateAppResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Authenticate(authenticator Authenticator) Middleware {
|
func Authenticate(authenticator Authenticator) Middleware {
|
||||||
return func(next Handler) Handler {
|
return func(next Handler) Handler {
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
return HandlerFunc(func(ctx *request.Context) error {
|
||||||
token := ctx.Param(applicationTokenHeader)
|
if ctx.SkipAppAuth() {
|
||||||
|
return next.Handle(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
token, appName, err := extractToken(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if token == "" {
|
if token == "" {
|
||||||
return httperrors.New(
|
return httperrors.New(
|
||||||
http.StatusUnauthorized,
|
http.StatusUnauthorized,
|
||||||
@@ -32,18 +40,51 @@ func Authenticate(authenticator Authenticator) Middleware {
|
|||||||
|
|
||||||
resp, err := authenticator.Authenticate(ctx.Context(), token)
|
resp, err := authenticator.Authenticate(ctx.Context(), token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessagef(err, "authenticate: authenticate")
|
return errors.WithMessage(err, "authenticate: authenticator error")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !resp.Authenticated {
|
if !resp.Authenticated {
|
||||||
return httperrors.New(
|
return httperrors.New(
|
||||||
http.StatusUnauthorized,
|
http.StatusUnauthorized,
|
||||||
"invalid application token",
|
"invalid application token",
|
||||||
errors.WithMessage(errors.New(resp.ErrorReason), "authenticate: authenticate"),
|
errors.Errorf("authenticate: %s", resp.ErrorReason),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ctx.Authenticate(request.AuthData(*resp.AuthData))
|
|
||||||
|
|
||||||
|
if appName != "" && resp.AuthData.AppName != appName {
|
||||||
|
return httperrors.New(
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
"invalid application token",
|
||||||
|
errors.New("authenticate: application name mismatch"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Authenticate(*resp.AuthData)
|
||||||
return next.Handle(ctx)
|
return next.Handle(ctx)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func extractToken(ctx *request.Context) (string, string, error) {
|
||||||
|
var (
|
||||||
|
appName string
|
||||||
|
token string
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
|
||||||
|
token = ctx.Param(applicationTokenHeader)
|
||||||
|
if token != "" {
|
||||||
|
return token, "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
appName, token, ok = ctx.Request().BasicAuth()
|
||||||
|
if ok && appName == "" {
|
||||||
|
return "", "", httperrors.New(
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
"application name required",
|
||||||
|
errors.New("authenticate: application name required on basic auth"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return token, appName, nil
|
||||||
|
}
|
||||||
+19
-5
@@ -4,25 +4,36 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/log"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Authorizer interface {
|
type Authorizer interface {
|
||||||
Authorize(ctx context.Context, applicationId int, endpoint string) (bool, error)
|
Authorize(ctx context.Context, applicationId int, httpMethod string, pathSchema string) (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Authorize(authorizer Authorizer, logger log.Logger) Middleware {
|
func Authorize(authorizer Authorizer, logger log.Logger) Middleware {
|
||||||
return func(next Handler) Handler {
|
return func(next Handler) Handler {
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
return HandlerFunc(func(ctx *request.Context) error {
|
||||||
|
if ctx.SkipAppAuth() {
|
||||||
|
return next.Handle(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
authData, err := ctx.GetAuthData()
|
authData, err := ctx.GetAuthData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "authorize: get auth data")
|
return errors.WithMessage(err, "authorize: get auth data")
|
||||||
}
|
}
|
||||||
|
|
||||||
ok, err := authorizer.Authorize(ctx.Context(), authData.ApplicationId, ctx.Endpoint())
|
endpointMeta := ctx.EndpointMeta()
|
||||||
|
ok, err := authorizer.Authorize(
|
||||||
|
ctx.Context(),
|
||||||
|
authData.ApplicationId,
|
||||||
|
ctx.Request().Method,
|
||||||
|
endpointMeta.PathSchema,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "authorize: authorize")
|
return errors.WithMessage(err, "authorize: authorize")
|
||||||
}
|
}
|
||||||
@@ -31,6 +42,7 @@ func Authorize(authorizer Authorizer, logger log.Logger) Middleware {
|
|||||||
ctx.Context(),
|
ctx.Context(),
|
||||||
"bypassing unauthorized request because it has admin privilege",
|
"bypassing unauthorized request because it has admin privilege",
|
||||||
log.Int("applicationId", authData.ApplicationId),
|
log.Int("applicationId", authData.ApplicationId),
|
||||||
|
log.String("applicationName", authData.AppName),
|
||||||
log.Int("adminId", ctx.AdminId()),
|
log.Int("adminId", ctx.AdminId()),
|
||||||
)
|
)
|
||||||
return next.Handle(ctx)
|
return next.Handle(ctx)
|
||||||
@@ -39,7 +51,9 @@ func Authorize(authorizer Authorizer, logger log.Logger) Middleware {
|
|||||||
return httperrors.New(
|
return httperrors.New(
|
||||||
http.StatusForbidden,
|
http.StatusForbidden,
|
||||||
"endpoint is not allowed",
|
"endpoint is not allowed",
|
||||||
errors.Errorf("authorize: endpoint '%s' is not allowed for application '%d'", ctx.Endpoint(), authData.ApplicationId),
|
errors.Errorf("authorize: endpoint '%s' with http method '%s' is not allowed for application '%d'",
|
||||||
|
endpointMeta.PathSchema, ctx.Request().Method, authData.ApplicationId,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
)
|
)
|
||||||
@@ -16,6 +16,10 @@ type DailyLimitChecker interface {
|
|||||||
func DailyLimit(checker DailyLimitChecker) Middleware {
|
func DailyLimit(checker DailyLimitChecker) Middleware {
|
||||||
return func(next Handler) Handler {
|
return func(next Handler) Handler {
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
return HandlerFunc(func(ctx *request.Context) error {
|
||||||
|
if ctx.SkipAppAuth() {
|
||||||
|
return next.Handle(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
authData, err := ctx.GetAuthData()
|
authData, err := ctx.GetAuthData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "daily limit: get auth data")
|
return errors.WithMessage(err, "daily limit: get auth data")
|
||||||
|
|||||||
+41
-14
@@ -1,32 +1,59 @@
|
|||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"isp-gate-service/domain"
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/log"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EntryPointConfig struct {
|
type EntryPointConfig struct {
|
||||||
PathPrefix string
|
PathPrefix string
|
||||||
WithPrefix bool
|
WithPrefix bool
|
||||||
|
ErrorOnUnknownEndpoint bool
|
||||||
|
WithLendingSlash bool
|
||||||
|
SkipLogging SkipLoggingPaths
|
||||||
}
|
}
|
||||||
|
|
||||||
func Entrypoint(maxReqBodySize int64, next Handler, logger log.Logger, cfg EntryPointConfig) http.Handler {
|
type EndpointResolver interface {
|
||||||
|
ResolveEndpoint(method string, path string, cfg EntryPointConfig) (*domain.EndpointMeta, error)
|
||||||
|
GetPaths(path string, cfg EntryPointConfig) (string, string)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Entrypoint(
|
||||||
|
maxReqBodySize int64,
|
||||||
|
next Handler,
|
||||||
|
cfg EntryPointConfig,
|
||||||
|
entryPointResolver EndpointResolver,
|
||||||
|
logger log.Logger,
|
||||||
|
) http.Handler {
|
||||||
return http.HandlerFunc(func(writer http.ResponseWriter, req *http.Request) {
|
return http.HandlerFunc(func(writer http.ResponseWriter, req *http.Request) {
|
||||||
req.Body = http.MaxBytesReader(writer, req.Body, maxReqBodySize)
|
req.Body = http.MaxBytesReader(writer, req.Body, maxReqBodySize)
|
||||||
|
|
||||||
endpoint := req.URL.Path
|
endpoint, err := entryPointResolver.ResolveEndpoint(req.Method, req.URL.Path, cfg)
|
||||||
if !cfg.WithPrefix {
|
if err != nil {
|
||||||
prefix := fmt.Sprintf("%s/", cfg.PathPrefix)
|
if !cfg.SkipLogging.ShouldSkip(req.URL.Path) {
|
||||||
endpoint = strings.TrimPrefix(req.URL.Path, prefix)
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := request.NewContext(req, writer, endpoint)
|
ctx := request.NewContext(req, writer, endpoint)
|
||||||
|
|
||||||
err := next.Handle(ctx)
|
err = next.Handle(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(req.Context(), errors.WithMessage(err, "uncaught error"))
|
logger.Error(req.Context(), errors.WithMessage(err, "uncaught error"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package middleware
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"isp-gate-service/request"
|
||||||
|
)
|
||||||
|
|
||||||
|
func JsonResponseUtf8Charset(applicationIds map[int]bool) Middleware {
|
||||||
|
return func(next Handler) Handler {
|
||||||
|
return HandlerFunc(func(ctx *request.Context) error {
|
||||||
|
authData, _ := ctx.GetAuthData()
|
||||||
|
ctx.EnableHttpJsonUtf8Charset(applicationIds[authData.ApplicationId])
|
||||||
|
return next.Handle(ctx)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
+37
-11
@@ -8,10 +8,16 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/http/endpoint/buffer"
|
"isp-gate-service/helpers"
|
||||||
"github.com/integration-system/isp-kit/log"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"github.com/txix-open/isp-kit/http/endpoint/buffer"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
unicodeEscapePrefix = []byte("\\u") // nolint:gochecknoglobals
|
||||||
)
|
)
|
||||||
|
|
||||||
type scSource interface {
|
type scSource interface {
|
||||||
@@ -20,6 +26,7 @@ type scSource interface {
|
|||||||
|
|
||||||
type writerWrapper struct {
|
type writerWrapper struct {
|
||||||
http.ResponseWriter
|
http.ResponseWriter
|
||||||
|
|
||||||
statusCode int
|
statusCode int
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,11 +50,13 @@ func (w *writerWrapper) WriteHeader(statusCode int) {
|
|||||||
w.ResponseWriter.WriteHeader(statusCode)
|
w.ResponseWriter.WriteHeader(statusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Logger(
|
func Logger( // nolint:gocognit,funlen
|
||||||
logger log.Logger,
|
logger log.Logger,
|
||||||
enableRequestLogging bool,
|
enableRequestLogging bool,
|
||||||
enableBodyLogging bool,
|
enableBodyLogging bool,
|
||||||
|
skipLogging SkipLoggingPaths,
|
||||||
skipBodyLoggingEndpointPrefixes []string,
|
skipBodyLoggingEndpointPrefixes []string,
|
||||||
|
enableForceUnescapingUnicode bool,
|
||||||
) Middleware {
|
) Middleware {
|
||||||
return func(next Handler) Handler {
|
return func(next Handler) Handler {
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
return HandlerFunc(func(ctx *request.Context) error {
|
||||||
@@ -57,10 +66,15 @@ func Logger(
|
|||||||
|
|
||||||
r := ctx.Request()
|
r := ctx.Request()
|
||||||
|
|
||||||
|
if skipLogging.ShouldSkip(r.URL.Path) {
|
||||||
|
return next.Handle(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
endpoint := ctx.EndpointMeta().NormalizedEndpoint
|
||||||
logBodyFromCurrenRequest := enableBodyLogging
|
logBodyFromCurrenRequest := enableBodyLogging
|
||||||
if logBodyFromCurrenRequest {
|
if logBodyFromCurrenRequest {
|
||||||
for _, prefix := range skipBodyLoggingEndpointPrefixes {
|
for _, prefix := range skipBodyLoggingEndpointPrefixes {
|
||||||
if strings.HasPrefix(ctx.Endpoint(), prefix) {
|
if strings.HasPrefix(endpoint, prefix) {
|
||||||
logBodyFromCurrenRequest = false
|
logBodyFromCurrenRequest = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -102,18 +116,30 @@ func Logger(
|
|||||||
log.String("xForwardedFor", r.Header.Get("X-Forwarded-For")),
|
log.String("xForwardedFor", r.Header.Get("X-Forwarded-For")),
|
||||||
log.Int("statusCode", scSrc.StatusCode()),
|
log.Int("statusCode", scSrc.StatusCode()),
|
||||||
log.String("path", originalPath),
|
log.String("path", originalPath),
|
||||||
log.String("endpoint", ctx.Endpoint()),
|
log.String("endpoint", endpoint),
|
||||||
log.Int("applicationId", authData.ApplicationId),
|
log.Int("applicationId", authData.ApplicationId),
|
||||||
|
log.String("applicationName", authData.AppName),
|
||||||
log.Int("adminId", ctx.AdminId()),
|
log.Int("adminId", ctx.AdminId()),
|
||||||
}
|
}
|
||||||
|
|
||||||
if logBodyFromCurrenRequest {
|
if logBodyFromCurrenRequest {
|
||||||
fields = append(fields,
|
if enableForceUnescapingUnicode && bytes.Contains(buf.RequestBody(), unicodeEscapePrefix) {
|
||||||
log.ByteString("request", buf.RequestBody()),
|
fields = append(fields, log.ByteString("request", helpers.UnescapeUnicode(buf.RequestBody())))
|
||||||
log.ByteString("response", buf.ResponseBody()),
|
} else {
|
||||||
)
|
fields = append(fields, log.ByteString("request", buf.RequestBody()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fields = append(fields, log.ByteString("response", buf.ResponseBody()))
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case scSrc.StatusCode() >= http.StatusInternalServerError:
|
||||||
|
logger.Error(ctx.Context(), "log request", fields...)
|
||||||
|
case scSrc.StatusCode() >= http.StatusBadRequest:
|
||||||
|
logger.Warn(ctx.Context(), "log request", fields...)
|
||||||
|
default:
|
||||||
|
logger.Debug(ctx.Context(), "log request", fields...)
|
||||||
}
|
}
|
||||||
logger.Debug(ctx.Context(), "log request", fields...)
|
|
||||||
|
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"isp-gate-service/request"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/metrics/http_metrics"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Metrics(storage *http_metrics.ServerStorage) Middleware {
|
||||||
|
return func(next Handler) Handler {
|
||||||
|
return HandlerFunc(func(ctx *request.Context) error {
|
||||||
|
pathSchema := ctx.EndpointMeta().PathSchema
|
||||||
|
if pathSchema == "" {
|
||||||
|
return next.Handle(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
r := ctx.Request()
|
||||||
|
|
||||||
|
start := time.Now()
|
||||||
|
err := next.Handle(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
storage.ObserveDuration(r.Method, pathSchema, time.Since(start))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"slices"
|
||||||
|
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,10 +18,10 @@ func (f HandlerFunc) Handle(ctx *request.Context) error {
|
|||||||
|
|
||||||
type Middleware func(next Handler) Handler
|
type Middleware func(next Handler) Handler
|
||||||
|
|
||||||
// nolint:ireturn
|
//nolint:ireturn // Chain по определению возвращает Handler-интерфейс
|
||||||
func Chain(root Handler, middlewares ...Middleware) Handler {
|
func Chain(root Handler, middlewares ...Middleware) Handler {
|
||||||
for i := len(middlewares) - 1; i >= 0; i-- {
|
for _, m := range slices.Backward(middlewares) {
|
||||||
root = middlewares[i](root)
|
root = m(root)
|
||||||
}
|
}
|
||||||
return root
|
return root
|
||||||
}
|
}
|
||||||
+30
-11
@@ -3,28 +3,47 @@ package middleware
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/log"
|
|
||||||
"github.com/integration-system/isp-kit/requestid"
|
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
"github.com/txix-open/isp-kit/log"
|
||||||
requestIdHeader = "x-request-id"
|
"github.com/txix-open/isp-kit/requestid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RequestId() Middleware {
|
func RequestId() Middleware {
|
||||||
return func(next Handler) Handler {
|
return func(next Handler) Handler {
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
return HandlerFunc(func(ctx *request.Context) error {
|
||||||
requestId := strings.TrimSpace(ctx.Request().Header.Get(requestIdHeader))
|
requestId := requestid.Next()
|
||||||
if requestId == "" {
|
|
||||||
requestId = requestid.Next()
|
|
||||||
}
|
|
||||||
|
|
||||||
context := requestid.ToContext(ctx.Context(), requestId)
|
context := requestid.ToContext(ctx.Context(), requestId)
|
||||||
context = log.ToContext(context, log.String("requestId", requestId))
|
context = log.ToContext(context, log.String(requestid.LogKey, requestId))
|
||||||
|
|
||||||
|
ctx.SetContext(context)
|
||||||
|
return next.Handle(ctx)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ClientRequestId(forwardClientRequestId bool, forwardReqIdByApp map[int]bool) Middleware {
|
||||||
|
return func(next Handler) Handler {
|
||||||
|
return HandlerFunc(func(ctx *request.Context) error {
|
||||||
|
requestId := requestid.FromContext(ctx.Context())
|
||||||
|
clientRequestId := strings.TrimSpace(ctx.Request().Header.Get(requestid.Header))
|
||||||
|
|
||||||
|
clientLogFields := make([]log.Field, 0, 1)
|
||||||
|
if clientRequestId != "" {
|
||||||
|
authData, _ := ctx.GetAuthData()
|
||||||
|
if forwardClientRequestId || forwardReqIdByApp[authData.ApplicationId] {
|
||||||
|
requestId = clientRequestId
|
||||||
|
}
|
||||||
|
|
||||||
|
clientLogFields = append(clientLogFields, log.String("clientRequestId", clientRequestId))
|
||||||
|
}
|
||||||
|
|
||||||
|
context := requestid.ToContext(ctx.Context(), requestId)
|
||||||
|
context = log.RewriteContextField(context, log.String(requestid.LogKey, requestId))
|
||||||
|
context = log.ToContext(context, clientLogFields...)
|
||||||
|
|
||||||
ctx.SetContext(context)
|
ctx.SetContext(context)
|
||||||
|
|
||||||
return next.Handle(ctx)
|
return next.Handle(ctx)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
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))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
@@ -18,6 +18,10 @@ type Throttler interface {
|
|||||||
func Throttling(throttler Throttler) Middleware {
|
func Throttling(throttler Throttler) Middleware {
|
||||||
return func(next Handler) Handler {
|
return func(next Handler) Handler {
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
return HandlerFunc(func(ctx *request.Context) error {
|
||||||
|
if ctx.SkipAppAuth() {
|
||||||
|
return next.Handle(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
authData, err := ctx.GetAuthData()
|
authData, err := ctx.GetAuthData()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "throttling: get auth data")
|
return errors.WithMessage(err, "throttling: get auth data")
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
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,61 @@
|
|||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/httperrors"
|
||||||
|
"isp-gate-service/request"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserAuthenticator interface {
|
||||||
|
Authenticate(ctx *request.Context) (*domain.AuthenticateUserResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func UserAuthenticate(authenticator UserAuthenticator, logger log.Logger) Middleware {
|
||||||
|
return func(next Handler) Handler {
|
||||||
|
return HandlerFunc(func(ctx *request.Context) error {
|
||||||
|
resp, err := authenticator.Authenticate(ctx)
|
||||||
|
switch {
|
||||||
|
case errors.Is(err, domain.ErrEmptyUserToken):
|
||||||
|
return httperrors.New(
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
"user token required",
|
||||||
|
errors.New("customAuth: authenticate user: user token required"),
|
||||||
|
)
|
||||||
|
case errors.Is(err, domain.ErrInvalidUserToken):
|
||||||
|
return httperrors.New(
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
"invalid user token",
|
||||||
|
errors.WithMessage(err, "customAuth: authenticate user: invalid user token"),
|
||||||
|
)
|
||||||
|
case err != nil:
|
||||||
|
return errors.WithMessage(err, "customAuth: authenticate user: authenticator error")
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.SkipUserAuth {
|
||||||
|
return next.Handle(ctx)
|
||||||
|
}
|
||||||
|
if !resp.Authenticated {
|
||||||
|
return httperrors.New(
|
||||||
|
http.StatusUnauthorized,
|
||||||
|
"invalid user token",
|
||||||
|
errors.Errorf("customAuth: authenticate user: authenticate: %s", resp.ErrorReason),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.AuthenticateUser(*resp.AuthData)
|
||||||
|
|
||||||
|
if ctx.SkipAppAuth() {
|
||||||
|
logger.Debug(
|
||||||
|
ctx.Context(),
|
||||||
|
"skip app auth is set. All steps that require app auth data are skipped",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return next.Handle(ctx)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
+61
-31
@@ -3,20 +3,23 @@ package proxy
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"io"
|
"io"
|
||||||
|
"maps"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/grpc"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/integration-system/isp-kit/grpc/client"
|
"github.com/txix-open/isp-kit/grpc"
|
||||||
"github.com/integration-system/isp-kit/grpc/isp"
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
"github.com/integration-system/isp-kit/json"
|
"github.com/txix-open/isp-kit/grpc/isp"
|
||||||
"github.com/integration-system/isp-kit/requestid"
|
"github.com/txix-open/isp-kit/json"
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/requestid"
|
||||||
_ "google.golang.org/genproto/googleapis/rpc/errdetails"
|
_ "google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
@@ -68,23 +71,8 @@ func (p Grpc) Handle(ctx *request.Context) error {
|
|||||||
return errors.WithMessage(err, "grpc: read body")
|
return errors.WithMessage(err, "grpc: read body")
|
||||||
}
|
}
|
||||||
|
|
||||||
md := metadata.MD{
|
requestId := requestid.FromContext(ctx.Context())
|
||||||
grpc.ProxyMethodNameHeader: {ctx.Endpoint()},
|
md := p.writeMetadata(ctx)
|
||||||
grpc.RequestIdHeader: {requestid.FromContext(ctx.Context())},
|
|
||||||
}
|
|
||||||
if !p.skipAuth {
|
|
||||||
authData, err := ctx.GetAuthData()
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "get auth data")
|
|
||||||
}
|
|
||||||
md[grpc.SystemIdHeader] = []string{strconv.Itoa(authData.SystemId)}
|
|
||||||
md[grpc.DomainIdHeader] = []string{strconv.Itoa(authData.DomainId)}
|
|
||||||
md[grpc.ServiceIdHeader] = []string{strconv.Itoa(authData.ServiceId)}
|
|
||||||
md[grpc.ApplicationIdHeader] = []string{strconv.Itoa(authData.ApplicationId)}
|
|
||||||
if ctx.IsAdminAuthenticated() {
|
|
||||||
md[xAdminIdHeader] = []string{strconv.Itoa(ctx.AdminId())}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
requestContext := metadata.NewOutgoingContext(ctx.Context(), md)
|
requestContext := metadata.NewOutgoingContext(ctx.Context(), md)
|
||||||
|
|
||||||
requestContext, cancel := context.WithTimeout(requestContext, p.timeout)
|
requestContext, cancel := context.WithTimeout(requestContext, p.timeout)
|
||||||
@@ -93,13 +81,13 @@ func (p Grpc) Handle(ctx *request.Context) error {
|
|||||||
Body: &isp.Message_BytesBody{BytesBody: body},
|
Body: &isp.Message_BytesBody{BytesBody: body},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return p.handleError(err, ctx.ResponseWriter())
|
return p.handleError(err, ctx.ResponseWriter(), ctx.EndpointMeta().Endpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
return p.writeResponse(http.StatusOK, result.GetBytesBody(), ctx.ResponseWriter())
|
return p.writeResponse(http.StatusOK, result.GetBytesBody(), requestId, ctx.ResponseWriter())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Grpc) handleError(err error, w http.ResponseWriter) error {
|
func (p Grpc) handleError(err error, w http.ResponseWriter, endpoint string) error {
|
||||||
status, ok := status.FromError(err)
|
status, ok := status.FromError(err)
|
||||||
if !ok {
|
if !ok {
|
||||||
return httperrors.New(
|
return httperrors.New(
|
||||||
@@ -115,7 +103,7 @@ func (p Grpc) handleError(err error, w http.ResponseWriter) error {
|
|||||||
case *isp.Message:
|
case *isp.Message:
|
||||||
switch {
|
switch {
|
||||||
case typeOfDetail.GetBytesBody() != nil:
|
case typeOfDetail.GetBytesBody() != nil:
|
||||||
return p.writeResponse(statusCode, typeOfDetail.GetBytesBody(), w)
|
return p.writeResponse(statusCode, typeOfDetail.GetBytesBody(), "", w)
|
||||||
case typeOfDetail.GetListBody() != nil:
|
case typeOfDetail.GetListBody() != nil:
|
||||||
return p.writeProto(statusCode, typeOfDetail.GetListBody(), w)
|
return p.writeProto(statusCode, typeOfDetail.GetListBody(), w)
|
||||||
case typeOfDetail.GetStructBody() != nil:
|
case typeOfDetail.GetStructBody() != nil:
|
||||||
@@ -129,20 +117,23 @@ func (p Grpc) handleError(err error, w http.ResponseWriter) error {
|
|||||||
return httperrors.New(
|
return httperrors.New(
|
||||||
statusCode,
|
statusCode,
|
||||||
status.Message(),
|
status.Message(),
|
||||||
status.Err(),
|
errors.WithMessagef(err, "isp-routing-service: proxy '%s'", endpoint),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Grpc) writeProto(statusCode int, proto interface{}, w http.ResponseWriter) error {
|
func (p Grpc) writeProto(statusCode int, proto any, w http.ResponseWriter) error {
|
||||||
data, err := json.Marshal(proto)
|
data, err := json.Marshal(proto)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "marshal grpc details to json")
|
return errors.WithMessage(err, "marshal grpc details to json")
|
||||||
}
|
}
|
||||||
return p.writeResponse(statusCode, data, w)
|
return p.writeResponse(statusCode, data, "", w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Grpc) writeResponse(statusCode int, data []byte, w http.ResponseWriter) error {
|
func (p Grpc) writeResponse(statusCode int, data []byte, requestId string, w http.ResponseWriter) error {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
|
if requestId != "" {
|
||||||
|
w.Header().Set(requestid.Header, requestId)
|
||||||
|
}
|
||||||
w.WriteHeader(statusCode)
|
w.WriteHeader(statusCode)
|
||||||
_, err := w.Write(data)
|
_, err := w.Write(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -159,3 +150,42 @@ func (p Grpc) codeToHttpStatus(code codes.Code) int {
|
|||||||
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p Grpc) writeMetadata(ctx *request.Context) metadata.MD {
|
||||||
|
requestId := requestid.FromContext(ctx.Context())
|
||||||
|
md := metadata.MD{
|
||||||
|
grpc.ProxyMethodNameHeader: {ctx.EndpointMeta().Endpoint},
|
||||||
|
requestid.Header: {requestId},
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.skipAuth {
|
||||||
|
return md
|
||||||
|
}
|
||||||
|
|
||||||
|
appAuthData, err := ctx.GetAuthData()
|
||||||
|
if err == nil {
|
||||||
|
md[grpc.SystemIdHeader] = []string{strconv.Itoa(appAuthData.SystemId)}
|
||||||
|
md[grpc.DomainIdHeader] = []string{strconv.Itoa(appAuthData.DomainId)}
|
||||||
|
md[grpc.ServiceIdHeader] = []string{strconv.Itoa(appAuthData.ServiceId)}
|
||||||
|
md[grpc.ApplicationIdHeader] = []string{strconv.Itoa(appAuthData.ApplicationId)}
|
||||||
|
encodedAppName := base64.StdEncoding.EncodeToString([]byte(appAuthData.AppName))
|
||||||
|
md[grpc.ApplicationNameHeader] = []string{encodedAppName}
|
||||||
|
}
|
||||||
|
|
||||||
|
userAuthData, err := ctx.GetUserAuthData()
|
||||||
|
if err == nil {
|
||||||
|
proxyHeaders := maps.Clone(userAuthData.ExtraHeaders)
|
||||||
|
proxyHeaders[userAuthData.IdentityHeader] = []string{userAuthData.Identity}
|
||||||
|
for header, values := range proxyHeaders {
|
||||||
|
header = strings.ToLower(header)
|
||||||
|
if strings.HasPrefix(header, "x-") {
|
||||||
|
md.Set(header, values...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ctx.IsAdminAuthenticated() {
|
||||||
|
md[xAdminIdHeader] = []string{strconv.Itoa(ctx.AdminId())}
|
||||||
|
}
|
||||||
|
return md
|
||||||
|
}
|
||||||
+50
-26
@@ -1,24 +1,25 @@
|
|||||||
package proxy
|
package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/grpc"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/integration-system/isp-kit/requestid"
|
"github.com/txix-open/isp-kit/grpc"
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/requestid"
|
||||||
"golang.org/x/net/context"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// nolint:gomnd
|
|
||||||
var (
|
var (
|
||||||
httpTransport = &http.Transport{
|
httpTransport = &http.Transport{
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
@@ -66,11 +67,9 @@ func (p Http) Handle(ctx *request.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
request := ctx.Request()
|
request := ctx.Request()
|
||||||
request.URL.Path = ctx.Endpoint()
|
request.URL.Path = ctx.EndpointMeta().Endpoint
|
||||||
err = setHttpHeaders(ctx, request.Header, p.skipAuth)
|
setHttpHeaders(ctx, request.Header, p.skipAuth)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
reverseProxy := httputil.NewSingleHostReverseProxy(target)
|
reverseProxy := httputil.NewSingleHostReverseProxy(target)
|
||||||
reverseProxy.Transport = httpTransport
|
reverseProxy.Transport = httpTransport
|
||||||
var resultError error
|
var resultError error
|
||||||
@@ -81,6 +80,9 @@ func (p Http) Handle(ctx *request.Context) error {
|
|||||||
errors.WithMessagef(err, "http proxy to %s", host),
|
errors.WithMessagef(err, "http proxy to %s", host),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if ctx.IsJsonUtf8CharsetEnabled() {
|
||||||
|
reverseProxy.ModifyResponse = addJsonUtf8Charset
|
||||||
|
}
|
||||||
|
|
||||||
context, cancel := context.WithTimeout(request.Context(), p.timeout)
|
context, cancel := context.WithTimeout(request.Context(), p.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@@ -90,26 +92,48 @@ func (p Http) Handle(ctx *request.Context) error {
|
|||||||
return resultError
|
return resultError
|
||||||
}
|
}
|
||||||
|
|
||||||
func setHttpHeaders(ctx *request.Context, header http.Header, skipAuth bool) error {
|
func setHttpHeaders(ctx *request.Context, header http.Header, skipAuth bool) {
|
||||||
header.Set(grpc.RequestIdHeader, requestid.FromContext(ctx.Context()))
|
header.Set(requestid.Header, requestid.FromContext(ctx.Context()))
|
||||||
if !skipAuth {
|
if skipAuth {
|
||||||
authData, err := ctx.GetAuthData()
|
return
|
||||||
if err != nil {
|
}
|
||||||
return errors.WithMessage(err, "http: get auth data")
|
|
||||||
|
userAuthData, err := ctx.GetUserAuthData()
|
||||||
|
if err == nil {
|
||||||
|
for key, values := range userAuthData.ExtraHeaders {
|
||||||
|
for _, value := range values {
|
||||||
|
header.Add(key, value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
header.Set(grpc.SystemIdHeader, strconv.Itoa(authData.SystemId))
|
header.Set(userAuthData.IdentityHeader, userAuthData.Identity)
|
||||||
header.Set(grpc.DomainIdHeader, strconv.Itoa(authData.DomainId))
|
}
|
||||||
header.Set(grpc.ServiceIdHeader, strconv.Itoa(authData.ServiceId))
|
|
||||||
header.Set(grpc.ApplicationIdHeader, strconv.Itoa(authData.ApplicationId))
|
appAuthData, err := ctx.GetAuthData()
|
||||||
if ctx.IsAdminAuthenticated() {
|
if err == nil {
|
||||||
header.Set(xAdminIdHeader, strconv.Itoa(ctx.AdminId()))
|
header.Set(grpc.SystemIdHeader, strconv.Itoa(appAuthData.SystemId))
|
||||||
} else {
|
header.Set(grpc.DomainIdHeader, strconv.Itoa(appAuthData.DomainId))
|
||||||
header.Del(xAdminIdHeader)
|
header.Set(grpc.ServiceIdHeader, strconv.Itoa(appAuthData.ServiceId))
|
||||||
}
|
header.Set(grpc.ApplicationIdHeader, strconv.Itoa(appAuthData.ApplicationId))
|
||||||
|
encodedAppName := base64.StdEncoding.EncodeToString([]byte(appAuthData.AppName))
|
||||||
|
header.Set(grpc.ApplicationNameHeader, encodedAppName) //nolint:canonicalheader
|
||||||
|
}
|
||||||
|
|
||||||
|
if ctx.IsAdminAuthenticated() {
|
||||||
|
header.Set(xAdminIdHeader, strconv.Itoa(ctx.AdminId())) //nolint:canonicalheader
|
||||||
|
} else {
|
||||||
|
header.Del(xAdminIdHeader) //nolint:canonicalheader
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultTransportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) {
|
func defaultTransportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) {
|
||||||
return dialer.DialContext
|
return dialer.DialContext
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addJsonUtf8Charset(response *http.Response) error {
|
||||||
|
contentType := response.Header.Get("Content-Type")
|
||||||
|
if strings.EqualFold(contentType, "application/json") {
|
||||||
|
response.Header.Set("Content-Type", "application/json; charset=utf-8")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
+6
-6
@@ -6,11 +6,12 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/tomakado/websocketproxy"
|
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
|
"github.com/tomakado/websocketproxy"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Ws struct {
|
type Ws struct {
|
||||||
@@ -25,7 +26,6 @@ func NewWs(hostManager HttpHostManager, skipAuth bool) Ws {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gomnd
|
|
||||||
func (ws Ws) Handle(ctx *request.Context) error {
|
func (ws Ws) Handle(ctx *request.Context) error {
|
||||||
host, err := ws.hostManager.Next()
|
host, err := ws.hostManager.Next()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -39,12 +39,12 @@ func (ws Ws) Handle(ctx *request.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
request := ctx.Request()
|
request := ctx.Request()
|
||||||
request.URL.Path = ctx.Endpoint()
|
request.URL.Path = ctx.EndpointMeta().Endpoint
|
||||||
|
|
||||||
var resultError error
|
var resultError error
|
||||||
proxy := websocketproxy.NewProxy(target)
|
proxy := websocketproxy.NewProxy(target)
|
||||||
proxy.Director = func(incoming *http.Request, out http.Header) {
|
proxy.Director = func(incoming *http.Request, out http.Header) {
|
||||||
_ = setHttpHeaders(ctx, out, ws.skipAuth)
|
setHttpHeaders(ctx, out, ws.skipAuth)
|
||||||
}
|
}
|
||||||
proxy.Upgrader = &websocket.Upgrader{
|
proxy.Upgrader = &websocket.Upgrader{
|
||||||
HandshakeTimeout: 5 * time.Second,
|
HandshakeTimeout: 5 * time.Second,
|
||||||
|
|||||||
+8
-8
@@ -4,10 +4,10 @@ package repository
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"isp-gate-service/domain"
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/grpc/client"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -23,10 +23,10 @@ func NewAdmin(cli *client.Client) Admin {
|
|||||||
return Admin{cli: cli}
|
return Admin{cli: cli}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Admin) Authenticate(ctx context.Context, token string) (*domain.AdminAuthenticateResponse, error) {
|
func (r Admin) Authenticate(ctx context.Context, token string) (*entity.AdminAuthenticateResponse, error) {
|
||||||
resp := domain.AdminAuthenticateResponse{}
|
resp := entity.AdminAuthenticateResponse{}
|
||||||
err := r.cli.Invoke(adminAuthenticate).
|
err := r.cli.Invoke(adminAuthenticate).
|
||||||
JsonRequestBody(domain.AuthenticateRequest{Token: token}).
|
JsonRequestBody(entity.AuthenticateRequest{Token: token}).
|
||||||
JsonResponseBody(&resp).
|
JsonResponseBody(&resp).
|
||||||
Do(ctx)
|
Do(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -36,9 +36,9 @@ func (r Admin) Authenticate(ctx context.Context, token string) (*domain.AdminAut
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r Admin) Authorize(ctx context.Context, adminId int, permission string) (bool, error) {
|
func (r Admin) Authorize(ctx context.Context, adminId int, permission string) (bool, error) {
|
||||||
resp := domain.AdminAuthorizeResponse{}
|
resp := entity.AdminAuthorizeResponse{}
|
||||||
err := r.cli.Invoke(adminAuthorize).
|
err := r.cli.Invoke(adminAuthorize).
|
||||||
JsonRequestBody(domain.AdminAuthorizeRequest{AdminId: adminId, Permission: permission}).
|
JsonRequestBody(entity.AdminAuthorizeRequest{AdminId: adminId, Permission: permission}).
|
||||||
JsonResponseBody(&resp).
|
JsonResponseBody(&resp).
|
||||||
Do(ctx)
|
Do(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/json"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-gate-service/cache"
|
"isp-gate-service/cache"
|
||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"github.com/txix-open/isp-kit/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuthenticationCache struct {
|
type AuthenticationCache struct {
|
||||||
@@ -22,13 +24,13 @@ func NewAuthenticationCache(duration time.Duration) AuthenticationCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r AuthenticationCache) Get(ctx context.Context, token string) (*domain.AuthData, error) {
|
func (r AuthenticationCache) Get(ctx context.Context, token string) (*entity.AppAuthData, error) {
|
||||||
data, ok := r.cache.Get(token)
|
data, ok := r.cache.Get(token)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, domain.ErrAuthenticationCacheMiss
|
return nil, domain.ErrAuthenticationCacheMiss
|
||||||
}
|
}
|
||||||
|
|
||||||
result := domain.AuthData{}
|
result := entity.AppAuthData{}
|
||||||
err := json.Unmarshal(data, &result)
|
err := json.Unmarshal(data, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "json unmarshal auth data")
|
return nil, errors.WithMessage(err, "json unmarshal auth data")
|
||||||
@@ -37,7 +39,7 @@ func (r AuthenticationCache) Get(ctx context.Context, token string) (*domain.Aut
|
|||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r AuthenticationCache) Set(ctx context.Context, token string, data domain.AuthData) error {
|
func (r AuthenticationCache) Set(ctx context.Context, token string, data entity.AppAuthData) error {
|
||||||
value, err := json.Marshal(data)
|
value, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "json marshal auth data")
|
return errors.WithMessage(err, "json marshal auth data")
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
package repository
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DailyLimit struct {
|
|
||||||
cli redis.UniversalClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewDailyLimit(cli redis.UniversalClient) DailyLimit {
|
|
||||||
return DailyLimit{
|
|
||||||
cli: cli,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r DailyLimit) Increment(ctx context.Context, applicationId int, today time.Time) (int64, error) {
|
|
||||||
key := r.key(applicationId, today)
|
|
||||||
value, err := r.cli.Incr(ctx, key).Result()
|
|
||||||
if err != nil {
|
|
||||||
return 0, errors.WithMessage(err, "incr")
|
|
||||||
}
|
|
||||||
|
|
||||||
if value == 1 {
|
|
||||||
err := r.cli.ExpireNX(ctx, key, 24*time.Hour).Err() //nolint:mnd,gomnd
|
|
||||||
if err != nil {
|
|
||||||
return 0, errors.WithMessage(err, "expire nx")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return value, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r DailyLimit) key(applicationId int, today time.Time) string {
|
|
||||||
y, m, d := today.Date()
|
|
||||||
return fmt.Sprintf("daily_limit:%d:%d-%d-%d", applicationId, y, m, d)
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
incrementEndpoint = "isp-lock-service/daily_limit/increment"
|
||||||
|
rateLimitEndpoint = "isp-lock-service/rate_limit"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Locker struct {
|
||||||
|
cli *client.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLocker(cli *client.Client) Locker {
|
||||||
|
return Locker{
|
||||||
|
cli: cli,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Locker) Increment(ctx context.Context, key string, today time.Time) (int64, error) {
|
||||||
|
resp := new(entity.IncrementResponse)
|
||||||
|
err := r.cli.Invoke(incrementEndpoint).
|
||||||
|
JsonRequestBody(entity.IncrementRequest{
|
||||||
|
Key: key,
|
||||||
|
Today: today,
|
||||||
|
}).
|
||||||
|
JsonResponseBody(resp).
|
||||||
|
Do(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return 0, errors.WithMessagef(err, "invoke isp-lock-service: '%s'", incrementEndpoint)
|
||||||
|
default:
|
||||||
|
return int64(resp.Value), nil //nolint:gosec
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Locker) IsAllowRequestPerSecond(ctx context.Context, key string, rate int) (*entity.RateLimiterResponse, error) {
|
||||||
|
resp := new(entity.RateLimiterResponse)
|
||||||
|
err := r.cli.Invoke(rateLimitEndpoint).
|
||||||
|
JsonRequestBody(entity.RateLimiterRequest{
|
||||||
|
Key: key,
|
||||||
|
MaxRps: rate,
|
||||||
|
}).
|
||||||
|
JsonResponseBody(resp).
|
||||||
|
Do(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessagef(err, "invoke isp-lock-service: '%s'", rateLimitEndpoint)
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
+10
-9
@@ -4,9 +4,10 @@ package repository
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/grpc/client"
|
"isp-gate-service/entity"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-gate-service/domain"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -24,10 +25,10 @@ func NewSystem(cli *client.Client) System {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r System) Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error) {
|
func (r System) Authenticate(ctx context.Context, token string) (*entity.AuthenticateResponse, error) {
|
||||||
resp := domain.AuthenticateResponse{}
|
resp := entity.AuthenticateResponse{}
|
||||||
err := r.cli.Invoke(authenticate).
|
err := r.cli.Invoke(authenticate).
|
||||||
JsonRequestBody(domain.AuthenticateRequest{Token: token}).
|
JsonRequestBody(entity.AuthenticateRequest{Token: token}).
|
||||||
JsonResponseBody(&resp).
|
JsonResponseBody(&resp).
|
||||||
Do(ctx)
|
Do(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -36,10 +37,10 @@ func (r System) Authenticate(ctx context.Context, token string) (*domain.Authent
|
|||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r System) Authorize(ctx context.Context, applicationId int, endpoint string) (bool, error) {
|
func (r System) Authorize(ctx context.Context, req entity.AuthorizeRequest) (bool, error) {
|
||||||
resp := domain.AuthorizeResponse{}
|
resp := entity.AuthorizeResponse{}
|
||||||
err := r.cli.Invoke(authorize).
|
err := r.cli.Invoke(authorize).
|
||||||
JsonRequestBody(domain.AuthorizeRequest{ApplicationId: applicationId, Endpoint: endpoint}).
|
JsonRequestBody(req).
|
||||||
JsonResponseBody(&resp).
|
JsonResponseBody(&resp).
|
||||||
Do(ctx)
|
Do(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
package repository
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/go-redis/redis_rate/v10"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
"isp-gate-service/domain"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Throttling struct {
|
|
||||||
cli *redis_rate.Limiter
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewThrottling(cli redis.UniversalClient) Throttling {
|
|
||||||
return Throttling{
|
|
||||||
cli: redis_rate.NewLimiter(cli),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Throttling) IsAllowRequestPerSecond(ctx context.Context, applicationId int, rate int) (*domain.RateLimitResult, error) {
|
|
||||||
result, err := r.cli.Allow(ctx, r.key(applicationId), redis_rate.PerSecond(rate))
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "redis_rate/Allow")
|
|
||||||
}
|
|
||||||
return &domain.RateLimitResult{
|
|
||||||
Allow: result.Allowed > 0,
|
|
||||||
Remaining: result.Remaining,
|
|
||||||
RetryAfter: result.RetryAfter,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Throttling) key(applicationId int) string {
|
|
||||||
return fmt.Sprintf("throttling:%d", applicationId)
|
|
||||||
}
|
|
||||||
@@ -4,10 +4,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/json"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
|
"github.com/redis/go-redis/v9"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"github.com/txix-open/isp-kit/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RedisAuthCache struct {
|
type RedisAuthCache struct {
|
||||||
@@ -24,7 +26,7 @@ func NewRedisAuthCache(cli redis.UniversalClient, duration time.Duration, db int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r RedisAuthCache) Get(ctx context.Context, token string) (*domain.AuthData, error) {
|
func (r RedisAuthCache) Get(ctx context.Context, token string) (*entity.AppAuthData, error) {
|
||||||
results, err := r.cli.Pipelined(ctx, func(p redis.Pipeliner) error {
|
results, err := r.cli.Pipelined(ctx, func(p redis.Pipeliner) error {
|
||||||
p.Select(ctx, r.db)
|
p.Select(ctx, r.db)
|
||||||
p.Get(ctx, token)
|
p.Get(ctx, token)
|
||||||
@@ -34,7 +36,7 @@ func (r RedisAuthCache) Get(ctx context.Context, token string) (*domain.AuthData
|
|||||||
return nil, errors.WithMessage(err, "pipelined")
|
return nil, errors.WithMessage(err, "pipelined")
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := results[1].(*redis.StringCmd).Result()
|
data, err := results[1].(*redis.StringCmd).Result() // nolint: forcetypeassert
|
||||||
if errors.Is(err, redis.Nil) {
|
if errors.Is(err, redis.Nil) {
|
||||||
return nil, domain.ErrAuthenticationCacheMiss
|
return nil, domain.ErrAuthenticationCacheMiss
|
||||||
}
|
}
|
||||||
@@ -42,7 +44,7 @@ func (r RedisAuthCache) Get(ctx context.Context, token string) (*domain.AuthData
|
|||||||
return nil, errors.WithMessage(err, "get")
|
return nil, errors.WithMessage(err, "get")
|
||||||
}
|
}
|
||||||
|
|
||||||
result := domain.AuthData{}
|
result := entity.AppAuthData{}
|
||||||
err = json.Unmarshal([]byte(data), &result)
|
err = json.Unmarshal([]byte(data), &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "json unmarshal auth data")
|
return nil, errors.WithMessage(err, "json unmarshal auth data")
|
||||||
@@ -51,7 +53,7 @@ func (r RedisAuthCache) Get(ctx context.Context, token string) (*domain.AuthData
|
|||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r RedisAuthCache) Set(ctx context.Context, token string, data domain.AuthData) error {
|
func (r RedisAuthCache) Set(ctx context.Context, token string, data entity.AppAuthData) error {
|
||||||
value, err := json.Marshal(data)
|
value, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "json marshal auth data")
|
return errors.WithMessage(err, "json marshal auth data")
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RedisAuthzCache struct {
|
type RedisAuthzCache struct {
|
||||||
@@ -33,7 +33,7 @@ func (r RedisAuthzCache) Get(ctx context.Context, applicationId int, endpoint st
|
|||||||
return false, errors.WithMessage(err, "pipelined")
|
return false, errors.WithMessage(err, "pipelined")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = result[1].(*redis.StringCmd).Result()
|
_, err = result[1].(*redis.StringCmd).Result() // nolint: forcetypeassert
|
||||||
if errors.Is(err, redis.Nil) {
|
if errors.Is(err, redis.Nil) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"github.com/txix-open/isp-kit/http/httpcli"
|
||||||
|
"github.com/txix-open/isp-kit/http/httpclix"
|
||||||
|
"github.com/txix-open/isp-kit/lb"
|
||||||
|
"github.com/txix-open/isp-kit/metrics/http_metrics"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserAuth struct {
|
||||||
|
lb *lb.RoundRobin
|
||||||
|
cli *httpcli.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserAuth(lb *lb.RoundRobin) UserAuth {
|
||||||
|
return UserAuth{
|
||||||
|
lb: lb,
|
||||||
|
cli: httpclix.Default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r UserAuth) Authenticate(
|
||||||
|
ctx context.Context,
|
||||||
|
method string,
|
||||||
|
token string,
|
||||||
|
) (*entity.UserAuthenticateResponse, error) {
|
||||||
|
ctx = http_metrics.ClientEndpointToContext(ctx, method)
|
||||||
|
|
||||||
|
host, err := r.lb.Next()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "lb next")
|
||||||
|
}
|
||||||
|
|
||||||
|
endpoint := fmt.Sprintf("http://%s/%s", host, method)
|
||||||
|
resp := entity.UserAuthenticateResponse{}
|
||||||
|
err = r.cli.Post(endpoint).
|
||||||
|
JsonRequestBody(entity.UserAuthenticateRequest{
|
||||||
|
Token: token,
|
||||||
|
}).JsonResponseBody(&resp).
|
||||||
|
StatusCodeToError().
|
||||||
|
DoWithoutResponse(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessagef(err, "http client invoke: %s", endpoint)
|
||||||
|
}
|
||||||
|
return &resp, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"github.com/txix-open/isp-kit/json"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Cache interface {
|
||||||
|
Get(key string) ([]byte, bool)
|
||||||
|
Set(key string, data []byte, lifeTime time.Duration)
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserAuthenticationCache struct {
|
||||||
|
cache Cache
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserAuthenticationCache(cache Cache) UserAuthenticationCache {
|
||||||
|
return UserAuthenticationCache{
|
||||||
|
cache: cache,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r UserAuthenticationCache) Get(ctx context.Context, authMethodPath string, token string) (*entity.UserAuthData, error) {
|
||||||
|
data, ok := r.cache.Get(r.key(authMethodPath, token))
|
||||||
|
if !ok {
|
||||||
|
return nil, domain.ErrAuthenticationCacheMiss
|
||||||
|
}
|
||||||
|
|
||||||
|
result := entity.UserAuthData{}
|
||||||
|
err := json.Unmarshal(data, &result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "json unmarshal auth data")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r UserAuthenticationCache) Set(
|
||||||
|
ctx context.Context,
|
||||||
|
authMethodPath string,
|
||||||
|
token string,
|
||||||
|
data entity.UserAuthData,
|
||||||
|
duration time.Duration,
|
||||||
|
) error {
|
||||||
|
value, err := json.Marshal(data)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "json marshal auth data")
|
||||||
|
}
|
||||||
|
|
||||||
|
r.cache.Set(r.key(authMethodPath, token), value, duration)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r UserAuthenticationCache) key(authModuleName string, token string) string {
|
||||||
|
return fmt.Sprintf("%s:%s", authModuleName, token)
|
||||||
|
}
|
||||||
+44
-17
@@ -2,44 +2,47 @@ package request
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"isp-gate-service/domain"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrNotAuthenticated = errors.New("not authenticated")
|
ErrNotAuthenticated = errors.New("not authenticated")
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuthData struct {
|
|
||||||
SystemId int
|
|
||||||
DomainId int
|
|
||||||
ServiceId int
|
|
||||||
ApplicationId int
|
|
||||||
}
|
|
||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
request *http.Request
|
request *http.Request
|
||||||
responseWriter http.ResponseWriter
|
responseWriter http.ResponseWriter
|
||||||
|
|
||||||
endpoint string
|
endpointMeta *domain.EndpointMeta
|
||||||
|
|
||||||
authenticated bool
|
authenticated bool
|
||||||
authData *AuthData
|
authData *domain.AppAuthData
|
||||||
|
|
||||||
|
userAuthenticated bool
|
||||||
|
userAuthData *domain.UserAuthData
|
||||||
|
|
||||||
adminAuthenticated bool
|
adminAuthenticated bool
|
||||||
adminId int
|
adminId int
|
||||||
adminToken string
|
adminToken string
|
||||||
|
|
||||||
queryParams map[string]string
|
queryParams map[string]string
|
||||||
|
|
||||||
|
httpJsonUtf8Charset bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewContext(request *http.Request, response http.ResponseWriter, endpoint string) *Context {
|
func NewContext(
|
||||||
|
request *http.Request,
|
||||||
|
response http.ResponseWriter,
|
||||||
|
endpointMeta *domain.EndpointMeta,
|
||||||
|
) *Context {
|
||||||
return &Context{
|
return &Context{
|
||||||
request: request,
|
request: request,
|
||||||
responseWriter: response,
|
responseWriter: response,
|
||||||
endpoint: endpoint,
|
endpointMeta: endpointMeta,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,22 +58,38 @@ func (c *Context) SetResponseWriter(writer http.ResponseWriter) {
|
|||||||
c.responseWriter = writer
|
c.responseWriter = writer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) Endpoint() string {
|
func (c *Context) EndpointMeta() *domain.EndpointMeta {
|
||||||
return c.endpoint
|
return c.endpointMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) Authenticate(authData AuthData) {
|
func (c *Context) Authenticate(authData domain.AppAuthData) {
|
||||||
c.authenticated = true
|
c.authenticated = true
|
||||||
c.authData = &authData
|
c.authData = &authData
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) GetAuthData() (AuthData, error) {
|
func (c *Context) GetAuthData() (domain.AppAuthData, error) {
|
||||||
if !c.authenticated {
|
if !c.authenticated {
|
||||||
return AuthData{}, ErrNotAuthenticated
|
return domain.AppAuthData{}, ErrNotAuthenticated
|
||||||
}
|
}
|
||||||
return *c.authData, nil
|
return *c.authData, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Context) AuthenticateUser(authData domain.UserAuthData) {
|
||||||
|
c.userAuthenticated = true
|
||||||
|
c.userAuthData = &authData
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Context) GetUserAuthData() (domain.UserAuthData, error) {
|
||||||
|
if !c.userAuthenticated {
|
||||||
|
return domain.UserAuthData{}, ErrNotAuthenticated
|
||||||
|
}
|
||||||
|
return *c.userAuthData, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Context) SkipAppAuth() bool {
|
||||||
|
return c.userAuthData != nil && c.userAuthData.SkipAppAuth
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Context) IsAdminAuthenticated() bool {
|
func (c *Context) IsAdminAuthenticated() bool {
|
||||||
return c.adminAuthenticated
|
return c.adminAuthenticated
|
||||||
}
|
}
|
||||||
@@ -97,6 +116,14 @@ func (c *Context) SetContext(ctx context.Context) {
|
|||||||
c.request = c.request.WithContext(ctx)
|
c.request = c.request.WithContext(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Context) EnableHttpJsonUtf8Charset(enable bool) {
|
||||||
|
c.httpJsonUtf8Charset = enable
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Context) IsJsonUtf8CharsetEnabled() bool {
|
||||||
|
return c.httpJsonUtf8Charset
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Context) Param(name string) string {
|
func (c *Context) Param(name string) string {
|
||||||
value := c.request.Header.Get(name)
|
value := c.request.Header.Get(name)
|
||||||
if value != "" {
|
if value != "" {
|
||||||
|
|||||||
+101
-23
@@ -2,48 +2,126 @@ package routes
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/middleware"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/cluster"
|
"github.com/julienschmidt/httprouter"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Routes struct {
|
type Routes struct {
|
||||||
innerEndpoints map[string]bool
|
logger log.Logger
|
||||||
requiredPermissions map[string]string
|
allHttpMethods []string
|
||||||
|
router *httprouter.Router
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRoutes() *Routes {
|
func NewRoutes(logger log.Logger) *Routes {
|
||||||
return &Routes{
|
return &Routes{
|
||||||
innerEndpoints: make(map[string]bool),
|
logger: logger,
|
||||||
requiredPermissions: make(map[string]string),
|
allHttpMethods: []string{
|
||||||
|
http.MethodGet,
|
||||||
|
http.MethodHead,
|
||||||
|
http.MethodPost,
|
||||||
|
http.MethodPut,
|
||||||
|
http.MethodPatch,
|
||||||
|
http.MethodDelete,
|
||||||
|
http.MethodConnect,
|
||||||
|
http.MethodOptions,
|
||||||
|
http.MethodTrace,
|
||||||
|
},
|
||||||
|
router: httprouter.New(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Routes) ReceiveRoutes(ctx context.Context, routes cluster.RoutingConfig) error {
|
func (s *Routes) ReceiveRoutes(ctx context.Context, routes cluster.RoutingConfig) error {
|
||||||
newInnerMethods := make(map[string]bool)
|
router := httprouter.New()
|
||||||
newRequiredPermissions := make(map[string]string)
|
|
||||||
for _, backend := range routes {
|
for _, backend := range routes {
|
||||||
for _, v := range backend.Endpoints {
|
for _, descriptor := range backend.Endpoints {
|
||||||
if v.Inner {
|
path := normalizeDescriptorPath(descriptor.Path)
|
||||||
newInnerMethods[v.Path] = true
|
if descriptor.HttpMethod != "" {
|
||||||
}
|
s.registerEndpoint(router, backend.ModuleName, descriptor.HttpMethod, path, descriptor)
|
||||||
perm, ok := cluster.GetRequiredAdminPermission(v)
|
} else {
|
||||||
if ok {
|
for _, httpMethod := range s.allHttpMethods {
|
||||||
newRequiredPermissions[v.Path] = perm
|
s.registerEndpoint(router, backend.ModuleName, httpMethod, path, descriptor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.innerEndpoints = newInnerMethods
|
s.router = router
|
||||||
s.requiredPermissions = newRequiredPermissions
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Routes) IsInnerEndpoint(path string) bool {
|
func (s *Routes) ResolveEndpoint(method string, path string, cfg middleware.EntryPointConfig) (*domain.EndpointMeta, error) {
|
||||||
return s.innerEndpoints[path]
|
lookupPath, metaEndpoint := s.GetPaths(path, cfg)
|
||||||
|
|
||||||
|
handler, params, _ := s.router.Lookup(method, lookupPath)
|
||||||
|
|
||||||
|
if handler == nil {
|
||||||
|
if cfg.ErrorOnUnknownEndpoint {
|
||||||
|
return nil, errors.Errorf("unknown endpoint '%s'", lookupPath)
|
||||||
|
}
|
||||||
|
return &domain.EndpointMeta{
|
||||||
|
Endpoint: metaEndpoint,
|
||||||
|
NormalizedEndpoint: normalizePath(metaEndpoint),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
req, _ := http.NewRequestWithContext(context.Background(), method, lookupPath, nil)
|
||||||
|
handler(nil, req, params)
|
||||||
|
|
||||||
|
meta := domain.EndpointMetaFromContext(req.Context())
|
||||||
|
meta.Endpoint = metaEndpoint
|
||||||
|
meta.NormalizedEndpoint = normalizePath(meta.PathSchema)
|
||||||
|
return &meta, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Routes) RequiredAdminPermission(path string) (string, bool) {
|
func (s *Routes) GetPaths(path string, cfg middleware.EntryPointConfig) (string, string) {
|
||||||
perm, ok := s.requiredPermissions[path]
|
lookupPath := path
|
||||||
return perm, ok
|
if !cfg.WithPrefix {
|
||||||
|
lookupPath = strings.TrimPrefix(lookupPath, cfg.PathPrefix)
|
||||||
|
}
|
||||||
|
metaEndpoint := lookupPath
|
||||||
|
if !cfg.WithLendingSlash {
|
||||||
|
metaEndpoint = strings.TrimLeft(metaEndpoint, "/")
|
||||||
|
}
|
||||||
|
return lookupPath, metaEndpoint
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Routes) registerEndpoint(
|
||||||
|
router *httprouter.Router,
|
||||||
|
moduleName string,
|
||||||
|
httpMethod string,
|
||||||
|
path string,
|
||||||
|
descriptor cluster.EndpointDescriptor,
|
||||||
|
) {
|
||||||
|
defer func() {
|
||||||
|
_ = recover()
|
||||||
|
}()
|
||||||
|
|
||||||
|
requiredAdminPerm, _ := cluster.GetRequiredAdminPermission(descriptor)
|
||||||
|
meta := domain.EndpointMeta{
|
||||||
|
Inner: descriptor.Inner,
|
||||||
|
UserAuthRequired: descriptor.UserAuthRequired,
|
||||||
|
ModuleName: moduleName,
|
||||||
|
RequiredAdminPermission: requiredAdminPerm,
|
||||||
|
PathSchema: descriptor.Path,
|
||||||
|
}
|
||||||
|
|
||||||
|
handler := func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||||
|
ctx := meta.ToContext(r.Context())
|
||||||
|
// хак для передачи метадаты обратно в код
|
||||||
|
*r = *r.WithContext(ctx)
|
||||||
|
}
|
||||||
|
router.Handle(httpMethod, path, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func normalizePath(path string) string {
|
||||||
|
return strings.TrimPrefix(path, "/")
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package routes
|
||||||
|
|
||||||
|
import "strings"
|
||||||
|
|
||||||
|
// nolint:mnd
|
||||||
|
func normalizeDescriptorPath(path string) string {
|
||||||
|
pathParts := strings.Split(path, " ")
|
||||||
|
// хак для endpoint'ов с GET /path
|
||||||
|
if len(pathParts) == 2 {
|
||||||
|
path = pathParts[1]
|
||||||
|
}
|
||||||
|
if !strings.HasPrefix(path, "/") {
|
||||||
|
path = "/" + path
|
||||||
|
}
|
||||||
|
return path
|
||||||
|
}
|
||||||
+8
-3
@@ -4,12 +4,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AdminAuth interface {
|
type AdminAuth interface {
|
||||||
Authenticate(ctx context.Context, token string) (*domain.AdminAuthenticateResponse, error)
|
Authenticate(ctx context.Context, token string) (*entity.AdminAuthenticateResponse, error)
|
||||||
Authorize(ctx context.Context, adminId int, permission string) (bool, error)
|
Authorize(ctx context.Context, adminId int, permission string) (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +31,11 @@ func (s Admin) AdminAuthenticate(ctx context.Context, token string) (*domain.Adm
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "get admin token data from admin service")
|
return nil, errors.WithMessage(err, "get admin token data from admin service")
|
||||||
}
|
}
|
||||||
return resp, nil
|
return &domain.AdminAuthenticateResponse{
|
||||||
|
Authenticated: resp.Authenticated,
|
||||||
|
ErrorReason: resp.ErrorReason,
|
||||||
|
AdminId: resp.AdminId,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Admin) AdminAuthorize(ctx context.Context, adminId int, permission string) (bool, error) {
|
func (s Admin) AdminAuthorize(ctx context.Context, adminId int, permission string) (bool, error) {
|
||||||
|
|||||||
+46
-19
@@ -2,54 +2,81 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuthenticationCache interface {
|
type AuthenticationCache interface {
|
||||||
Get(ctx context.Context, token string) (*domain.AuthData, error)
|
Get(ctx context.Context, token string) (*entity.AppAuthData, error)
|
||||||
Set(ctx context.Context, token string, data domain.AuthData) error
|
Set(ctx context.Context, token string, data entity.AppAuthData) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthenticationRepo interface {
|
type AuthenticationRepo interface {
|
||||||
Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error)
|
Authenticate(ctx context.Context, token string) (*entity.AuthenticateResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Auth struct {
|
type Authentication struct {
|
||||||
cache AuthenticationCache
|
cache AuthenticationCache
|
||||||
repo AuthenticationRepo
|
repo AuthenticationRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAuthentication(cache AuthenticationCache, repo AuthenticationRepo) Auth {
|
func NewAuthentication(
|
||||||
return Auth{
|
cache AuthenticationCache,
|
||||||
|
repo AuthenticationRepo,
|
||||||
|
) Authentication {
|
||||||
|
return Authentication{
|
||||||
cache: cache,
|
cache: cache,
|
||||||
repo: repo,
|
repo: repo,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Auth) Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error) {
|
func (s Authentication) Authenticate(ctx context.Context, token string) (*domain.AuthenticateAppResponse, error) {
|
||||||
authData, err := s.cache.Get(ctx, token)
|
authData, err := s.cache.Get(ctx, token)
|
||||||
if errors.Is(err, domain.ErrAuthenticationCacheMiss) {
|
switch {
|
||||||
|
case errors.Is(err, domain.ErrAuthenticationCacheMiss):
|
||||||
resp, err := s.repo.Authenticate(ctx, token)
|
resp, err := s.repo.Authenticate(ctx, token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "auth repo authenticate")
|
return nil, errors.WithMessage(err, "auth repo authenticate")
|
||||||
}
|
}
|
||||||
if !resp.Authenticated {
|
if !resp.Authenticated {
|
||||||
return resp, nil
|
return s.convertAuthReponse(resp), nil
|
||||||
}
|
}
|
||||||
err = s.cache.Set(ctx, token, *resp.AuthData)
|
err = s.cache.Set(ctx, token, *resp.AuthData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "auth cache set")
|
return nil, errors.WithMessage(err, "auth cache set")
|
||||||
}
|
}
|
||||||
return resp, nil
|
return s.convertAuthReponse(resp), nil
|
||||||
}
|
case err != nil:
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "auth cache get")
|
return nil, errors.WithMessage(err, "auth cache get")
|
||||||
|
default:
|
||||||
|
return &domain.AuthenticateAppResponse{
|
||||||
|
Authenticated: true,
|
||||||
|
ErrorReason: "",
|
||||||
|
AuthData: s.convertAuthData(authData),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Authentication) convertAuthReponse(resp *entity.AuthenticateResponse) *domain.AuthenticateAppResponse {
|
||||||
|
return &domain.AuthenticateAppResponse{
|
||||||
|
Authenticated: resp.Authenticated,
|
||||||
|
ErrorReason: resp.ErrorReason,
|
||||||
|
AuthData: s.convertAuthData(resp.AuthData),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Authentication) convertAuthData(authData *entity.AppAuthData) *domain.AppAuthData {
|
||||||
|
if authData == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &domain.AppAuthData{
|
||||||
|
AppName: authData.AppName,
|
||||||
|
SystemId: authData.SystemId,
|
||||||
|
DomainId: authData.DomainId,
|
||||||
|
ServiceId: authData.ServiceId,
|
||||||
|
ApplicationId: authData.ApplicationId,
|
||||||
}
|
}
|
||||||
return &domain.AuthenticateResponse{
|
|
||||||
Authenticated: true,
|
|
||||||
ErrorReason: "",
|
|
||||||
AuthData: authData,
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,10 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuthorizationCache interface {
|
type AuthorizationCache interface {
|
||||||
@@ -12,7 +14,7 @@ type AuthorizationCache interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AuthorizationRepo interface {
|
type AuthorizationRepo interface {
|
||||||
Authorize(ctx context.Context, applicationId int, endpoint string) (bool, error)
|
Authorize(ctx context.Context, req entity.AuthorizeRequest) (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Authorization struct {
|
type Authorization struct {
|
||||||
@@ -27,21 +29,26 @@ func NewAuthorization(cache AuthorizationCache, repo AuthorizationRepo) Authoriz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Authorization) Authorize(ctx context.Context, applicationId int, endpoint string) (bool, error) {
|
func (s Authorization) Authorize(ctx context.Context, applicationId int, httpMethod string, endpoint string) (bool, error) {
|
||||||
ok, err := s.cache.Get(ctx, applicationId, endpoint)
|
cacheKey := fmt.Sprintf("%s %s", httpMethod, endpoint)
|
||||||
|
ok, err := s.cache.Get(ctx, applicationId, cacheKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.WithMessage(err, "authz cache get")
|
return false, errors.WithMessage(err, "authz cache get")
|
||||||
}
|
}
|
||||||
if ok {
|
if ok {
|
||||||
return ok, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ok, err = s.repo.Authorize(ctx, applicationId, endpoint)
|
ok, err = s.repo.Authorize(ctx, entity.AuthorizeRequest{
|
||||||
|
ApplicationId: applicationId,
|
||||||
|
HttpMethod: httpMethod,
|
||||||
|
Endpoint: endpoint,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.WithMessagef(err, "authz repo authorize")
|
return false, errors.WithMessagef(err, "authz repo authorize")
|
||||||
}
|
}
|
||||||
if ok {
|
if ok {
|
||||||
err = s.cache.SetAuthorized(ctx, applicationId, endpoint)
|
err = s.cache.SetAuthorized(ctx, applicationId, cacheKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.WithMessagef(err, "authz cache set")
|
return false, errors.WithMessagef(err, "authz cache set")
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-5
@@ -2,14 +2,15 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"isp-gate-service/conf"
|
"isp-gate-service/conf"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DailyLimitRepo interface {
|
type DailyLimitRepo interface {
|
||||||
Increment(ctx context.Context, applicationId int, today time.Time) (int64, error)
|
Increment(ctx context.Context, key string, today time.Time) (int64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type DailyLimit struct {
|
type DailyLimit struct {
|
||||||
@@ -29,15 +30,21 @@ func NewDailyLimit(repo DailyLimitRepo, configs []conf.DailyLimit) DailyLimit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s DailyLimit) IncrementAndCheck(ctx context.Context, applicationId int) (bool, error) {
|
func (s DailyLimit) IncrementAndCheck(ctx context.Context, applicationId int) (bool, error) {
|
||||||
max, ok := s.limits[applicationId]
|
limit, ok := s.limits[applicationId]
|
||||||
if !ok {
|
if !ok {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
newValue, err := s.repo.Increment(ctx, applicationId, time.Now())
|
key := s.key(applicationId, time.Now())
|
||||||
|
newValue, err := s.repo.Increment(ctx, key, time.Now())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.WithMessage(err, "increment")
|
return false, errors.WithMessage(err, "increment")
|
||||||
}
|
}
|
||||||
|
|
||||||
return newValue <= max, nil
|
return newValue <= limit, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s DailyLimit) key(applicationId int, today time.Time) string {
|
||||||
|
y, m, d := today.Date()
|
||||||
|
return fmt.Sprintf("isp-gate-service::daily-limit::%d:%d-%d-%d", applicationId, y, m, d)
|
||||||
}
|
}
|
||||||
+18
-7
@@ -2,22 +2,24 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"isp-gate-service/conf"
|
"isp-gate-service/conf"
|
||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/entity"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ThrottlingRepo interface {
|
type LockRepo interface {
|
||||||
IsAllowRequestPerSecond(ctx context.Context, applicationId int, rate int) (*domain.RateLimitResult, error)
|
IsAllowRequestPerSecond(ctx context.Context, key string, rate int) (*entity.RateLimiterResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Throttling struct {
|
type Throttling struct {
|
||||||
repo ThrottlingRepo
|
repo LockRepo
|
||||||
limits map[int]int
|
limits map[int]int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewThrottling(repo ThrottlingRepo, configs []conf.Throttling) Throttling {
|
func NewThrottling(repo LockRepo, configs []conf.Throttling) Throttling {
|
||||||
limits := make(map[int]int)
|
limits := make(map[int]int)
|
||||||
for _, config := range configs {
|
for _, config := range configs {
|
||||||
limits[config.ApplicationId] = config.RequestsPerSeconds
|
limits[config.ApplicationId] = config.RequestsPerSeconds
|
||||||
@@ -38,10 +40,19 @@ func (s Throttling) AllowRateLimit(ctx context.Context, applicationId int) (*dom
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := s.repo.IsAllowRequestPerSecond(ctx, applicationId, rate)
|
key := s.key(applicationId)
|
||||||
|
result, err := s.repo.IsAllowRequestPerSecond(ctx, key, rate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "is allow request per second")
|
return nil, errors.WithMessage(err, "is allow request per second")
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return &domain.RateLimitResult{
|
||||||
|
Allow: result.Allow,
|
||||||
|
Remaining: result.Remaining,
|
||||||
|
RetryAfter: result.RetryAfter,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Throttling) key(applicationId int) string {
|
||||||
|
return fmt.Sprintf("isp-gate-service::rate-limit::%d", applicationId)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package token_provider
|
||||||
|
|
||||||
|
import (
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/request"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CookieProvider struct {
|
||||||
|
name string
|
||||||
|
cookieName string
|
||||||
|
validate bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCookieProvider(name string, cfg conf.CookieTokenProvider) CookieProvider {
|
||||||
|
return CookieProvider{
|
||||||
|
name: name,
|
||||||
|
cookieName: cfg.CookieName,
|
||||||
|
validate: cfg.Validate,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p CookieProvider) GetName() string {
|
||||||
|
return p.name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p CookieProvider) ExtractToken(ctx *request.Context) (string, error) {
|
||||||
|
cookie, err := ctx.Request().Cookie(p.cookieName)
|
||||||
|
switch {
|
||||||
|
case errors.Is(err, http.ErrNoCookie):
|
||||||
|
return "", nil
|
||||||
|
case err != nil:
|
||||||
|
return "", errors.WithMessagef(err, "get cookie with name '%s'", p.cookieName)
|
||||||
|
}
|
||||||
|
if !p.validate {
|
||||||
|
return strings.TrimSpace(cookie.Value), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = cookie.Valid()
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.WithMessagef(err, "validate cookie with name '%s'", p.cookieName)
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(cookie.Value), nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package token_provider
|
||||||
|
|
||||||
|
import (
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/request"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type HeaderProvider struct {
|
||||||
|
name string
|
||||||
|
headerName string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewHeaderProvider(name string, cfg conf.HeaderTokenProvider) HeaderProvider {
|
||||||
|
return HeaderProvider{
|
||||||
|
name: name,
|
||||||
|
headerName: cfg.HeaderName,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p HeaderProvider) GetName() string {
|
||||||
|
return p.name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p HeaderProvider) ExtractToken(ctx *request.Context) (string, error) {
|
||||||
|
value := ctx.Request().Header.Get(p.headerName)
|
||||||
|
return strings.TrimSpace(value), nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,234 @@
|
|||||||
|
// nolint:ireturn
|
||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
"isp-gate-service/request"
|
||||||
|
"isp-gate-service/service/token_provider"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserAuthenticationCache interface {
|
||||||
|
Get(ctx context.Context, authEndpoint string, token string) (*entity.UserAuthData, error)
|
||||||
|
Set(ctx context.Context, authEndpoint string, token string, data entity.UserAuthData, duration time.Duration) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserAuthenticationRepo interface {
|
||||||
|
Authenticate(ctx context.Context, authEndpoint string, token string) (*entity.UserAuthenticateResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type TokenProvider interface {
|
||||||
|
GetName() string
|
||||||
|
ExtractToken(ctx *request.Context) (string, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type userAuthSetting struct {
|
||||||
|
tokenProviders []TokenProvider
|
||||||
|
authEndpoint string
|
||||||
|
authCacheDuration time.Duration
|
||||||
|
skipAppAuth bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserAuthentication struct {
|
||||||
|
cache UserAuthenticationCache
|
||||||
|
repo UserAuthenticationRepo
|
||||||
|
settingsByModuleName map[string]userAuthSetting
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserAuthentication(
|
||||||
|
cfg conf.CustomAuth,
|
||||||
|
cache UserAuthenticationCache,
|
||||||
|
repo UserAuthenticationRepo,
|
||||||
|
) (UserAuthentication, error) {
|
||||||
|
tokenProviders := make(map[string]TokenProvider, len(cfg.TokenProviders))
|
||||||
|
for i, provider := range cfg.TokenProviders {
|
||||||
|
_, ok := tokenProviders[provider.Name]
|
||||||
|
if ok {
|
||||||
|
return UserAuthentication{}, errors.Errorf("token provider name must have unique name, found duplicate at [%d] with name '%s'", i, provider.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenProvider, err := tokenProviderFromConfig(provider)
|
||||||
|
if err != nil {
|
||||||
|
return UserAuthentication{}, errors.WithMessagef(err, "init token provider with name '%s'", provider.Name)
|
||||||
|
}
|
||||||
|
tokenProviders[provider.Name] = tokenProvider
|
||||||
|
}
|
||||||
|
|
||||||
|
settingsByModuleName := make(map[string]userAuthSetting, len(cfg.UserAuthSettings))
|
||||||
|
for _, setting := range cfg.UserAuthSettings {
|
||||||
|
settingTokenProviders := make([]TokenProvider, 0, len(setting.TokenProviders))
|
||||||
|
for _, providerName := range setting.TokenProviders {
|
||||||
|
tokenProvider, ok := tokenProviders[providerName]
|
||||||
|
if !ok {
|
||||||
|
return UserAuthentication{},
|
||||||
|
errors.Errorf("modules with names'[%s]' has unknown token provider '%s'",
|
||||||
|
strings.Join(setting.ModuleNameList, ","),
|
||||||
|
providerName,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
settingTokenProviders = append(settingTokenProviders, tokenProvider)
|
||||||
|
}
|
||||||
|
|
||||||
|
cacheDuration := time.Duration(setting.CacheDataInSec) * time.Second
|
||||||
|
for _, moduleName := range setting.ModuleNameList {
|
||||||
|
_, ok := settingsByModuleName[moduleName]
|
||||||
|
if ok {
|
||||||
|
return UserAuthentication{},
|
||||||
|
errors.Errorf("setting unique violation, setting for module with name '%s' already present",
|
||||||
|
moduleName,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
settingsByModuleName[moduleName] = userAuthSetting{
|
||||||
|
tokenProviders: settingTokenProviders,
|
||||||
|
authEndpoint: setting.AuthenticateEndpoint,
|
||||||
|
authCacheDuration: cacheDuration,
|
||||||
|
skipAppAuth: setting.SkipAppAuth,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return UserAuthentication{
|
||||||
|
cache: cache,
|
||||||
|
repo: repo,
|
||||||
|
settingsByModuleName: settingsByModuleName,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s UserAuthentication) Authenticate(ctx *request.Context) (*domain.AuthenticateUserResponse, error) {
|
||||||
|
meta := ctx.EndpointMeta()
|
||||||
|
if !meta.UserAuthRequired {
|
||||||
|
return &domain.AuthenticateUserResponse{
|
||||||
|
SkipUserAuth: true,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
setting, ok := s.settingsByModuleName[meta.ModuleName]
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.WithMessagef(domain.ErrUserAuthSettingNotFound,
|
||||||
|
"setting for module '%s' and endpoint '%s' not found",
|
||||||
|
meta.ModuleName, meta.Endpoint,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
token, err := s.extractToken(ctx, setting.tokenProviders)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "extract user token")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.authenticate(
|
||||||
|
ctx.Context(),
|
||||||
|
setting,
|
||||||
|
token,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "auth")
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s UserAuthentication) extractToken(ctx *request.Context, providers []TokenProvider) (string, error) {
|
||||||
|
for _, provider := range providers {
|
||||||
|
token, err := provider.ExtractToken(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.WithMessagef(
|
||||||
|
domain.ErrInvalidUserToken,
|
||||||
|
"extract token by '%s' error: %s",
|
||||||
|
provider.GetName(),
|
||||||
|
err.Error(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if token != "" {
|
||||||
|
return token, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "", domain.ErrEmptyUserToken
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s UserAuthentication) authenticate(
|
||||||
|
ctx context.Context,
|
||||||
|
setting userAuthSetting,
|
||||||
|
token string,
|
||||||
|
) (*domain.AuthenticateUserResponse, error) {
|
||||||
|
if setting.authCacheDuration <= 0 {
|
||||||
|
resp, err := s.repo.Authenticate(ctx, setting.authEndpoint, token)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "auth repo authenticate")
|
||||||
|
}
|
||||||
|
return s.convertAuthResponse(resp, setting.skipAppAuth), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
authData, err := s.cache.Get(ctx, setting.authEndpoint, token)
|
||||||
|
switch {
|
||||||
|
case errors.Is(err, domain.ErrAuthenticationCacheMiss):
|
||||||
|
resp, err := s.repo.Authenticate(ctx, setting.authEndpoint, token)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "auth repo authenticate")
|
||||||
|
}
|
||||||
|
if !resp.Authenticated {
|
||||||
|
return s.convertAuthResponse(resp, setting.skipAppAuth), nil
|
||||||
|
}
|
||||||
|
err = s.cache.Set(
|
||||||
|
ctx,
|
||||||
|
setting.authEndpoint,
|
||||||
|
token,
|
||||||
|
*resp.AuthData,
|
||||||
|
setting.authCacheDuration,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "auth cache set")
|
||||||
|
}
|
||||||
|
return s.convertAuthResponse(resp, setting.skipAppAuth), nil
|
||||||
|
case err != nil:
|
||||||
|
return nil, errors.WithMessage(err, "auth cache get")
|
||||||
|
default:
|
||||||
|
return &domain.AuthenticateUserResponse{
|
||||||
|
Authenticated: true,
|
||||||
|
ErrorReason: "",
|
||||||
|
AuthData: s.convertAuthData(authData, setting.skipAppAuth),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s UserAuthentication) convertAuthResponse(resp *entity.UserAuthenticateResponse, skipAppAuth bool) *domain.AuthenticateUserResponse {
|
||||||
|
return &domain.AuthenticateUserResponse{
|
||||||
|
Authenticated: resp.Authenticated,
|
||||||
|
ErrorReason: resp.ErrorReason,
|
||||||
|
AuthData: s.convertAuthData(resp.AuthData, skipAppAuth),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (UserAuthentication) convertAuthData(authData *entity.UserAuthData, skipAppAuth bool) *domain.UserAuthData {
|
||||||
|
if authData == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &domain.UserAuthData{
|
||||||
|
Identity: authData.Identity,
|
||||||
|
IdentityHeader: authData.IdentityHeader,
|
||||||
|
ExtraHeaders: authData.ExtraHeaders,
|
||||||
|
SkipAppAuth: skipAppAuth,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func tokenProviderFromConfig(cfg conf.TokenProvider) (TokenProvider, error) {
|
||||||
|
switch cfg.Type {
|
||||||
|
case conf.HeaderTokenProviderType:
|
||||||
|
if cfg.HeaderProvider == nil {
|
||||||
|
return nil, errors.Errorf("token method '%s' has empty header provider", cfg.Name)
|
||||||
|
}
|
||||||
|
return token_provider.NewHeaderProvider(cfg.Name, *cfg.HeaderProvider), nil
|
||||||
|
case conf.CookieTokenProviderType:
|
||||||
|
if cfg.CookieProvider == nil {
|
||||||
|
return nil, errors.Errorf("token method '%s' has empty cookie provider", cfg.Name)
|
||||||
|
}
|
||||||
|
return token_provider.NewCookieProvider(cfg.Name, *cfg.CookieProvider), nil
|
||||||
|
default:
|
||||||
|
return nil, errors.Errorf("unknown token provider with type '%s'", cfg.Type)
|
||||||
|
}
|
||||||
|
}
|
||||||
+390
-88
@@ -3,33 +3,40 @@ package tests
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
etp "github.com/integration-system/isp-etp-go/v2"
|
|
||||||
etpcli "github.com/integration-system/isp-etp-go/v2/client"
|
|
||||||
"github.com/integration-system/isp-kit/cluster"
|
|
||||||
"github.com/integration-system/isp-kit/http/httpcli"
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"isp-gate-service/assembly"
|
"isp-gate-service/assembly"
|
||||||
|
"isp-gate-service/cache"
|
||||||
"isp-gate-service/conf"
|
"isp-gate-service/conf"
|
||||||
"isp-gate-service/domain"
|
"isp-gate-service/entity"
|
||||||
"isp-gate-service/routes"
|
"isp-gate-service/routes"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/txix-open/etp/v3"
|
||||||
|
"github.com/txix-open/etp/v3/msg"
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/http/endpoint"
|
||||||
|
"github.com/txix-open/isp-kit/http/endpoint/httplog"
|
||||||
|
"github.com/txix-open/isp-kit/http/httpcli"
|
||||||
|
"github.com/txix-open/isp-kit/http/router"
|
||||||
|
"github.com/txix-open/isp-kit/test/fake"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/integration-system/isp-kit/grpc"
|
|
||||||
"github.com/integration-system/isp-kit/grpc/client"
|
|
||||||
"github.com/integration-system/isp-kit/lb"
|
|
||||||
"github.com/integration-system/isp-kit/log"
|
|
||||||
"github.com/integration-system/isp-kit/requestid"
|
|
||||||
"github.com/integration-system/isp-kit/test"
|
|
||||||
"github.com/integration-system/isp-kit/test/grpct"
|
|
||||||
"github.com/integration-system/isp-kit/test/httpt"
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
"github.com/txix-open/isp-kit/grpc"
|
||||||
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
|
"github.com/txix-open/isp-kit/lb"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
"github.com/txix-open/isp-kit/requestid"
|
||||||
|
"github.com/txix-open/isp-kit/test"
|
||||||
|
"github.com/txix-open/isp-kit/test/grpct"
|
||||||
|
"github.com/txix-open/isp-kit/test/httpt"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -47,7 +54,7 @@ type HappyPathTestSuite struct {
|
|||||||
|
|
||||||
func (s *HappyPathTestSuite) TestGrpcProxy() {
|
func (s *HappyPathTestSuite) TestGrpcProxy() {
|
||||||
test, require := test.New(s.T())
|
test, require := test.New(s.T())
|
||||||
config, redisCli, systemCli, adminCli := s.commonDependencies(test)
|
config, systemCli, adminCli := s.commonDependencies(test)
|
||||||
|
|
||||||
requestId := requestid.Next()
|
requestId := requestid.Next()
|
||||||
targetService, targetCli := grpct.NewMock(test)
|
targetService, targetCli := grpct.NewMock(test)
|
||||||
@@ -70,12 +77,21 @@ func (s *HappyPathTestSuite) TestGrpcProxy() {
|
|||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.EqualValues("1", adminId)
|
require.EqualValues("1", adminId)
|
||||||
|
|
||||||
return response{Id: req.Id} //nolint:gosimple
|
return response{Id: req.Id}
|
||||||
})
|
})
|
||||||
targetClients := map[string]*client.Client{"target": targetCli}
|
targetClients := map[string]*client.Client{"target": targetCli}
|
||||||
logger, err := log.New(log.WithLevel(log.DebugLevel))
|
logger, err := log.New(log.WithLevel(log.DebugLevel))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
locator := assembly.NewLocator(logger, targetClients, nil, routes.NewRoutes(), systemCli, adminCli)
|
|
||||||
|
routes := routes.NewRoutes(logger)
|
||||||
|
err = routes.ReceiveRoutes(s.T().Context(), cluster.RoutingConfig{{
|
||||||
|
Endpoints: []cluster.EndpointDescriptor{{
|
||||||
|
Path: "endpoint",
|
||||||
|
}},
|
||||||
|
}})
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli, nil, nil, nil)
|
||||||
|
|
||||||
locations := []conf.Location{{
|
locations := []conf.Location{{
|
||||||
SkipAuth: false,
|
SkipAuth: false,
|
||||||
@@ -83,107 +99,120 @@ func (s *HappyPathTestSuite) TestGrpcProxy() {
|
|||||||
Protocol: "grpc",
|
Protocol: "grpc",
|
||||||
TargetModule: "target",
|
TargetModule: "target",
|
||||||
}}
|
}}
|
||||||
handler, err := locator.Handler(config, locations, redisCli)
|
handler, err := locator.Handler(config, locations)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
srv := httptest.NewServer(handler)
|
srv := httptest.NewServer(handler)
|
||||||
cli := httpcli.New()
|
cli := httpcli.New()
|
||||||
req := request{Id: uuid.New().String()}
|
req := request{Id: uuid.New().String()}
|
||||||
resp := response{}
|
resp := response{}
|
||||||
_, err = cli.Post(srv.URL+"/api/endpoint").
|
err = cli.Post(srv.URL+"/api/endpoint").
|
||||||
Header("x-application-token", "token").
|
Header("x-application-token", "token").
|
||||||
Header("x-request-id", requestId).
|
Header("x-request-id", requestId).
|
||||||
Header("x-auth-admin", "mock-token").
|
Header("x-auth-admin", "mock-token").
|
||||||
JsonRequestBody(req).
|
JsonRequestBody(req).
|
||||||
JsonResponseBody(&resp).
|
JsonResponseBody(&resp).
|
||||||
StatusCodeToError().
|
StatusCodeToError().
|
||||||
Do(context.Background())
|
DoWithoutResponse(s.T().Context())
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.EqualValues(req.Id, resp.Id)
|
require.EqualValues(req.Id, resp.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *HappyPathTestSuite) TestHttpProxy() {
|
func (s *HappyPathTestSuite) TestHttpProxy() {
|
||||||
test, require := test.New(s.T())
|
test, require := test.New(s.T())
|
||||||
config, redisCli, systemCli, adminCli := s.commonDependencies(test)
|
config, systemCli, adminCli := s.commonDependencies(test)
|
||||||
|
|
||||||
requestId := requestid.Next()
|
requestId := requestid.Next()
|
||||||
targetService := httpt.NewMock(test)
|
targetService := httpt.NewMock(test)
|
||||||
targetService.POST("/endpoint", func(ctx context.Context, httpReq *http.Request, req request) response {
|
targetService.POST("/endpoint", func(ctx context.Context, httpReq *http.Request, req request) response {
|
||||||
assertHeaders(require, requestId, ctx, httpReq.Header)
|
assertHeaders(require, requestId, ctx, httpReq.Header)
|
||||||
return response{Id: req.Id} //nolint:gosimple
|
return response{Id: req.Id}
|
||||||
})
|
})
|
||||||
targetUrl, err := url.Parse(targetService.BaseURL())
|
targetUrl, err := url.Parse(targetService.BaseURL())
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
rr := lb.NewRoundRobin([]string{targetUrl.Host})
|
rr := lb.NewRoundRobin([]string{targetUrl.Host})
|
||||||
targetClients := map[string]*lb.RoundRobin{"target": rr}
|
targetClients := map[string]*lb.RoundRobin{"target": rr}
|
||||||
locator := assembly.NewLocator(test.Logger(), nil, targetClients, routes.NewRoutes(), systemCli, adminCli)
|
|
||||||
|
routes := routes.NewRoutes(test.Logger())
|
||||||
|
err = routes.ReceiveRoutes(s.T().Context(), cluster.RoutingConfig{{
|
||||||
|
Endpoints: []cluster.EndpointDescriptor{{
|
||||||
|
Path: "/endpoint",
|
||||||
|
}},
|
||||||
|
}})
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
locator := assembly.NewLocator(test.Logger(), nil, targetClients, routes, systemCli, adminCli, nil, nil, nil)
|
||||||
locations := []conf.Location{{
|
locations := []conf.Location{{
|
||||||
SkipAuth: false,
|
SkipAuth: false,
|
||||||
PathPrefix: "/api",
|
PathPrefix: "/api",
|
||||||
Protocol: "http",
|
Protocol: "http",
|
||||||
TargetModule: "target",
|
TargetModule: "target",
|
||||||
}}
|
}}
|
||||||
handler, err := locator.Handler(config, locations, redisCli)
|
handler, err := locator.Handler(config, locations)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
srv := httptest.NewServer(handler)
|
srv := httptest.NewServer(handler)
|
||||||
cli := httpcli.New()
|
cli := httpcli.New()
|
||||||
req := request{Id: uuid.New().String()}
|
req := request{Id: uuid.New().String()}
|
||||||
resp := response{}
|
resp := response{}
|
||||||
_, err = cli.Post(srv.URL+"/api/endpoint").
|
err = cli.Post(srv.URL+"/api/endpoint").
|
||||||
Header("x-application-token", "token").
|
Header("x-application-token", "token").
|
||||||
Header("x-request-id", requestId).
|
Header("x-request-id", requestId).
|
||||||
Header("x-auth-admin", "mock-token").
|
Header("x-auth-admin", "mock-token").
|
||||||
JsonRequestBody(req).
|
JsonRequestBody(req).
|
||||||
JsonResponseBody(&resp).
|
JsonResponseBody(&resp).
|
||||||
StatusCodeToError().
|
StatusCodeToError().
|
||||||
Do(context.Background())
|
DoWithoutResponse(s.T().Context())
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.EqualValues(req.Id, resp.Id)
|
require.EqualValues(req.Id, resp.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *HappyPathTestSuite) TestWsProxy() { // nolint: funlen
|
func (s *HappyPathTestSuite) TestWsProxy() { // nolint:funlen
|
||||||
test, require := test.New(s.T())
|
test, require := test.New(s.T())
|
||||||
config, redisCli, systemCli, adminCli := s.commonDependencies(test)
|
config, systemCli, adminCli := s.commonDependencies(test)
|
||||||
|
|
||||||
requestId := requestid.Next()
|
requestId := requestid.Next()
|
||||||
wsServer := etp.NewServer(context.Background(), etp.ServerConfig{
|
wsServer := etp.NewServer(etp.WithServerReadLimit(2048))
|
||||||
ConnectionReadLimit: 2048,
|
wsServer.On("hello", wsEventHandlerMock{
|
||||||
InsecureSkipVerify: true,
|
requestId: requestId,
|
||||||
})
|
require: require,
|
||||||
wsServer.OnWithAck("hello", func(conn etp.Conn, data []byte) []byte {
|
t: test.T(),
|
||||||
headers := conn.RemoteHeader()
|
|
||||||
ctx := requestid.ToContext(context.Background(), headers.Get("x-request-id"))
|
|
||||||
assertHeaders(require, requestId, ctx, headers)
|
|
||||||
require.EqualValues("data", string(data))
|
|
||||||
return []byte("world")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
wsMux := http.NewServeMux()
|
wsMux := http.NewServeMux()
|
||||||
wsMux.Handle("/service", http.HandlerFunc(func(writer http.ResponseWriter, r *http.Request) {
|
wsMux.Handle("/service", http.HandlerFunc(func(writer http.ResponseWriter, r *http.Request) {
|
||||||
wsServer.ServeHttp(writer, r)
|
wsServer.ServeHTTP(writer, r)
|
||||||
}))
|
}))
|
||||||
targetService := httptest.NewServer(wsMux)
|
targetService := httptest.NewServer(wsMux)
|
||||||
targetUrl, err := url.Parse(targetService.URL)
|
targetUrl, err := url.Parse(targetService.URL)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
rr := lb.NewRoundRobin([]string{targetUrl.Host})
|
rr := lb.NewRoundRobin([]string{targetUrl.Host})
|
||||||
targetClients := map[string]*lb.RoundRobin{"target": rr}
|
targetClients := map[string]*lb.RoundRobin{"target": rr}
|
||||||
locator := assembly.NewLocator(test.Logger(), nil, targetClients, routes.NewRoutes(), systemCli, adminCli)
|
|
||||||
|
routes := routes.NewRoutes(test.Logger())
|
||||||
|
err = routes.ReceiveRoutes(s.T().Context(), cluster.RoutingConfig{{
|
||||||
|
Endpoints: []cluster.EndpointDescriptor{{
|
||||||
|
Path: "/service",
|
||||||
|
}},
|
||||||
|
}})
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
locator := assembly.NewLocator(test.Logger(), nil, targetClients, routes, systemCli, adminCli, nil, nil, nil)
|
||||||
locations := []conf.Location{{
|
locations := []conf.Location{{
|
||||||
SkipAuth: false,
|
SkipAuth: false,
|
||||||
PathPrefix: "/ws",
|
PathPrefix: "/ws",
|
||||||
Protocol: "ws",
|
Protocol: "ws",
|
||||||
TargetModule: "target",
|
TargetModule: "target",
|
||||||
}}
|
}}
|
||||||
handler, err := locator.Handler(config, locations, redisCli)
|
handler, err := locator.Handler(config, locations)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
srv := httptest.NewServer(handler)
|
srv := httptest.NewServer(handler)
|
||||||
|
|
||||||
cli := etpcli.NewClient(etpcli.Config{
|
cli := etp.NewClient(etp.WithClientDialOptions(&etp.DialOptions{
|
||||||
HttpHeaders: map[string][]string{
|
HTTPHeader: map[string][]string{
|
||||||
"x-request-id": {requestId},
|
"x-request-id": {requestId},
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
requestUrl, err := url.Parse(srv.URL)
|
requestUrl, err := url.Parse(srv.URL)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
requestUrl.Path = "ws/service"
|
requestUrl.Path = "ws/service"
|
||||||
@@ -193,26 +222,42 @@ func (s *HappyPathTestSuite) TestWsProxy() { // nolint: funlen
|
|||||||
}.Encode()
|
}.Encode()
|
||||||
err = cli.Dial(context.Background(), requestUrl.String())
|
err = cli.Dial(context.Background(), requestUrl.String())
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
resp, err := cli.EmitWithAck(context.Background(), "hello", []byte("data"))
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
|
||||||
|
defer cancel()
|
||||||
|
resp, err := cli.EmitWithAck(ctx, "hello", []byte("data"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.EqualValues("world", string(resp))
|
require.EqualValues("world", string(resp))
|
||||||
err = cli.Close()
|
err = cli.Close()
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wsEventHandlerMock struct {
|
||||||
|
requestId string
|
||||||
|
require *require.Assertions
|
||||||
|
t require.TestingT
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s wsEventHandlerMock) Handle(_ context.Context, conn *etp.Conn, event msg.Event) []byte {
|
||||||
|
headers := conn.HttpRequest().Header
|
||||||
|
ctx := requestid.ToContext(context.Background(), headers.Get("x-request-id"))
|
||||||
|
assertHeaders(s.require, s.requestId, ctx, headers)
|
||||||
|
require.EqualValues(s.t, "data", event.Data)
|
||||||
|
return []byte("world")
|
||||||
|
}
|
||||||
|
|
||||||
func (s *HappyPathTestSuite) TestAdminAuthorization() {
|
func (s *HappyPathTestSuite) TestAdminAuthorization() {
|
||||||
test, require := test.New(s.T())
|
test, require := test.New(s.T())
|
||||||
config, redisCli, systemCli, adminCli := s.commonDependencies(test)
|
config, systemCli, adminCli := s.commonDependencies(test)
|
||||||
|
|
||||||
targetService, targetCli := grpct.NewMock(test)
|
targetService, targetCli := grpct.NewMock(test)
|
||||||
targetService.Mock("endpoint", func(ctx context.Context, authData grpc.AuthData, req request) response {
|
targetService.Mock("endpoint", func(ctx context.Context, authData grpc.AuthData, req request) response {
|
||||||
return response{Id: req.Id} //nolint:gosimple
|
return response{Id: req.Id}
|
||||||
})
|
})
|
||||||
targetClients := map[string]*client.Client{"target": targetCli}
|
targetClients := map[string]*client.Client{"target": targetCli}
|
||||||
logger, err := log.New(log.WithLevel(log.DebugLevel))
|
logger, err := log.New(log.WithLevel(log.DebugLevel))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
routes := routes.NewRoutes()
|
routes := routes.NewRoutes(logger)
|
||||||
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli)
|
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli, nil, nil, nil)
|
||||||
|
|
||||||
locations := []conf.Location{{
|
locations := []conf.Location{{
|
||||||
SkipAuth: false,
|
SkipAuth: false,
|
||||||
@@ -220,7 +265,7 @@ func (s *HappyPathTestSuite) TestAdminAuthorization() {
|
|||||||
Protocol: "grpc",
|
Protocol: "grpc",
|
||||||
TargetModule: "target",
|
TargetModule: "target",
|
||||||
}}
|
}}
|
||||||
handler, err := locator.Handler(config, locations, redisCli)
|
handler, err := locator.Handler(config, locations)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
err = routes.ReceiveRoutes(context.Background(), cluster.RoutingConfig{{
|
err = routes.ReceiveRoutes(context.Background(), cluster.RoutingConfig{{
|
||||||
@@ -241,88 +286,343 @@ func (s *HappyPathTestSuite) TestAdminAuthorization() {
|
|||||||
cli := httpcli.New()
|
cli := httpcli.New()
|
||||||
req := request{Id: uuid.New().String()}
|
req := request{Id: uuid.New().String()}
|
||||||
resp := response{}
|
resp := response{}
|
||||||
_, err = cli.Post(srv.URL+"/api/endpoint").
|
err = cli.Post(srv.URL+"/api/endpoint").
|
||||||
Header("x-application-token", "token").
|
Header("x-application-token", "token").
|
||||||
Header("x-auth-admin", "mock-token").
|
Header("x-auth-admin", "mock-token").
|
||||||
JsonRequestBody(req).
|
JsonRequestBody(req).
|
||||||
JsonResponseBody(&resp).
|
JsonResponseBody(&resp).
|
||||||
StatusCodeToError().
|
StatusCodeToError().
|
||||||
Do(context.Background())
|
DoWithoutResponse(s.T().Context())
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.EqualValues(req.Id, resp.Id)
|
require.EqualValues(req.Id, resp.Id)
|
||||||
|
|
||||||
_, err = cli.Post(srv.URL+"/api/failed_endpoint").
|
err = cli.Post(srv.URL+"/api/failed_endpoint").
|
||||||
Header("x-application-token", "token").
|
Header("x-application-token", "token").
|
||||||
Header("x-auth-admin", "mock-token").
|
Header("x-auth-admin", "mock-token").
|
||||||
JsonRequestBody(req).
|
JsonRequestBody(req).
|
||||||
JsonResponseBody(&resp).
|
JsonResponseBody(&resp).
|
||||||
StatusCodeToError().
|
StatusCodeToError().
|
||||||
Do(context.Background())
|
DoWithoutResponse(s.T().Context())
|
||||||
errResp := httpcli.ErrorResponse{}
|
errResp := httpcli.ErrorResponse{}
|
||||||
require.ErrorAs(err, &errResp)
|
require.ErrorAs(err, &errResp)
|
||||||
require.EqualValues(http.StatusForbidden, errResp.StatusCode)
|
require.EqualValues(http.StatusForbidden, errResp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint:ireturn
|
func (s *HappyPathTestSuite) TestUserAuthorization() { // nolint:funlen
|
||||||
func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, redis.UniversalClient, *client.Client, *client.Client) {
|
test, require := test.New(s.T())
|
||||||
require := test.Assert()
|
config, systemCli, adminCli := s.commonDependencies(test)
|
||||||
redisCli := NewRedis(test)
|
userAuthData := fake.It[entity.UserAuthData]()
|
||||||
ctx := context.Background()
|
userAuthData.IdentityHeader = "x-" + userAuthData.IdentityHeader
|
||||||
|
|
||||||
s.T().Cleanup(func() {
|
targetService, targetCli := grpct.NewMock(test)
|
||||||
_, err := redisCli.Pipelined(ctx, func(p redis.Pipeliner) error {
|
targetService.Mock("endpoint", func(ctx context.Context, authData grpc.AuthData, req request) response {
|
||||||
p.Select(ctx, 0)
|
md, ok := metadata.FromIncomingContext(ctx)
|
||||||
p.FlushDB(ctx)
|
require.True(ok)
|
||||||
p.Select(ctx, 1)
|
require.ElementsMatch([]string{userAuthData.Identity}, md.Get(userAuthData.IdentityHeader))
|
||||||
p.FlushDB(ctx)
|
|
||||||
p.Select(ctx, 2)
|
return response{Id: req.Id}
|
||||||
p.FlushDB(ctx)
|
})
|
||||||
return nil
|
targetService.Mock("failed_auth_endpoint", func(ctx context.Context, authData grpc.AuthData, req request) response {
|
||||||
})
|
return response{Id: req.Id}
|
||||||
require.NoError(err)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
routerMux := router.New()
|
||||||
|
defaultWrapper := endpoint.DefaultWrapper(
|
||||||
|
test.Logger(),
|
||||||
|
httplog.Noop(),
|
||||||
|
)
|
||||||
|
|
||||||
|
userAuthToken := fake.It[string]()
|
||||||
|
|
||||||
|
routerMux.POST("/test-user-auth/authenticate",
|
||||||
|
defaultWrapper.Endpoint(func(req entity.UserAuthenticateRequest) entity.UserAuthenticateResponse {
|
||||||
|
require.Equal(userAuthToken, req.Token)
|
||||||
|
return entity.UserAuthenticateResponse{
|
||||||
|
Authenticated: true,
|
||||||
|
AuthData: &userAuthData,
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
routerMux.POST("/failed-user-auth/authenticate",
|
||||||
|
defaultWrapper.Endpoint(func(req entity.UserAuthenticateRequest) entity.UserAuthenticateResponse {
|
||||||
|
require.Equal(userAuthToken, req.Token)
|
||||||
|
return entity.UserAuthenticateResponse{
|
||||||
|
Authenticated: false,
|
||||||
|
ErrorReason: "test fail",
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
routerMock := httptest.NewServer(routerMux)
|
||||||
|
targetUrl, err := url.Parse(routerMock.URL)
|
||||||
|
require.NoError(err)
|
||||||
|
rr := lb.NewRoundRobin([]string{targetUrl.Host})
|
||||||
|
|
||||||
|
targetClients := map[string]*client.Client{"target": targetCli}
|
||||||
|
logger, err := log.New(log.WithLevel(log.DebugLevel))
|
||||||
|
require.NoError(err)
|
||||||
|
routes := routes.NewRoutes(logger)
|
||||||
|
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli, nil, rr, cache.New())
|
||||||
|
|
||||||
|
locations := []conf.Location{{
|
||||||
|
SkipAuth: false,
|
||||||
|
PathPrefix: "/api",
|
||||||
|
Protocol: "grpc",
|
||||||
|
TargetModule: "target",
|
||||||
|
}}
|
||||||
|
config.CustomAuth = conf.CustomAuth{
|
||||||
|
TokenProviders: []conf.TokenProvider{
|
||||||
|
{
|
||||||
|
Name: "test_provider",
|
||||||
|
Type: conf.HeaderTokenProviderType,
|
||||||
|
HeaderProvider: &conf.HeaderTokenProvider{
|
||||||
|
HeaderName: "test-token-header",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
UserAuthSettings: []conf.UserAuthSetting{
|
||||||
|
{
|
||||||
|
ModuleNameList: []string{"target"},
|
||||||
|
TokenProviders: []string{"test_provider"},
|
||||||
|
AuthenticateEndpoint: "test-user-auth/authenticate",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ModuleNameList: []string{"target2"},
|
||||||
|
TokenProviders: []string{"test_provider"},
|
||||||
|
AuthenticateEndpoint: "failed-user-auth/authenticate",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
handler, err := locator.Handler(config, locations)
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
err = routes.ReceiveRoutes(context.Background(), cluster.RoutingConfig{
|
||||||
|
{
|
||||||
|
ModuleName: "target",
|
||||||
|
Endpoints: []cluster.EndpointDescriptor{{
|
||||||
|
Path: "endpoint",
|
||||||
|
Inner: true,
|
||||||
|
UserAuthRequired: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ModuleName: "target2",
|
||||||
|
Endpoints: []cluster.EndpointDescriptor{
|
||||||
|
{
|
||||||
|
Path: "failed_auth_endpoint",
|
||||||
|
Inner: true,
|
||||||
|
UserAuthRequired: true,
|
||||||
|
}, {
|
||||||
|
Path: "failed_endpoint",
|
||||||
|
Inner: true,
|
||||||
|
UserAuthRequired: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
srv := httptest.NewServer(handler)
|
||||||
|
cli := httpcli.New()
|
||||||
|
req := request{Id: uuid.New().String()}
|
||||||
|
resp := response{}
|
||||||
|
err = cli.Post(srv.URL+"/api/endpoint").
|
||||||
|
Header("x-application-token", "token").
|
||||||
|
Header("test-token-header", userAuthToken).
|
||||||
|
Header("x-auth-admin", "mock-token").
|
||||||
|
JsonRequestBody(req).
|
||||||
|
JsonResponseBody(&resp).
|
||||||
|
StatusCodeToError().
|
||||||
|
DoWithoutResponse(s.T().Context())
|
||||||
|
require.NoError(err)
|
||||||
|
require.EqualValues(req.Id, resp.Id)
|
||||||
|
|
||||||
|
err = cli.Post(srv.URL+"/api/failed_auth_endpoint").
|
||||||
|
Header("x-application-token", "token").
|
||||||
|
Header("test-token-header", userAuthToken).
|
||||||
|
Header("x-auth-admin", "mock-token").
|
||||||
|
JsonRequestBody(req).
|
||||||
|
JsonResponseBody(&resp).
|
||||||
|
StatusCodeToError().
|
||||||
|
DoWithoutResponse(s.T().Context())
|
||||||
|
errResp := httpcli.ErrorResponse{}
|
||||||
|
require.ErrorAs(err, &errResp)
|
||||||
|
require.EqualValues(http.StatusUnauthorized, errResp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *HappyPathTestSuite) TestUserAuthorization_SkipAppAuth() { // nolint:funlen
|
||||||
|
test, require := test.New(s.T())
|
||||||
|
config, _, adminCli := s.commonDependencies(test)
|
||||||
|
systemService, systemCli := grpct.NewMock(test)
|
||||||
|
systemService.Mock("system/secure/authenticate", func() entity.AuthenticateResponse {
|
||||||
|
return entity.AuthenticateResponse{
|
||||||
|
Authenticated: false,
|
||||||
|
ErrorReason: "",
|
||||||
|
}
|
||||||
|
}).Mock("system/secure/authorize", func() entity.AuthorizeResponse {
|
||||||
|
return entity.AuthorizeResponse{Authorized: false}
|
||||||
|
})
|
||||||
|
|
||||||
|
userAuthData := fake.It[entity.UserAuthData]()
|
||||||
|
userAuthData.IdentityHeader = "x-" + userAuthData.IdentityHeader
|
||||||
|
|
||||||
|
targetService, targetCli := grpct.NewMock(test)
|
||||||
|
targetService.Mock("endpoint", func(ctx context.Context, authData grpc.AuthData, req request) response {
|
||||||
|
md, ok := metadata.FromIncomingContext(ctx)
|
||||||
|
require.True(ok)
|
||||||
|
require.ElementsMatch([]string{userAuthData.Identity}, md.Get(userAuthData.IdentityHeader))
|
||||||
|
|
||||||
|
return response{Id: req.Id}
|
||||||
|
})
|
||||||
|
|
||||||
|
routerMux := router.New()
|
||||||
|
defaultWrapper := endpoint.DefaultWrapper(
|
||||||
|
test.Logger(),
|
||||||
|
httplog.Noop(),
|
||||||
|
)
|
||||||
|
|
||||||
|
userAuthToken := fake.It[string]()
|
||||||
|
|
||||||
|
routerMux.POST("/test-user-auth/authenticate",
|
||||||
|
defaultWrapper.Endpoint(func(req entity.UserAuthenticateRequest) entity.UserAuthenticateResponse {
|
||||||
|
require.Equal(userAuthToken, req.Token)
|
||||||
|
return entity.UserAuthenticateResponse{
|
||||||
|
Authenticated: true,
|
||||||
|
AuthData: &userAuthData,
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
routerMock := httptest.NewServer(routerMux)
|
||||||
|
targetUrl, err := url.Parse(routerMock.URL)
|
||||||
|
require.NoError(err)
|
||||||
|
rr := lb.NewRoundRobin([]string{targetUrl.Host})
|
||||||
|
|
||||||
|
targetClients := map[string]*client.Client{"target": targetCli}
|
||||||
|
logger, err := log.New(log.WithLevel(log.DebugLevel))
|
||||||
|
require.NoError(err)
|
||||||
|
routes := routes.NewRoutes(logger)
|
||||||
|
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli, nil, rr, cache.New())
|
||||||
|
|
||||||
|
locations := []conf.Location{{
|
||||||
|
SkipAuth: false,
|
||||||
|
PathPrefix: "/api",
|
||||||
|
Protocol: "grpc",
|
||||||
|
TargetModule: "target",
|
||||||
|
}}
|
||||||
|
config.CustomAuth = conf.CustomAuth{
|
||||||
|
TokenProviders: []conf.TokenProvider{
|
||||||
|
{
|
||||||
|
Name: "test_provider",
|
||||||
|
Type: conf.HeaderTokenProviderType,
|
||||||
|
HeaderProvider: &conf.HeaderTokenProvider{
|
||||||
|
HeaderName: "test-token-header",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
UserAuthSettings: []conf.UserAuthSetting{
|
||||||
|
{
|
||||||
|
ModuleNameList: []string{"target"},
|
||||||
|
TokenProviders: []string{"test_provider"},
|
||||||
|
AuthenticateEndpoint: "test-user-auth/authenticate",
|
||||||
|
SkipAppAuth: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ModuleNameList: []string{"target2"},
|
||||||
|
TokenProviders: []string{"test_provider"},
|
||||||
|
AuthenticateEndpoint: "test-user-auth/authenticate",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
handler, err := locator.Handler(config, locations)
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
err = routes.ReceiveRoutes(context.Background(), cluster.RoutingConfig{{
|
||||||
|
ModuleName: "target",
|
||||||
|
Endpoints: []cluster.EndpointDescriptor{{
|
||||||
|
Path: "endpoint",
|
||||||
|
Inner: true,
|
||||||
|
UserAuthRequired: true,
|
||||||
|
}}},
|
||||||
|
{
|
||||||
|
ModuleName: "target2",
|
||||||
|
Endpoints: []cluster.EndpointDescriptor{{
|
||||||
|
Path: "failed_endpoint",
|
||||||
|
Inner: true,
|
||||||
|
UserAuthRequired: true,
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
srv := httptest.NewServer(handler)
|
||||||
|
cli := httpcli.New()
|
||||||
|
req := request{Id: uuid.New().String()}
|
||||||
|
resp := response{}
|
||||||
|
err = cli.Post(srv.URL+"/api/endpoint").
|
||||||
|
Header("x-application-token", "token").
|
||||||
|
Header("test-token-header", userAuthToken).
|
||||||
|
Header("x-auth-admin", "mock-token").
|
||||||
|
JsonRequestBody(req).
|
||||||
|
JsonResponseBody(&resp).
|
||||||
|
StatusCodeToError().
|
||||||
|
DoWithoutResponse(s.T().Context())
|
||||||
|
require.NoError(err)
|
||||||
|
require.EqualValues(req.Id, resp.Id)
|
||||||
|
|
||||||
|
err = cli.Post(srv.URL+"/api/failed_endpoint").
|
||||||
|
Header("x-application-token", "token").
|
||||||
|
Header("test-token-header", userAuthToken).
|
||||||
|
Header("x-auth-admin", "mock-token").
|
||||||
|
JsonRequestBody(req).
|
||||||
|
JsonResponseBody(&resp).
|
||||||
|
StatusCodeToError().
|
||||||
|
DoWithoutResponse(s.T().Context())
|
||||||
|
errResp := httpcli.ErrorResponse{}
|
||||||
|
require.ErrorAs(err, &errResp)
|
||||||
|
require.EqualValues(http.StatusUnauthorized, errResp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nolint:ireturn
|
||||||
|
func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, *client.Client, *client.Client) {
|
||||||
config := conf.Remote{
|
config := conf.Remote{
|
||||||
Redis: &conf.Redis{Address: redisCli.address},
|
Http: conf.Http{MaxRequestBodySizeInMb: 1, ProxyTimeoutInSec: 15},
|
||||||
Http: conf.Http{MaxRequestBodySizeInMb: 1, ProxyTimeoutInSec: 15},
|
|
||||||
Logging: conf.Logging{LogLevel: log.DebugLevel, RequestLogEnable: true, BodyLogEnable: true,
|
Logging: conf.Logging{LogLevel: log.DebugLevel, RequestLogEnable: true, BodyLogEnable: true,
|
||||||
SkipBodyLoggingEndpointPrefixes: []string{"endpoint"}},
|
SkipBodyLoggingEndpointPrefixes: []string{"endpoint"}},
|
||||||
Caching: conf.Caching{AuthorizationDataInSec: 1, AuthenticationDataInSec: 1},
|
Caching: conf.Caching{AuthorizationDataInSec: 1, AuthenticationDataInSec: 1},
|
||||||
DailyLimits: []conf.DailyLimit{{ApplicationId: 1, RequestsPerDay: 100}},
|
DailyLimits: []conf.DailyLimit{{ApplicationId: 1, RequestsPerDay: 100}},
|
||||||
Throttling: []conf.Throttling{{ApplicationId: 1, RequestsPerSeconds: 100}},
|
Throttling: []conf.Throttling{{ApplicationId: 1, RequestsPerSeconds: 100}},
|
||||||
|
EnableClientRequestIdForwarding: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
systemService, systemCli := grpct.NewMock(test)
|
systemService, systemCli := grpct.NewMock(test)
|
||||||
systemService.Mock("system/secure/authenticate", func() domain.AuthenticateResponse {
|
systemService.Mock("system/secure/authenticate", func() entity.AuthenticateResponse {
|
||||||
return domain.AuthenticateResponse{
|
return entity.AuthenticateResponse{
|
||||||
Authenticated: true,
|
Authenticated: true,
|
||||||
ErrorReason: "",
|
ErrorReason: "",
|
||||||
AuthData: &domain.AuthData{
|
AuthData: &entity.AppAuthData{
|
||||||
SystemId: 1,
|
SystemId: 1,
|
||||||
DomainId: 2,
|
DomainId: 2,
|
||||||
ServiceId: 3,
|
ServiceId: 3,
|
||||||
ApplicationId: 4,
|
ApplicationId: 4,
|
||||||
|
AppName: "test",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}).Mock("system/secure/authorize", func() domain.AuthorizeResponse {
|
}).Mock("system/secure/authorize", func() entity.AuthorizeResponse {
|
||||||
return domain.AuthorizeResponse{Authorized: true}
|
return entity.AuthorizeResponse{Authorized: true}
|
||||||
})
|
})
|
||||||
|
|
||||||
adminService, adminCli := grpct.NewMock(test)
|
adminService, adminCli := grpct.NewMock(test)
|
||||||
adminService.Mock("admin/secure/authenticate", func(req domain.AdminAuthorizeRequest) domain.AdminAuthenticateResponse {
|
adminService.Mock("admin/secure/authenticate", func(req entity.AdminAuthorizeRequest) entity.AdminAuthenticateResponse {
|
||||||
return domain.AdminAuthenticateResponse{
|
return entity.AdminAuthenticateResponse{
|
||||||
Authenticated: true,
|
Authenticated: true,
|
||||||
ErrorReason: "",
|
ErrorReason: "",
|
||||||
AdminId: 1,
|
AdminId: 1,
|
||||||
}
|
}
|
||||||
}).Mock("admin/secure/authorize", func(req domain.AdminAuthorizeRequest) domain.AdminAuthorizeResponse {
|
}).Mock("admin/secure/authorize", func(req entity.AdminAuthorizeRequest) entity.AdminAuthorizeResponse {
|
||||||
if req.Permission == "ok_permission" {
|
if req.Permission == "ok_permission" {
|
||||||
return domain.AdminAuthorizeResponse{Authorized: true}
|
return entity.AdminAuthorizeResponse{Authorized: true}
|
||||||
}
|
}
|
||||||
return domain.AdminAuthorizeResponse{Authorized: false}
|
return entity.AdminAuthorizeResponse{Authorized: false}
|
||||||
})
|
})
|
||||||
|
|
||||||
return config, redisCli, systemCli, adminCli
|
return config, systemCli, adminCli
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHappyPathTestSuite(t *testing.T) {
|
func TestHappyPathTestSuite(t *testing.T) {
|
||||||
@@ -344,6 +644,8 @@ func assertHeaders(require *require.Assertions, requestId string, ctx context.Co
|
|||||||
require.EqualValues(2, domainId)
|
require.EqualValues(2, domainId)
|
||||||
require.EqualValues(3, serviceId)
|
require.EqualValues(3, serviceId)
|
||||||
require.EqualValues(4, applicationId)
|
require.EqualValues(4, applicationId)
|
||||||
|
expectedAppName := base64.StdEncoding.EncodeToString([]byte("test"))
|
||||||
|
require.EqualValues(expectedAppName, headers.Get("x-application-name"))
|
||||||
|
|
||||||
adminId, err := strconv.Atoi(headers.Get("x-admin-id"))
|
adminId, err := strconv.Atoi(headers.Get("x-admin-id"))
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|||||||
+19
-18
@@ -5,17 +5,19 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
"isp-gate-service/assembly"
|
"isp-gate-service/assembly"
|
||||||
"isp-gate-service/conf"
|
"isp-gate-service/conf"
|
||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/entity"
|
||||||
"isp-gate-service/routes"
|
"isp-gate-service/routes"
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/grpc"
|
"github.com/redis/go-redis/v9"
|
||||||
"github.com/integration-system/isp-kit/grpc/client"
|
|
||||||
endpoint2 "github.com/integration-system/isp-kit/grpc/endpoint"
|
"github.com/txix-open/isp-kit/grpc"
|
||||||
"github.com/integration-system/isp-kit/grpc/isp"
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
"github.com/integration-system/isp-kit/log"
|
endpoint2 "github.com/txix-open/isp-kit/grpc/endpoint"
|
||||||
|
"github.com/txix-open/isp-kit/grpc/isp"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type request struct {
|
type request struct {
|
||||||
@@ -46,7 +48,6 @@ func main() {
|
|||||||
})
|
})
|
||||||
}()
|
}()
|
||||||
config := conf.Remote{
|
config := conf.Remote{
|
||||||
Redis: &conf.Redis{Address: "localhost:6379"},
|
|
||||||
Http: conf.Http{MaxRequestBodySizeInMb: 1, ProxyTimeoutInSec: 15},
|
Http: conf.Http{MaxRequestBodySizeInMb: 1, ProxyTimeoutInSec: 15},
|
||||||
Logging: conf.Logging{LogLevel: log.DebugLevel, RequestLogEnable: true, BodyLogEnable: true},
|
Logging: conf.Logging{LogLevel: log.DebugLevel, RequestLogEnable: true, BodyLogEnable: true},
|
||||||
Caching: conf.Caching{AuthorizationDataInSec: 15, AuthenticationDataInSec: 15},
|
Caching: conf.Caching{AuthorizationDataInSec: 15, AuthenticationDataInSec: 15},
|
||||||
@@ -55,19 +56,19 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
systemService, systemCli, _ := NewMock(logger)
|
systemService, systemCli, _ := NewMock(logger)
|
||||||
systemService.Mock("system/secure/authenticate", func() domain.AuthenticateResponse {
|
systemService.Mock("system/secure/authenticate", func() entity.AuthenticateResponse {
|
||||||
return domain.AuthenticateResponse{
|
return entity.AuthenticateResponse{
|
||||||
Authenticated: true,
|
Authenticated: true,
|
||||||
ErrorReason: "",
|
ErrorReason: "",
|
||||||
AuthData: &domain.AuthData{
|
AuthData: &entity.AppAuthData{
|
||||||
SystemId: 1,
|
SystemId: 1,
|
||||||
DomainId: 1,
|
DomainId: 1,
|
||||||
ServiceId: 1,
|
ServiceId: 1,
|
||||||
ApplicationId: 1,
|
ApplicationId: 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}).Mock("system/secure/authorize", func() domain.AuthorizeResponse {
|
}).Mock("system/secure/authorize", func() entity.AuthorizeResponse {
|
||||||
return domain.AuthorizeResponse{Authorized: true}
|
return entity.AuthorizeResponse{Authorized: true}
|
||||||
})
|
})
|
||||||
|
|
||||||
adminService, _, adminCli := NewMock(logger)
|
adminService, _, adminCli := NewMock(logger)
|
||||||
@@ -85,14 +86,14 @@ func main() {
|
|||||||
})
|
})
|
||||||
targetClients := map[string]*client.Client{"target": targetCli}
|
targetClients := map[string]*client.Client{"target": targetCli}
|
||||||
logger, _ = log.New(log.WithLevel(log.DebugLevel))
|
logger, _ = log.New(log.WithLevel(log.DebugLevel))
|
||||||
locator := assembly.NewLocator(logger, targetClients, nil, routes.NewRoutes(), systemCli, adminCli)
|
locator := assembly.NewLocator(logger, targetClients, nil, routes.NewRoutes(logger), systemCli, adminCli, nil, nil, nil)
|
||||||
locations := []conf.Location{{
|
locations := []conf.Location{{
|
||||||
SkipAuth: false,
|
SkipAuth: false,
|
||||||
PathPrefix: "/api",
|
PathPrefix: "/api",
|
||||||
Protocol: "grpc",
|
Protocol: "grpc",
|
||||||
TargetModule: "target",
|
TargetModule: "target",
|
||||||
}}
|
}}
|
||||||
handler, _ := locator.Handler(config, locations, redisCli)
|
handler, _ := locator.Handler(config, locations)
|
||||||
|
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
Addr: "localhost:8000",
|
Addr: "localhost:8000",
|
||||||
@@ -102,7 +103,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestServer(service isp.BackendServiceServer) (*grpc.Server, *client.Client, *client.Client) {
|
func TestServer(service isp.BackendServiceServer) (*grpc.Server, *client.Client, *client.Client) {
|
||||||
listener, _ := net.Listen("tcp", "127.0.0.1:")
|
listener, _ := net.Listen("tcp", "127.0.0.1:") // nolint:noctx
|
||||||
srv := grpc.NewServer()
|
srv := grpc.NewServer()
|
||||||
sysCli, _ := client.Default()
|
sysCli, _ := client.Default()
|
||||||
adminCli, _ := client.Default()
|
adminCli, _ := client.Default()
|
||||||
@@ -119,7 +120,7 @@ func TestServer(service isp.BackendServiceServer) (*grpc.Server, *client.Client,
|
|||||||
type MockServer struct {
|
type MockServer struct {
|
||||||
srv *grpc.Server
|
srv *grpc.Server
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
mockEndpoints map[string]interface{}
|
mockEndpoints map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMock(logger log.Logger) (*MockServer, *client.Client, *client.Client) {
|
func NewMock(logger log.Logger) (*MockServer, *client.Client, *client.Client) {
|
||||||
@@ -127,11 +128,11 @@ func NewMock(logger log.Logger) (*MockServer, *client.Client, *client.Client) {
|
|||||||
return &MockServer{
|
return &MockServer{
|
||||||
srv: srv,
|
srv: srv,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
mockEndpoints: make(map[string]interface{}),
|
mockEndpoints: make(map[string]any),
|
||||||
}, syscli, admincli
|
}, syscli, admincli
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockServer) Mock(endpoint string, handler interface{}) *MockServer {
|
func (m *MockServer) Mock(endpoint string, handler any) *MockServer {
|
||||||
m.mockEndpoints[endpoint] = handler
|
m.mockEndpoints[endpoint] = handler
|
||||||
wrapper := endpoint2.DefaultWrapper(m.logger)
|
wrapper := endpoint2.DefaultWrapper(m.logger)
|
||||||
muxer := grpc.NewMux()
|
muxer := grpc.NewMux()
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
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,25 +0,0 @@
|
|||||||
package tests
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/integration-system/isp-kit/test"
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Redis struct {
|
|
||||||
address string
|
|
||||||
redis.UniversalClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRedis(test *test.Test) Redis {
|
|
||||||
redisHost := test.Config().Optional().String("REDIS_HOST", "localhost")
|
|
||||||
redisPort := test.Config().Optional().String("REDIS_PORT", "6379")
|
|
||||||
addr := fmt.Sprintf("%s:%s", redisHost, redisPort)
|
|
||||||
cli := redis.NewClient(&redis.Options{Addr: addr})
|
|
||||||
return Redis{UniversalClient: cli, address: addr}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Redis) Address() string {
|
|
||||||
return r.address
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
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))
|
||||||
|
}
|
||||||
@@ -0,0 +1,275 @@
|
|||||||
|
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