Repository navigation
Mint Medic's gateway token from enable-compose.sh; start the gateway with either credential file missing - #4458
Merged
samarmstrong merged 1 commit intoNov 16, 2026
Conversation
…with either credential file missing (#4429) enable-compose.sh no longer makes viewer_password. Once the backend is up it pipes `python -m core.auth.service_account token` straight into a 0600 medic_gateway_token (chowned to 10002 on Linux before the rename), then recreates medic-gateway. A plain re-run with a token kept mints nothing; --rotate rotates it with the API key; --secrets-only mints nothing and says so. An upgraded site's viewer_password is left in place. Compose mounts the new medic_gateway_token secret. lib.sh's dc and the script create empty 0600 placeholders for a missing token or password file, so the gateway starts with either missing and reads an empty one as absent. Closes #4429 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
samarmstrong
deleted the
factory/4429-compose-enable-compose-sh-mints-122afb5e
branch
November 16, 2026 06:00
samarmstrong
added a commit
that referenced
this pull request
Nov 16, 2026
Resolve docs/medic/enable.md: Compose (#4458) and Helm (this PR) both read with a host-minted token now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4429 (part of #4425).
On Compose,
scripts/medic/enable-compose.shnow gives Medic's gateway an API token. Before, it made a password. The gateway also starts now when either credential file is missing.Script (
scripts/medic/enable-compose.sh)viewer_password.python -m core.auth.service_account token <name>. The output goes straight into a 0600 temp file in the secrets dir.vgl_api_…token. On Linux it is chowned to 10002 and then renamed ontomedic_gateway_token, andmedic-gatewayis recreated.ensure. It refuses (77) once the account has a token, andtokencreates a missing account itself.--rotaterotates the token (the old one works for 24 hours) along withapi_key, and recreates the backend as before.--secrets-onlymints nothing and reports the token step as "still to do". With--rotate, it leaves a.mintmarker so the next full run rotates the token..mintmarker is also written before every mint and cleared only once the new file is in place.tokencommits a rotation before the file is written, so a run cut short there gets re-minted next time instead of keeping a token that dies in 24 hours.viewer_passwordis left in place and is never rotated. The summary lists the token as minted, rotated, kept or still to do, and never prints its value.make_secretnow only makesapi_key, so it is nowmake_api_key.ensure_accountandread_secretare gone.Compose
medic_gateway_tokensecret is mounted onmedic-gateway, next tomedic_viewer_password._dc_medicinscripts/lib.shcreates an empty 0600 placeholder for whichever file is missing; the enable script does the same. Without it, Compose refuses to start the container ("bind source path does not exist"). The gateway treats an empty file as absent.Docs
docs/medic/enable.mdanddocs/upgrading.mdcover the move by re-run, and the re-mint after a restore (deletemedic_gateway_tokenand re-run).CHANGELOG.mdsays the password path is removed no earlier than the release that ends the announced window.Live tests (opt-in, nightly or manual dispatch only)
test_enable_live.py: the canary checks the token instead of the password, and the gateway read must showcredential: token.test_compose_live.py: its stub backend accepts only a password login, so the fixture writes aviewer_passwordto model a site enabled before tokens.Verification
Ran. Every check below used the repo's Compose stack as shipped, under the factory slot (base compose file plus the Medic overlay, real backend and Postgres). The "15 GETs" are the gateway's whole outbound allowlist, requested through
medic-gateway-out:8471from inside themediccontainer. Each check also read/_gw/status.medic_gateway_token minted.viewer_passwordwas a 0-byte placeholder; the token file was 52 bytes, owned by 10002, mode 0600./api/v1/agent-runsreturned 403. Viewer lacksai_chat.use, which predates this PR (the same 403 is noted on Mint Medic's gateway a token from the host; end its password on first use #4443).credential: token,state: ok.kept. The token file's inode and mtime were unchanged, the database still had one credential, and no container was recreated.--rotate, probing every 2 s throughoutrotated, and the old credential's expiry moved to +24 h.api_key, as before this change.credential: token.main's script,lib.shand compose file (credential: password), then switched back to this branch's files.docker compose … up medic-gatewayfailed withbind source path does not exist: …/medic_gateway_token.ensure_container(whatstart.shcalls), the placeholder was created, the gateway started, and it kept reading withcredential: password.minted, plusviewer_password left in place…. Thencredential: token.users.password_hashwas NULL after the gateway's first token read, and a login with the old password returned 401.ensure_containereach time)credential: token.credential: none,no_credential; the auth'd routes returned 502 and the unauthenticated ones 200 or 404.Further checks:
rotated).--secrets-only --rotateprinted "still to do" and left.mint; the next plain run rotated the token and cleared it..mintand no temp file, and the next plain run re-minted.--secrets-onlyon a fresh dir created both placeholders.vgl_api_.bash -npasses on both scripts, andpy_compileon the two tests.A subagent reviewed the diff. Fixed:
.mintmarker before minting, plus an EXIT trap for the temp file, fix it.--secrets-onlyleft no placeholders for the printeddocker composecommand.ensureparagraph inenable.md.Did not run
./start.shitself. It would also start a host-run backend on 6987, which the containerised backend holds. I ran the function it uses to start containers (ensure_container→dc) instead.tests/medic_compose/*_live.py). They are manual-dispatch/nightly and build their own stack; I updated them but didn't run them.Blocked by the machine
.env. Compose needsJWT_SECRET_KEY, so I copiedenv.exampleto.envwith a random secret and deleted it afterwards.shellcheckisn't installed.🤖 Generated with Claude Code