feat: add ticket renewal and keytab-based minting/bootstrap - #2
Merged
Merged
Conversation
Three new capabilities alongside the existing password-based /v1/mint: - POST /v1/renew: kinit -R on a ccache this service minted earlier. No credential involved at all, so it never touches the rate limiter; capped at the ticket's own renew_until. - POST /v1/mint now also accepts keytab_b64 as an alternative to password (kinit -k -t), exactly one of the two required. - POST /v1/keytab: bootstraps a fresh keytab from a password via CERN's own cern-get-keytab (msktutil-backed). Never persists the keytab -- the caller is responsible for storing it (e.g. in a vault) for future keytab-mode mints. Shares the failed-auth rate limiter with /v1/mint's password path, since both are real checks against the same CERN account. cern-get-keytab is vendored as-is at etc/cern-get-keytab and patched separately via etc/cern-get-keytab.patch (applied at image build time, never hand-edited in place), fixing three real problems in the upstream script: a shell-injection bug in its --old-account-password handling (shlex.quote), no non-interactive stdin password input (only argv or an interactive /dev/tty prompt), and silently discarded failure diagnostics on stderr. The third fix turned out to be load-bearing in a way source-reading alone didn't show: verified against CERN's real AD backend, msktutil's own "Preauthentication failed"-style errors land on stdout, not stderr -- only its top-level failure summary reaches stderr, and only because of this patch. Also fixes ccache.read_ccache to wrap pykrb5's own krb5.Krb5Error (genuinely malformed input) into CcacheParseError, alongside the existing "no TGT found" case -- found by the first renew_ticket test against a garbage ccache. docs/plans/2026-09-03-keytab-and-renew-design.md has the full design writeup, including what was verified against real CERN infrastructure versus assumed from source. Assisted-by: Claude (Anthropic)
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.
Summary
POST /v1/renew—kinit -Ron a ccache this service minted earlier. No credential involved at all, so it never touches the rate limiter; capped at the ticket's ownrenew_until.POST /v1/mintnow also acceptskeytab_b64as an alternative topassword(kinit -k -t), exactly one of the two required (422 otherwise).POST /v1/keytab— bootstraps a fresh keytab from a password via CERN's owncern-get-keytab(msktutil-backed). Never persists the keytab; the caller stores it (e.g. in a vault) for future keytab-mode mints. Shares the failed-auth rate limiter with/v1/mint's password path — both are real checks against the same CERN account.cern-get-keytabis vendored as-is (etc/cern-get-keytab) and patched separately (etc/cern-get-keytab.patch, applied at image build time), fixing three real problems in the upstream script — seedocs/plans/2026-09-03-keytab-and-renew-design.mdfor the full writeup, including a finding only reproducible by running the patched script against CERN's real backend (msktutil's per-strategy errors land on stdout, not stderr; only its top-level summary reaches stderr, and only because of this patch's third fix).ccache.read_ccachenow also wrapspykrb5's ownKrb5Error(genuinely malformed input) intoCcacheParseError— found by the firstrenew_tickettest against a garbage ccache.Test plan
pixi run -e dev lint-all(ruff +mypy --strict+ pre-commit incl. zizmor) — cleanpixi run -e dev test— 147 passed, 1 skipped (test_e2e.py, opt-in against a real deployment)helm lint/helm template(default values andkrb5Config.override=true)docker buildagainst the updatedContainerfile; confirmed inside the built image:msktutilpresent,kinit/klistsymlinks resolve, the patch applied correctly (all four fixes present),requests/pyyamlimport under the service's own interpreter, and the stdin-password patch works at runtime — not just present in source — against CERN's real Active Directory backend (deliberately wrong password, against a nonexistent test account only, never a real one)🤖 Generated with Claude Code