jiriOndrusek-agent commented on PR #642:
URL: 
https://github.com/apache/camel-quarkus-examples/pull/642#issuecomment-7040003328

   The branch was rebuilt (force-pushed); the SHAs below are the new ones.
   
   **1. Unauthenticated callers force DB writes**
   Fixed in `fbbd8e9f`. Requests without a valid token (401) and throttled 
requests (429) no longer append to the chain. They only increment 
`gateway_rejected_requests_total{status}`, from a synchronous observer with no 
DB access. Only authenticated 403s are still audited (async, and the README 
says a record can be lost on a crash). `/api/audit/verify` no longer takes the 
head lock: it reads the head, then checks rows `seq <= head` in pages of 1000. 
Rows up to the head are committed and append-only, so appends continue 
meanwhile. Tests: `SecurityTest.anonymousRequestsAreNotAudited` (50 anonymous 
requests leave no rows), a 429 check in `burstFromOnePartnerIsThrottled`, 
`AuditChainTest.chainCanBeVerifiedPageByPage`, and 
`AuditVerifyTest.appendDuringVerifyKeepsTheChainValid` (a record appended after 
the head was read is not checked).
   
   **2. Append-only trigger vs. Flyway user**
   Fixed in `30f3341a`. Flyway runs as the schema owner 
(`quarkus.flyway.username/password`). The application connects as 
`gateway_app`, and the migration grants it only `SELECT, INSERT` on 
`audit_event` and `partner_order` and `SELECT, UPDATE` on `audit_chain_head`. 
Dev/test create the role through a `%dev,test` Flyway `init-sql`. The README 
shows the production env vars. A plain `%prod` property would not fail on an 
unset value, so `V1.0.0__gateway_schema.sql` starts with a guard that raises an 
error when `current_user = 'gateway_app'`: a missing `QUARKUS_FLYWAY_*` fails 
the startup. The README states PostgreSQL 16+ and this failure, and notes that 
with `migrate-at-start` the process holds the owner password (a separate 
migration step avoids that). Test: 
`AuditImmutabilityTest.applicationRoleCannotRemoveTheTrigger` (`DISABLE 
TRIGGER` / `DROP TRIGGER` -> `must be owner`).
   
   **3. Idempotency**
   Fixed in `9e56a64b`. `JdbcMessageIdRepository`, `CAMEL_MESSAGEPROCESSED` and 
`camel-quarkus-sql` are removed. `OrderService.submit` does `INSERT ... ON 
CONFLICT (partner_id, idempotency_key) DO NOTHING` in the order's transaction. 
A concurrent duplicate waits for the first commit and then replays it, so the 
409 / stuck-key case is gone. A retry with another order gets 422. There is no 
request hash: the order row already holds the whole request (`sku`, 
`quantity`), so the retry is compared to it. Test: 
`OrderApiTest.retryWithAnotherOrderIsRejected`. The concurrency test now 
expects only 202/200.
   
   **4. Header allow-list does not pin the source**
   Fixed in `1e5e21b2`. `POST /api/orders` rejects any query string with 400, 
so `Idempotency-Key` can only come from the HTTP header. `/api/audit` reads 
`actor`/`action`/`limit` from `CamelHttpQuery` only, so same-named HTTP headers 
are ignored. A repeated parameter such as `?actor=a&actor=b` is rejected with 
400 instead of becoming a list. On `POST`, the throttle runs before the 415 and 
the query-string 400 checks, so such requests get 429 once the limit is hit. 
The route comment and README say that `removeHeaders` does not fix where a 
value comes from. Tests: `OrderApiTest.idempotencyKeyInTheQueryIsRejected`, 
`AuditTrailTest.filtersComeFromTheQueryOnly`, 
`AuditTrailTest.invalidQueryIsRejected` (`actor=a&actor=b`, `limit=1&limit=2`), 
`OrderApiTest.burstFromOnePartnerIsThrottled` (wildcard content type and query 
string get 429).
   
   **5. Role and tenant sources**
   Fixed in `707d2f4c`. `quarkus.oidc.roles.role-claim-path=realm_access/roles` 
is now set. The README says `partner_id` must come from an admin-controlled 
mapper, and that any realm client that can get role `partner` plus audience 
`gateway-api` is trusted. Test: the new realm client `groups-claim-client` has 
`groups: ["auditor"]` and no role. 
`SecurityTest.rolesAreNotReadFromTheGroupsClaim` expects 403 (it was 200 
before).
   
   **6. `AGENTS.md`**
   Reworded in `a721b18f`: "When an example needs authentication, RBAC, ..., 
see `secure-partner-gateway` ... Match the security of an example to its scope, 
and copy only the parts it needs." The "other examples need not cover them" 
wording is gone. "Serves as a reference" is also gone from the description and 
`examples.json`, and the README "Reuse" paragraph got the same rewording. 
Whether `AGENTS.md` should point at this example at all is your call. Happy to 
drop the section.
   
   **7. `%00` gives 500**
   Fixed in `23421141`. `{id}` must be a UUID, `actor` must have no control 
characters, and `action` must match `[A-Z_]{1,32}`. Anything else gets 400 
problem+json, with no stack trace. Tests: 
`OrderApiTest.invalidOrderIdIsRejected`, and 
`AuditTrailTest.invalidQueryIsRejected` now also covers `actor=a%00b` and 
`action=a%00b`.
   
   **8. Untested README claims**
   Removed in `c9ee8ac9`. The checklist now only says that the `prod` profile 
sets `camel.main.profile=prod`, with no claim that Camel refuses insecure 
settings. I dropped the `OidcProvider` log override and its README line. In 
Quarkus 4.0.0.CR1, `OidcProvider` logs only the jose4j error detail (claim 
values such as `iss`/`aud`/`exp`), not the token, so hiding all its warnings 
was not justified.
   
   **9. `TEST-GUIDE.adoc`**
   Fixed in `51306565`. The file is removed, and a short "Try it" section in 
the README covers tokens, order/retry/422, tenant isolation, audit query and 
verify. The tests cover the rest. I checked the commands against dev mode.
   
   _Generated with [Claude Code](https://claude.com/claude-code) on behalf of 
@JiriOndrusek_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to