mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-07 13:41:30 +00:00
auth-bundle-2 Phase 16: docs updates (security.md OIDC + sessions + break-glass + auditor split sections; new migration/oidc-enable.md; CHANGELOG.md v2.1.0 Bundle 2 release notes)
Closes Phase 16 of cowork/auth-bundle-2-prompt.md. Three operator-
facing docs updated, one new migration guide ships, README nav row
added.
Files
=====
docs/operator/security.md (MODIFIED, Last reviewed bumped to 2026-05-10):
* Added 5 new Bundle 2 subsections under '## Authentication
surface' after the Bundle 1 approval-bypass-closure entry:
- 'OIDC federation (Bundle 2 Phases 1-7)' — alg allow-list,
IdP-downgrade defense, iss/aud/azp/at_hash, single-use
state+nonce, PKCE-S256 mandatory, JWKS rotation handling,
encrypted client_secret at rest with the v3 blob format
pinned by an integration test, pointer to oidc-runbooks/
for per-IdP setup.
- 'Sessions + back-channel logout (Bundle 2 Phases 4-6)' —
length-prefixed HMAC cookie wire format, HttpOnly + Secure
+ SameSite cookie hardening, idle/absolute timeouts, CSRF
defense, signing-key rotation primitive, fail-fatal
EnsureInitialSigningKey at server boot, OpenID Connect
Back-Channel Logout 1.0 (NOT RFC 8414).
- 'OIDC first-admin bootstrap (Bundle 2 Phase 7)' — coexists
with Bundle 1's env-var-token bootstrap, group-scoped via
CERTCTL_BOOTSTRAP_ADMIN_GROUPS + CERTCTL_BOOTSTRAP_OIDC_PROVIDER_ID,
one-shot per tenant.
- 'Break-glass admin (Bundle 2 Phase 7.5)' — default-OFF,
surface invisibility via 404-not-403, Argon2id with OWASP
2024 params, lockout state machine, constant-time-via-
verifyDummy, WARN log at boot, runbook pointer for
operator drill.
- 'Migrating an existing deployment to OIDC' — pointer to
the new migration/oidc-enable.md walkthrough.
docs/migration/oidc-enable.md (NEW, Last reviewed 2026-05-10):
* Step-by-step migration guide for an operator on a Bundle-1-merged
deployment to enable OIDC SSO. Pre-reqs (CERTCTL_CONFIG_ENCRYPTION_KEY,
admin actor with auth.oidc.create + auth.oidc.edit, IdP tenant)
+ 7 numbered steps (pin encryption key, complete IdP-side per
runbook, configure certctl-side OIDCProvider, add group→role
mappings with fail-closed warning, optional first-admin bootstrap,
verify with single test user, announce SSO endpoint).
* Rollback section covering the 4-step disable flow + the 409
Conflict on provider-delete-while-sessions-exist + the
existing-sessions-keep-working-until-expiry semantics.
* Troubleshooting section pinning 8 most-common failure modes
(discovery doc fetch fails / IdP downgrade defense rejects /
no roles assigned / iss mismatch / pre-login expired / state
mismatch / sessions revoked but user can hit API / JWKS
rotation breaks login).
* Database row count drift documented so operators know what to
expect after OIDC is live (10 Bundle 2 tables enumerated).
* Cross-references to oidc-runbooks/ + security.md +
auth-threat-model.md + auth-benchmarks.md + auth-standards-implemented.md.
CHANGELOG.md (MODIFIED):
* v2.1.0 section title bumped from 'Auth Bundle 1: RBAC primitive'
to 'Auth Bundles 1 + 2: RBAC primitive + OIDC SSO + sessions'.
* Replaced the Bundle 1 closing-bullet ('Bundle 2 starts after
Bundle 1 lands on master') with 18 new Bundle 2 entries:
- OIDC + sessions + back-channel logout + break-glass overview.
- OIDC token validation pinned at three layers (alg allow-list,
IdP-downgrade defense, OIDC Core §3.1.3.7 re-verification).
- Length-prefixed HMAC session cookies.
- CSRF double-submit + hashed-token-on-row.
- OIDC client_secret AES-256-GCM v3 blob at rest +
integration-test invariant.
- OIDC first-admin bootstrap.
- Default-OFF break-glass admin (Argon2id + lockout +
constant-time + surface invisibility).
- GUI: 4 new pages + login-page IdP buttons + sidebar logout.
- 11 new MCP tools for OIDC + session management.
- 6 per-IdP runbooks (Keycloak / Authentik / Okta / Auth0 /
Entra ID / Google Workspace).
- Threat model extended with 5 new defense subsections + 8 new
threat-catalogue subsections.
- Performance baselines documented (4 benchmarks; 3 measured
+ 1 operator-runs).
- Standards-and-RFC implementation table (13 RFCs + 14 CWEs;
NOT a compliance-mapping doc).
- Coverage gates held at floor 90 across all 4 Bundle 2
packages (anti-Bundle-1-mistake invariant).
- Multi-tenant query CI guard (ratchet baseline 32).
- Phase 10 Keycloak testcontainers integration test + optional
Okta smoke test.
- OpenAPI cookieAuth security scheme + 13 new endpoints + 4
break-glass endpoints.
- Bundle-1-only compat regression CI guard +
Bundle-1-to-2-upgrade regression CI guard.
* Final paragraph updated to point at oidc-enable.md alongside
api-keys-to-rbac.md as the two migration walkthroughs.
docs/README.md (MODIFIED):
* Added the new oidc-enable.md migration row under '## Migration'
alongside the existing api-keys-to-rbac.md entry, with a
one-line description flagging it as the Bundle 2 OIDC
onboarding walkthrough.
Verification
============
* Last-reviewed on security.md + oidc-enable.md: 2026-05-10.
* Internal-link sweep on oidc-enable.md: 0 broken (every relative
link resolves via shell-loop verification).
* Internal-link sweep on docs/README.md: 0 broken (all .md
references resolve).
* No Go-side impact, make verify gate unchanged.
Bundle 2 documentation deliverables now complete: security.md +
auth-threat-model.md + oidc-runbooks/ + auth-benchmarks.md +
auth-standards-implemented.md + api-keys-to-rbac.md + oidc-enable.md
+ CHANGELOG.md v2.1.0. The full Bundle 2 surface is operator-
discoverable from docs/README.md root nav.
This commit is contained in:
+144
-1
@@ -1,6 +1,6 @@
|
||||
# certctl Security Posture & Operator Guidance
|
||||
|
||||
> Last reviewed: 2026-05-09
|
||||
> Last reviewed: 2026-05-10
|
||||
|
||||
This document collects the operator-facing security guidance that the source
|
||||
code's per-finding comment blocks reference. Each section names the audit
|
||||
@@ -130,6 +130,149 @@ layer with `ErrApproveBySameActor`. See
|
||||
[`docs/reference/profiles.md`](../reference/profiles.md) for the
|
||||
full gate semantics.
|
||||
|
||||
### OIDC federation (Bundle 2 Phases 1-7)
|
||||
|
||||
Bundle 2 adds OIDC SSO on top of the API-key + RBAC foundation.
|
||||
Operators configure one or more identity providers (Keycloak,
|
||||
Authentik, Okta, Auth0, Entra ID, or Google Workspace via Keycloak
|
||||
broker); end users sign in at the IdP, certctl validates the
|
||||
returned ID token, and a session cookie is minted.
|
||||
|
||||
The token-validation pipeline pins:
|
||||
|
||||
- Algorithm allow-list: RS256 / RS512 / ES256 / ES384 / EdDSA only.
|
||||
HS256 / HS384 / HS512 / `none` are rejected at the service-layer
|
||||
sentinel level.
|
||||
- IdP-downgrade-attack defense at provider creation AND every
|
||||
RefreshKeys: the IdP's advertised
|
||||
`id_token_signing_alg_values_supported` is intersected with the
|
||||
allow-list; a provider that advertises HS-family is rejected
|
||||
before any token is signed under the weak alg.
|
||||
- Exact `iss` match (`ErrIssuerMismatch`).
|
||||
- `aud` membership + `azp` for multi-aud tokens (per OIDC core
|
||||
§3.1.3.7 step 5).
|
||||
- `at_hash` REQUIRED-when-access_token-present (Phase 3 tightening
|
||||
of the spec MAY → MUST so a substituted access token cannot
|
||||
ride alongside a clean ID token).
|
||||
- Single-use state + nonce (32-byte random server-generated;
|
||||
atomic `DELETE...RETURNING` on consume).
|
||||
- PKCE-S256 mandatory; `plain` rejected.
|
||||
- Configurable `iat` window (default 300s, capped 600s).
|
||||
- JWKS cache with operator-triggered RefreshKeys + auto-refresh on
|
||||
TTL expiry (default 3600s); JWKS-fetch failure during a key
|
||||
rotation returns 503 to the in-flight login (existing sessions
|
||||
untouched).
|
||||
|
||||
OIDC `client_secret` is encrypted at rest via AES-256-GCM (v3 blob
|
||||
format: magic 0x03 + salt(16) + nonce(12) + ciphertext+tag) using
|
||||
the `CERTCTL_CONFIG_ENCRYPTION_KEY` passphrase. The encryption
|
||||
invariant is pinned by an integration test
|
||||
(`internal/repository/postgres/oidc_encryption_invariant_test.go`)
|
||||
that asserts ciphertext != plaintext + correct blob shape +
|
||||
round-trip recovery + wrong-passphrase fails.
|
||||
|
||||
Per-IdP setup guides at
|
||||
[`oidc-runbooks/index.md`](oidc-runbooks/index.md) cover Keycloak,
|
||||
Authentik, Okta, Auth0, Entra ID, and Google Workspace.
|
||||
|
||||
### Sessions + back-channel logout (Bundle 2 Phases 4-6)
|
||||
|
||||
Successful OIDC login mints a session cookie:
|
||||
`v1.<session_id>.<signing_key_id>.<base64url-no-pad(HMAC-SHA256)>`.
|
||||
The HMAC input is **length-prefixed** as `len:sid:len:kid` to defeat
|
||||
concatenation-collision attacks on bare-concat designs. Cookie
|
||||
attributes:
|
||||
|
||||
- `HttpOnly=true` (no JS access; defends XSS cookie theft).
|
||||
- `Secure=true` (HTTPS-only; defends network MITM).
|
||||
- `SameSite=Lax` default (configurable to Strict via
|
||||
`CERTCTL_SESSION_SAMESITE`).
|
||||
- `Path=/`, host-only.
|
||||
|
||||
Idle timeout default 1h; absolute timeout default 8h; both
|
||||
configurable via `CERTCTL_SESSION_IDLE_TIMEOUT` and
|
||||
`CERTCTL_SESSION_ABSOLUTE_TIMEOUT`. The scheduler's
|
||||
`sessionGCLoop` (default 1h interval) sweeps expired rows.
|
||||
|
||||
CSRF defense: plaintext CSRF token in the JS-readable
|
||||
`certctl_csrf` cookie (intentionally `HttpOnly=false` for the GUI
|
||||
to echo into the `X-CSRF-Token` header); SHA-256 hash on the
|
||||
session row; `subtle.ConstantTimeCompare` in `CSRFMiddleware`.
|
||||
API-key actors are CSRF-exempt (no session row in context).
|
||||
|
||||
Session signing keys rotate via `RotateSigningKey`; the old key
|
||||
stays valid for `CERTCTL_SESSION_SIGNING_KEY_RETENTION` (default
|
||||
24h) so existing cookies validate during rollover. Past retention,
|
||||
the old key's row is dropped and any cookie still signed under it
|
||||
returns `ErrSigningKeyNotFound`. `EnsureInitialSigningKey` is
|
||||
fail-fatal at server boot.
|
||||
|
||||
Back-channel logout per **OpenID Connect Back-Channel Logout 1.0**
|
||||
(NOT RFC 8414): `POST /auth/oidc/back-channel-logout` accepts a
|
||||
JWT-signed logout token from the IdP, validates the JWT against
|
||||
the IdP's JWKS (same alg allow-list as login), pins required
|
||||
claims (`iss` / `aud` / `iat` / `jti` / `events`; exactly one of
|
||||
`sub` / `sid`; `nonce` MUST be absent), defeats replay via
|
||||
`jti`-based deduplication, and revokes matching sessions.
|
||||
|
||||
For threat-model coverage of these surfaces, see
|
||||
[`auth-threat-model.md`](auth-threat-model.md). For the
|
||||
operator-runnable performance baselines, see
|
||||
[`auth-benchmarks.md`](auth-benchmarks.md).
|
||||
|
||||
### OIDC first-admin bootstrap (Bundle 2 Phase 7)
|
||||
|
||||
Coexists with Bundle 1's env-var-token bootstrap. When the
|
||||
operator sets `CERTCTL_BOOTSTRAP_ADMIN_GROUPS` + (optionally)
|
||||
`CERTCTL_BOOTSTRAP_OIDC_PROVIDER_ID`, the first user with one of
|
||||
those IdP groups becomes admin on first login per tenant.
|
||||
Subsequent users go through normal mapping. The admin-existence
|
||||
probe ensures only one wins between the two bootstrap paths;
|
||||
once any actor holds `r-admin`, the OIDC bootstrap hook silently
|
||||
falls through to normal mapping. Audit row on every grant
|
||||
(`bootstrap.oidc_first_admin`, `event_category=auth`).
|
||||
|
||||
### Break-glass admin (Bundle 2 Phase 7.5)
|
||||
|
||||
Default-OFF (`CERTCTL_BREAKGLASS_ENABLED=false`). When enabled,
|
||||
the local-password admin path bypasses OIDC + group-claim layers;
|
||||
intended ONLY for SSO-broken incidents.
|
||||
|
||||
- Argon2id with OWASP 2024 params (m=64 MiB, t=3, p=4, 16-byte
|
||||
salt, 32-byte output, per-password random salt, PHC-format
|
||||
hash). Hash column is `json:"-"` so handlers cannot wire-leak.
|
||||
- Lockout state machine: 5 failures (default; configurable via
|
||||
`CERTCTL_BREAKGLASS_LOCKOUT_THRESHOLD`) within 1h reset window
|
||||
(`_LOCKOUT_RESET_INTERVAL`) trips a 30s lockout (`_LOCKOUT_DURATION`).
|
||||
Atomic single-statement IncrementFailure defeats concurrent
|
||||
racing attempts.
|
||||
- Constant-time across all failure paths via `verifyDummy()` —
|
||||
wrong-password / locked-account / no-actor all take statistically
|
||||
indistinguishable time.
|
||||
- Surface invisibility: when disabled, ALL four endpoints return
|
||||
HTTP 404 (NOT 403). Scanners cannot distinguish "endpoint
|
||||
disabled" from "endpoint doesn't exist".
|
||||
- WARN log at server boot when `ENABLED=true`; audit row on every
|
||||
break-glass login (`auth.breakglass_login_*`,
|
||||
`event_category=auth`); WebAuthn/FIDO2 second factor pairing
|
||||
on the v3 roadmap (Decision 12).
|
||||
|
||||
Operator should DISABLE break-glass within 24h of SSO recovery
|
||||
to avoid a permanent backdoor; the runbook at
|
||||
[`auth-threat-model.md#break-glass-risks-phase-75`](auth-threat-model.md)
|
||||
documents the full state machine.
|
||||
|
||||
### Migrating an existing deployment to OIDC
|
||||
|
||||
A Bundle-1-merged deployment that wants to add OIDC follows the
|
||||
step-by-step at
|
||||
[`docs/migration/oidc-enable.md`](../migration/oidc-enable.md):
|
||||
configure CERTCTL_CONFIG_ENCRYPTION_KEY, pick + configure an IdP
|
||||
per the relevant runbook, configure the certctl-side OIDCProvider
|
||||
+ group→role mappings, verify the login flow against a single
|
||||
test user, then announce the SSO endpoint to the rest of the
|
||||
organization.
|
||||
|
||||
## Per-user rate limiting
|
||||
|
||||
Bundle B / M-025. Authenticated callers are bucketed by API-key name;
|
||||
|
||||
Reference in New Issue
Block a user