diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-09 12:07:04 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-09 12:07:04 +0000 |
| commit | 4528917f5c709071293e6b6670456963897a7040 (patch) | |
| tree | 737bf08b69c34e782a4bcb948fba270d01dfdd31 /test/python/test_mapping_methods.py | |
| parent | de07aabd384d3adabf2b095b0a76a09efd81de45 (diff) | |
| download | genenetwork4-4528917f5c709071293e6b6670456963897a7040.tar.gz | |
api: name the caller on the response, so the log can say who
Answering "is robw using this successfully, and the others?" from the access logs took an hour of inference -- user agents, search terms, which traits were mapped -- because nginx records the address and the subject is only in the token. Two callers can share an address (an agent and a person behind one NAT), one caller can move between addresses (an LLM's egress is a /24), and the answer for a given person was "probably 80.115.1.132". The API now sets `x-gn4-user: <token sub>` on every **authenticated** response, and the `gn4` log format records it as `user=`. The subject is only known inside the handler (the `AuthToken` extractor verifies the token there), so a middleware opens a slot in the request extensions, the extractor fills it, and the header is set on the way out; a request with no valid token gets no header, which is the honest answer and reads as `user=-`. The caller only ever sees an identity it already presented. * src/auth.rs: `USER_HEADER`, `CallerSlot`, and the extractor recording its subject. * src/lib.rs: the `tag_caller` middleware, outermost so the slot exists before any extractor runs. * tests/auth.rs: `an_authenticated_response_names_its_caller` -- the header equals the token's `sub`, and `/version` (no identity) carries none. * etc/nginx-vesuvio.pu.ac.ke.conf (and the deployed copy of it): `user=` in the log format. * README.md, docs/nginx.md (the format, an `awk` one-liner for per-user counts, and the caveat that old and new lines differ in field count), docs/www/operator-checklist.md (`user=-` means no token, not a token that failed late). 281 tests pass; the same four as before do not.
Diffstat (limited to 'test/python/test_mapping_methods.py')
0 files changed, 0 insertions, 0 deletions
