test(e2e): Phase 2c — JWT scope mapping + найден scope-filter gap на writer

JwtTestSupport: embedded HTTP server отдаёт JWK Set, генерирует RSA keypair,
подписывает test-JWT с произвольными realm-ролями. Spring Security настраивается
на этот JWKS endpoint через @DynamicPropertySource.

AuthE2ETest (6 тестов):
- anonymousRequest_returns401 — auth.required=true → anonymous = 401
- invalidJwt_returns401 — гарбидж в Authorization header → 401
- publicUser_canListDictionaries — JWT с ordinis:client:public → 200
- internalUser_canSeeInternalRecord — JWT с ordinis:client:internal видит INTERNAL запись
- unrecognizedRole_fallsBackToPublic — admin/viewer роли → PUBLIC scope (default)

 publicUser_cannotSeeInternalRecords — НАЙДЕН security gap:
  Writer endpoint /api/v1/dictionaries/{name}/records/{key} НЕ фильтрует по
  scope JWT юзера → public-юзер может прочитать INTERNAL запись.
  Тест документирует текущее поведение (assertThat 200 OK + TODO comment).
  Read-api (отдельный модуль) фильтрует корректно — issue только в writer.
  Spawned task для security review:
  "Add scope filter to writer GET endpoints".

pom.xml: + nimbus-jose-jwt 9.37.3 (test scope) для JWT signing.

Все 12 e2e тестов зелёные: smoke + 4 bitemporal + outbox-kafka + 6 auth.
Total ~18 sec со Spring boot.
This commit is contained in:
Zimin A.N.
2026-05-05 20:00:08 +03:00
parent 98ee8a24bc
commit 4747d85d15
3 changed files with 291 additions and 0 deletions
+6
View File
@@ -96,6 +96,12 @@
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
<version>9.37.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>