about summary refs log tree commit diff
path: root/test/python/test_envelope.py
diff options
context:
space:
mode:
authorPjotr <wrk@bosa.lan>2026-11-14 13:27:44 +0000
committerPjotr <wrk@bosa.lan>2026-11-14 13:27:44 +0000
commitf64a7084694fc28fc2069e39778a83716c1b858e (patch)
treef2f25b8eff4548a4610f4383cf3bafa45057adfb /test/python/test_envelope.py
parent96c1979e5d4b662e8b4426dc7e9a27a5b7742c67 (diff)
downloadgenenetwork4-f64a7084694fc28fc2069e39778a83716c1b858e.tar.gz
logs: one access line per request, naming the caller
The proxy logs the caller through x-gn4-user, but the process log -- the one an
operator tails while a job runs -- named nobody, so "who started this GEMMA
run" meant going to the nginx log or guessing. genenetwork4 now writes one
compact JSON line per request on stderr:

  {"event":"request","method":"GET","path":"/groups/BXD","status":200,
   "took_ms":10,"request_id":"…","user":"zachs"}

Decisions in it: `user` is absent, not "-", when no token was verified (a dash
is a value a reader can mistake for a user name); the path is logged without
its query string, because a query can carry a credential and has no business
in a log; the token value itself is never logged, only its subject; and the
line carries the `request_id`, so it sits beside the existing `event: error`
lines for 5xx and one grep joins a failure to the request that caused it.
`GN4_ACCESS_LOG=false` turns it off where the proxy's log is the record of
truth.

Verified on a probe instance: with the test token the line says
user "gn4-test-stub", with zachs's token user "zachs", and an unauthenticated
401 has no user field at all.

docs/www/operator-checklist.md claimed "genenetwork4 does not log the token's
sub" -- true until now, which is exactly the kind of sentence that rots; it is
replaced by the line above, what it contains and what it deliberately omits.
README's x-gn4-user paragraph gains the same, next to the identity it already
described.
Diffstat (limited to 'test/python/test_envelope.py')
0 files changed, 0 insertions, 0 deletions