craig-intake-keyring — Signer-Key Registry Sidecar
craig-intake-keyring is a minimal workspace service (services/craig-intake-keyring/, container port 8010) introduced by ADR-042 §D8 (MR8 / #688). It exists only for the standalone-SHINES deployment.
Why it exists
craig-intake is a stateless edge (ADR-017): it validates and forwards, with no service-side DB of its own. But the standalone signature-only API needs two pieces of state: the registered public keys and the JWS replay-dedup records. Rather than smear that state into the edge, which would break ADR-017, the keyring isolates it in one tiny companion service. Crucially, it re-exposes the same HTTP contracts craig-security and craig-cases already serve, so intake’s existing SignerAuthClient and JwsReplayClient just point at the sidecar instead. No new client is needed, and JWS is verified in standalone mode exactly as it is in integrated mode.
The store holds only public keys (a passkey’s private key stays in the reporter’s authenticator; a machine client keeps its own) and replay records — all publishable, so encryption would be obscurity, not security (Kerckhoffs). This still holds after the ADR-042 §D8 amendment (2026-08-26) moved the store off an unencrypted flat JSON file onto an unencrypted Postgres database — the data’s sensitivity didn’t change, only whether one instance or N can serve it.
A browser offers a passkey only in a secure context: HTTPS, or localhost. The intake pages must therefore be served over HTTPS in production, from an origin on the keyring’s list; elsewhere /keygen, /passkeys and the report page’s signing block explain that a passkey cannot be used and offer no signing. The pages are described in Browser pages and passkeys.
|
Re-exposed contracts (consumed by intake unchanged)
-
GET /v1/security/signer-keys/by-kid/{kid}: returns theSignerKeyInfoshape intake deserializes, with a synthetic nilpartner_idand the literalpartner_status: "active", the exact value the verifier accepts, since there is no partner tenancy. It returns HTTP 404 for an unknown, pending, revoked, or expired key. Key lifecycle is enforced by withholding the key, mirroring craig-security. The response also names the key’scredential_kind,jwsorwebauthn(ADR-082 D1): a verifier must refuse a proof of the other kind. -
POST /v1/cases/_internal/jws-replay-check: takes{ partner_id, jti, iat }and dedups byjti. The unchanged client carries nokid;jtiis a per-submission UUID, so cross-holder collision is negligible. It returns HTTP 200 for first-seen, HTTP 401 for a replay, and records past a configurable retention window are pruned. Since #732 the body optionally carries the signing receipt (signer_kid,payload_sha256,jws) — appended to the separate append-onlysigning_receiptsevidence table on every ACCEPTANCE (a replay appends nothing; the dedup prune never touches it), making each accepted submission’s signature evidence durable and re-verifiable against the registered key (ADR-042 § Amendment 2026-08-29). An over-capsigner_kid(> 64) is a 400 and apayload_sha256that is not 64 lowercase hex is the extractor’s 422, both before the jti is recorded;jwsis bounded by the 16 KiB body limit only (#2366).-
Passkey evidence (ADR-082 D3, #2196). The body may carry
webauthn_receiptin place of the three JWS receipt members:{signer_kid, payload_sha256, authenticator_data, client_data_json, signature}, the last three unpadded base64url. On first-seen the keyring appends awebauthnrow tosigning_receiptsholding the signed bytes, the signature, the flags byte and the signature counter, so the assertion re-verifies later from the stored row, the original canonical payload and the registered key. A body carrying both receipt shapes, or a whole passkey receipt that does not decode, is 400 with nothing written. A partial one is a plain dedup, as for JWS.
-
-
The receipt’s
jwsis bounded at intake (#2566). Intake refuses anX-JWS-Signaturecompact over 8 KiB (JWS_COMPACT_MAX) as the uniform 401, before it verifies or forwards it. The replay check’s body around a compact at the bound therefore fits this service’s 16 KiB body limit, and intake never meets the keyring’s 413.
Key lifecycle
-
POST /keys/register: accepts a browser-generated public JWK and a holder label (reusingcraig_security_contracts::RegisterSignerKeyRequest), and stores itpending. It is unauthenticated by design: anyone may propose a key, but an admin must approve it before it can sign an accepted report. It allowlist-validates the algorithm toES256(ECDSA over the P-256 curve with SHA-256, the JOSE/JWA signature algorithm identifier), rejects a duplicatekid(HTTP 409), and is bounded by amax_keyscap (HTTP 429).-
Passkeys (ADR-082 D2, #2195). The same route takes a second body. A body with
"kind": "webauthn"registers a passkey:user_identifier,display_name,iat(epoch seconds) and the base64urlattestation_objectandclient_data_jsonof the browser’s registration ceremony. A body with nokindmember is the JWK registration above, unchanged; akindof any other value or type,nullincluded, a repeatedkind, or a JSON body that is not an object is 400. The keyring verifies the ceremony itself before storing anything: thewebauthn.createtype; a challenge equal to SHA-256 of the canonical{display_name, iat, user_identifier}, which ties the labels an administrator approves to the credential created; an allowed origin; the RP ID hash; user presence and user verification; aniatno more than 5 minutes old or 30 seconds ahead; an ES256 P-256 key; and, when device-bound credentials are required, a credential that is not backup-eligible. Any failure is the fixed 400, which names no check. Success stores a new identity with onependingwebauthnkey whosekidis derived from the credential ID (wa_+ base64url of its SHA-256), and answers{kid, signer_key_id, status}. A credential already registered is 409; a full store is 429, counted with the JWK keys under the same lock. Labels holding a control character are refused, not cleaned: the challenge binds them as sent. intake’sPOST /signed/v1/keys/registerrelays a passkey body to the keyring byte for byte.
-
-
PUT /keys/{kid}/approve(pending→approved) andPUT /keys/{kid}/revoke(→revoked, terminal) form the admin lifecycle, gated by a constant-time admin-token bearer check (subtle::ConstantTimeEqover SHA-256 digests; an unset token fails closed). These are operator-only; there is no browser approve/revoke UI. -
GET /webauthn/config(ADR-082 D2, #2194) serves the passkey policy this keyring owns:{rp_id, allowed_origins, require_device_bound}, from the requiredCRAIG_INTAKE_KEYRINGWEBAUTHN_RP_IDandWEBAUTHN_ALLOWED_ORIGINS(plusWEBAUTHN_REQUIRE_DEVICE_BOUND;WEBAUTHN_MAX_ACTIVE_PER_IDENTITYis read by later units). It is internal and unauthenticated, carrying no secret. Both SHINES intake instances fetch it at boot and refuse to start without it, so a change needs an intake restart. -
PUT /identities/{identity_id}/revoke(ADR-082 D5, #2200): admin-token gated like approve and revoke. It revokes every passkey of one identity with a single generation bump, the backstop for devices a reporter added without an administrator. An unknown identity is 404; a missing or wrong token is 401.GET /keysshows each passkey’sidentity_id, with itscredential_kindandbackup_eligible; it still omits the JWK anduser_identifier. -
verify-receipt(ADR-082 D4, #2201).craig-intake-keyring verify-receipt --jti <uuid> --payload <file>re-verifies every signing receipt stored for one submission. It needs onlyCRAIG_INTAKE_KEYRING__DATABASE_URL, runs its session read-only, and never serves or migrates.<file>is the submission’s report JSON, which the keyring never holds. For each receipt it prints the receipt id, kind,kid, the signer’s labels, when it was stored, a passkey’s flags, andVALIDorINVALID:with the failing check: the payload must hash to the recorded value; the key registered for thekidmust be of the receipt’s kind; the signature must verify under it; a JWS’s signed header must name thiskid,jtiand the recordediat; a passkey’s signed client data must bind thisjti, the recordediatand that hash, and its signed authenticator data must carry the registered RP ID, user presence and verification, and the recorded flags. The origin inside a passkey’s signed client data is not compared with the WebAuthn policy, which the command does not load. Exit codes: 0 when every receipt is valid, 1 when any is not, 2 when no receipt is stored for thejtior the payload cannot be read as JSON. The output names the signer, so treat it as you would the key list. -
POST /self-service(ADR-082 D5, #2198): a reporter’s operations on their own passkeys. The body is{op, credential_id, authenticator_data, client_data_json, signature, jti, iat};opis tagged bykind:view,rename(display_name),revoke(target_kid) oradd_device(new_kid,attestation_object,registration_client_data_json,registration_iat). The keyring verifies the assertion itself, over a challenge of SHA-256 of the canonical{op, iat, jti}plus the operation’s bound members:display_namefor a rename,target_kidfor a revoke, and for an add bothnew_kidandattestation_digest(unpadded base64url SHA-256 of the new device’sattestationObject, so the new public key cannot be swapped after signing), and spends thejtiin its replay store.-
Who may do what. A pending passkey may view, rename and revoke itself. An approved one may also revoke any passkey of its identity and add a device. A revoked or expired passkey, a failed assertion, a replayed
jtiand an operation the signer may not perform are all the same 401. -
Answer. Every operation answers the identity as it now stands: its labels and, per passkey,
kid, effective status,created_at,backup_eligibleand whether it signed this request. Never a JWK or a credential ID. -
Rename changes the identity’s
display_nameonly, needs no re-approval, and logs the old and new names as one structured event. Revoke is terminal and bumps the revocation generation in the same transaction; akidoutside the signer’s identity is 404, like an unknown one. -
Add device verifies the new device’s registration ceremony over the identity’s stored labels and requires it to derive to the
new_kidthe signer’s assertion bound (400 otherwise; 409 for a known credential; 429 for a full store). The new passkey is approved, with a generation bump, while the identity holds fewer active passkeys thanCRAIG_INTAKE_KEYRING__WEBAUTHN_MAX_ACTIVE_PER_IDENTITY(default 3), and pending otherwise. The count and the insert run under a per-identity lock, so concurrent adds across keyring instances cannot approve past the cap. Administrator approval is not limited by the cap. -
Reaching it. intake’s
POST /signed/v1/passkeysrelays the request to the keyring byte for byte and returns its view; the keyring’s 400, 401, 404, 409 and 429 come back as bare statuses.
-
-
GET /keys(#714) is a metadata-only list of registered keys for the view-keys testing aid:kid,display_name, an effectivestatus(an approved key pastexpires_atreadsexpired, mirroringlookup_active),created_at, andexpires_at. It deliberately omits thepublic_key_jwkand the partner-scoped holder identifier. It’s gated default-off byCRAIG_INTAKE_KEYRING__ENABLE_KEY_LIST: when off, the route is simply absent (HTTP 404, with no existence signal); when on, it’s unauthenticated likeregister, with the gate plus the internal-only deployment boundary as the protection. The browser reaches it only through the same-origin intake proxyGET /signed/v1/keys.
SignerAuthClient (services/craig-intake/src/api/signer_auth.rs, ADR-045, #747) caches by kid with split lifetimes: an approved key for 5 s (POSITIVE_CACHE_TTL), so a revoke stops verifying within 5 s, and an absent key (None) for 60 s (NEGATIVE_CACHE_TTL), so a key approved after its absence was cached may wait up to 60 s for its first successful verify. On the standalone-SHINES path a keyring revocation-generation bump evicts the cache at once (#892); the 5 s TTL is the fallback there. Tests register and approve a fresh kid so a pre-approval None is never cached.
|
Store + operations
-
Store: the
craig_intake_keyringPostgres database (signer_keys,replay_records, and the #732 append-onlysigning_receipts), applied via the fleet’s standard ADR-063 migration gate (docker compose up craig-intake-keyring-migratebefore the app boots). Like every other service database it carries the ADR-063schema_compat_floor(migration20261007110000_schema_compat_floor, #2605), which the serving boot’sFloorCheck::Enforcereads on an Ahead schema;20261007120000_passkey_identitiesraises it to its own version. The service can run as N horizontally-scaled instances sharing the one database: duplicate-kidrejection andapprove/revokeare exact via ordinary Postgres constraints/row updates;register’s `max_keyscapacity check is exact via a transaction-scoped advisory lock serializingregistercalls fleet-wide; andreplay_check— the security-critical operation — is a single atomic upsert (INSERT … ON CONFLICT … DO UPDATE … WHERE), so two instances racing the samejticannot both accept it as first-seen. Seedocs/modules/ROOT/pages/plans/archive/keyring-postgres-backend.adocand the ADR-042 amendment for the full design and the two S3-based alternatives rejected before this one. -
Credential kinds (ADR-082 D1/D4, #2193): every
signer_keysrow has acredential_kind,jwsorwebauthn. Ajwsrow is today’s key, with its holder labels on the row. Awebauthnrow is a passkey: it belongs to onesigner_identitiesrow, which carries the labels. A trigger refuses any change touser_identifier, the identifier an admin approves on;display_nameis the label ADR-082 D5 lets the reporter change. It records itscredential_id(unique), therp_idit was created under, and whether it wasbackup_eligibleat registration; its own label columns are NULL. Reads join the identity and resolve the labels withCOALESCE, so every read path returns labels for both kinds.signing_receiptslikewise holds exactly one evidence shape per row: the detached JWS compact, or the WebAuthnauthenticator_data,client_data_json, DERsignature,flagsandsign_count. CHECK constraints make a mixed row unrepresentable in both tables; rows written before the migration arejwsand unchanged. A second trigger,signer_keys_webauthn_binding_fixed, refuses any change to awebauthnrow’sidentity_id,credential_kind,credential_id,rp_id,public_key_jwkorkid, including turning ajwsrow into one, so an approved passkey cannot move to another identity, credential or key pair;KeyringState::registerwritesjwsrows only. Passkey registration and verification arrive in later units (U4, U5). -
Image: Alpine, musl, rustls; runs non-root, with a
HEALTHCHECK. -
Devstack: a
craig-intake-keyringcompose service plus anxtaskport mapping (container port 8010; the host port is ephemeral, allocated bycargo xtask devand recorded in.ports.env—cargo xtask dev statusshows the live mapping — while the rawdocker composefallback still publishes the default host port 8012). The admin token is the devstack-onlyADMIN_TOKEN: devstack-keyring-admin-token.
Deployment boundary
The keyring is internal-network-only in production: no CORS, and it’s never host-published. The registration page proposes a passkey by POSTing same-origin to an intake proxy (POST /signed/v1/keys/register), which forwards server-side to the sidecar, so the browser only ever talks to intake’s origin (ADR-042 §D9). The devstack host-port mapping exists purely as a test convenience, letting the signed-API e2e and the Rust integration tests drive the admin approve route directly.
Related
-
ADR-042 §D8/§D9 — the sidecar design + the no-partner signed-API auth.
-
Standalone intake architecture — where the keyring sits in the flow.
-
SHINES CPS intake — proposed API — the backend a signed submission forwards to.