diff options
| author | Pjotr Prins <pjotr.public01@thebird.nl> | 2026-10-05 06:50:30 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-10-05 06:50:30 +0000 |
| commit | 693e7ee89f8618c1abbf8af5c0db23b071700803 (patch) | |
| tree | e5db71e3f7e8af7342be1004aac9d5dfd0e1db2a /docs | |
| parent | adc173c1f3c78da487827122262573e753284260 (diff) | |
| download | genenetwork4-693e7ee89f8618c1abbf8af5c0db23b071700803.tar.gz | |
Add POST /dev/token, a dev-only gn-auth token issuer
Calls gn-auth's own password grant (POST /auth/token) for gn-auth's well-known development user and returns the result, so local testing no longer needs a manual curl/gn-auth round trip of its own. Only ever registered -- not just rejected at request time, genuinely absent from the router and from /openapi.json -- when two new Config fields are both set: dev_mode (GENENETWORK4_DEV_MODE) and a loopback bind (GENENETWORK4_BIND, also new). Both are config, not something genenetwork4 infers from its actual network exposure, by design: dev mode alone, or a loopback bind alone, each leave it disabled, and the check (Config::dev_token_enabled) is a plain function so the condition itself has direct unit test coverage rather than only being exercised indirectly through the route. src/main.rs now binds to config.bind instead of a hardcoded "0.0.0.0", via a proper SocketAddr rather than string formatting -- the latter would mishandle an IPv6 bind address like "::1" (needs brackets). GN_AUTH_DEV_CLIENT_ID/_CLIENT_SECRET/_USERNAME/_PASSWORD default to gn-auth's own published dev fixtures (flask init-dev-clients, gn_auth/wsgi.py), so this works unconfigured against an unmodified dev gn-auth instance -- confirmed live, including using the returned token against a real gated endpoint (/traits/BXD/10001), not just checking the token response's shape. tests/dev_token.rs covers all four combinations of the two settings in one sequential test function (mutating the same two env vars from more than one #[tokio::test] in a file would race, since they run concurrently by default) plus the /openapi.json visibility check. test/python/test_dev_token.py mirrors this using separate test classes instead, which is safe here since each spawns its own server subprocess with its own environment (ServerTestCase gains EXTRA_ENV for this). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XDDpXvZBQat9uSgDeEMJ8d
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/gn-auth.md | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/gn-auth.md b/docs/gn-auth.md index f4b8410..b07c2a9 100644 --- a/docs/gn-auth.md +++ b/docs/gn-auth.md @@ -305,6 +305,25 @@ branch specifically wasn't exercised against real data -- only against the already-proven ProbeSet branch and gn-auth's own "unlinked dataset" 404-to-deny behavior, which this new branch calls unchanged. +### Getting a token for local testing: `POST /dev/token` + +Every live test in this repo (`tests/*.rs`, `test/python/test_*.py`) +needs a real bearer token, obtained by hand so far (e.g. +`test-token2.txt` in the setup notes). genenetwork4 can hand one out +itself now: `POST /dev/token` (`src/routes/dev.rs`) calls gn-auth's own +password grant for gn-auth's well-known development user +(`test@development.user`, from `flask init-dev-clients`/ +`gn_auth/wsgi.py`) and returns the result. See the README's +"Development mode" section for how to enable it +(`GENENETWORK4_DEV_MODE=true` and `GENENETWORK4_BIND=127.0.0.1`, +required together) and gn-auth's own `AUTHLIB_INSECURE_TRANSPORT` +requirement for accepting the grant over plain HTTP at all. + +This doesn't change anything about how genenetwork4 verifies or +authorizes tokens (src/auth.rs) -- it is purely a convenience for +obtaining one of the tokens that mechanism already accepts, scoped to +local development by two independent config checks rather than one. + ### Found wrong in gn-auth while building this Four bugs in gn-auth itself blocked this integration before they were |
