From 69aac61b0c5b2d8a4f909de6a6d6af8d6ee293a3 Mon Sep 17 00:00:00 2001 From: Pjotr Date: Thu, 8 Oct 2026 14:57:35 +0000 Subject: * src/routes/dev.rs: POST /get-test-token answers local callers only, not tied to dev mode. The endpoint no longer depends on GENENETWORK4_DEV_MODE or on the bind address. It decides per request whether to answer. * src/routes/dev.rs (get_test_token): answers a caller only when the TCP peer (axum ConnectInfo) is in 127.0.x.x (or ::1, or an IPv4-mapped 127.x) and the request carries no X-Forwarded-For, Forwarded or X-Real-IP header (a reverse proxy on the same host would otherwise make every client look local). Anything else, including an unknown peer, is a 403. Local is never established from a header. * src/main.rs: serve with into_make_service_with_connect_info, which provides the peer address. * src/config.rs: remove dev_mode, GENENETWORK4_DEV_MODE and dev_token_enabled(). Add GENENETWORK4_TEST_TOKEN (on by default); when it is not a clearly affirmative value (true/1/yes/on) the route is not registered: a 404, absent from /openapi.json. It fails closed, so a typo ("flase") turns the endpoint off. * src/lib.rs: register the route unless that switch is off. * tests: tests/get_test_token.rs rewritten (remote, unknown and proxied peers refused; 127.x and ::1 answered; always documented by default); tests/get_test_token_off.rs for the switch (own process: it sets an environment variable); common::post_from supplies a peer address to the in-process requests. Python: test_get_test_token.py rewritten, TOKEN_ENV is now empty (no setting needed). * README.md, docs/gn-auth.md, docs/SKILL.md, RELEASE_NOTES.md: document the check, the switch, and "Behind nginx or in a container" (a bridge container sees the gateway as the peer; a host-network container behind nginx sees 127.0.0.1, so block the path in nginx, set X-Forwarded-For, or switch the endpoint off). Co-Authored-By: Claude Sonnet 5.5 --- test/python/server_test_case.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/python/server_test_case.py') diff --git a/test/python/server_test_case.py b/test/python/server_test_case.py index c400661..7561792 100644 --- a/test/python/server_test_case.py +++ b/test/python/server_test_case.py @@ -138,7 +138,7 @@ class ServerTestCase(unittest.TestCase): """Spawns the genenetwork4 binary for the duration of the test class. Subclasses that need the server started with extra/overridden - environment variables (e.g. GENENETWORK4_DEV_MODE) can set EXTRA_ENV. + environment variables (e.g. GN3_URL) can set EXTRA_ENV. """ EXTRA_ENV = {} -- cgit 1.4.1