Skip to content

feat: add ticket renewal and keytab-based minting/bootstrap - #2

Merged
kratsg merged 1 commit into
mainfrom
feat/keytab-and-renew
Sep 3, 2026
Merged

kratsg merged 1 commit into
mainfrom
feat/keytab-and-renew

Conversation

@kratsg

@kratsg kratsg commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • 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 (422 otherwise).
  • 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 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-keytab is 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 — see docs/plans/2026-09-03-keytab-and-renew-design.md for 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_ccache now also wraps pykrb5's own Krb5Error (genuinely malformed input) into CcacheParseError — found by the first renew_ticket test against a garbage ccache.

Test plan

  • pixi run -e dev lint-all (ruff + mypy --strict + pre-commit incl. zizmor) — clean
  • pixi run -e dev test — 147 passed, 1 skipped (test_e2e.py, opt-in against a real deployment)
  • helm lint / helm template (default values and krb5Config.override=true)
  • Real docker build against the updated Containerfile; confirmed inside the built image: msktutil present, kinit/klist symlinks resolve, the patch applied correctly (all four fixes present), requests/pyyaml import 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

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)
@kratsg
kratsg merged commit a1ad1f5 into main Sep 3, 2026
5 checks passed
@kratsg
kratsg deleted the feat/keytab-and-renew branch September 3, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant