A release job gets a ten-minute SSH certificate for one command (AHT-231) #208
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
queue
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
romaine-life/auth!208
Loading…
Reference in a new issue
No description provided.
Delete branch "forgejo-release-cert"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Step 1 of the certificate delivery plan on AHT-231: a release's delivery job holds no stored key. It exchanges its own Forgejo Actions job token for a ten-minute SSH certificate that can run one command.
What it does
POST /api/auth/exchange/ssh-cert/forgejo(src/forgejo-actions-auth.ts). Bearer is the job's OIDC token; body is{public_key, purpose}. The token is verified the way the k8s exchanges verify theirs (RS256, the issuer's published keys through discovery, issuerhttps://forgejo.romaine.life/api/actions, audiencehttps://auth.romaine.life/ssh-cert, unexpired), then a claim rule must accept it.at-update-releasegives principalforgejo-release:at-updatewith force-command"C:\Program Files\at-home\at-update\current\at-update.exe" --task-run;treadmill-wakegivesforgejo-release:nas-wakewithsudo /usr/syno/sbin/synonet --wake E8:FF:1E:D8:9B:FB eth0. 600 seconds, key idforgejo:<repository>:<run_id>, no extensions.public_keymust bessh-ed25519and not a certificate.forgejoActions.sshCertRulesink8s/values.yaml, passed to the pod asFORGEJO_SSH_CERT_RULES. As shipped:release/ci.ymlin anynelsong6/*orromaine-life/*repository onrefs/heads/mainorrefs/heads/master, started bypushorworkflow_dispatch; and pipeline-templates'deliver.ymldispatched on itsmain. No matching row refuses; an empty or unreadable table refuses every job; a pull request event is refused even if a row lists it.src/ssh-cert.ts:signUserCerttakes an optionalforceCommand, written as theforce-commandcritical option. Without it the certificate is byte-for-byte what it was (the existing tests still assert empty critical options).client/ssh-host.go):romaine-auth ssh-hostaccepts theforgejo-release:at-updateprincipals line only ascommand="<that command>",restrict forgejo-release:at-update(client.ReleasePrincipalLine), in either option order, at most once, and refuses it bare, with another command, with an option added back, or for any otherforgejo-release:principal. The CLI now reads the principals file by line so that line stays whole.device:lines are read and checked exactly as before, and--user-scopestill refuses the release line.auth_ssh_cert_forgejo_exchange_total{result}; log linesforgejo ssh certificate issuedandforgejo ssh certificate refused. README section "A release job's certificate".What it doesn't do
POST /api/auth/exchange/ssh-cert(glimmung's), its allowlist, or the machine certificates.Not yet confirmed, and how the logs settle it
Which workflow a called workflow's token names in
workflowandworkflow_refhas not been read from a real token. The release suite reaches the PCs through pipeline-templates'deliver.ymlas a called workflow; the shipped rule assumes that job's token names the caller'srelease/ci.yml(existing OpenBao roles bindworkflowto values of that form, such astofu/ci.yml). If the token namesdeliver.ymlinstead, the request is refused with 403denied_claimsand nothing is issued. Every refusal of a verified token writes oneforgejo ssh certificate refusedline carryingrepository,ref,workflow,workflow_ref,event_nameandrun_idas the token had them, and never the token, so the first real delivery either gets its certificate or shows the exact values to put in the table.workflow_refis not bound by the shipped rows for the same reason; a row can bind it withworkflowRefsonce its form is known.Also not confirmed: that auth's pod reaches
forgejo.romaine.life(a failure is 503error_issuer_unreachable, logged, and retried on the next request rather than kept until a restart), and the job token's lifetime.Tests
src/forgejo-actions-auth.test.ts: tokens signed with a locally generated RS256 key behind a local JWKS, against the rules read fromk8s/values.yaml. Accepted: release on main/master by push/dispatch, pipeline-templates' dispatch. Refused: wrong repository, ref, workflow, event, pull request events, missing or non-text claims, bad run id; wrong audience, issuer, signing key, expired, HS256; unknown purpose; a non-ed25519 key or a certificate as the key. Each purpose's certificate decodes to its one principal, theforce-commandcritical option alone, no extensions, 600 seconds, and verifies under the CA;ssh-keygen -Lreads the same.client/ssh-host_test.go: the release line accepted only with its command andrestrict; refused bare and in eleven other forms;device:lines unchanged.🤖 Generated with Claude Code