Repository navigation
feat(security): credential lifecycle — validation, rotation, audit, revocation (Fixes #62) - #190
Merged
Merged
Conversation
… audit trail, revocation (#62) - Validate org credentials at save time (strict by default, CREDENTIAL_VALIDATION =warn|off): no control chars/line breaks, size cap, secret length, URL shape, vendor prefixes (sk-ant-, sk-, xoxb-, hooks.slack.com, GitHub token formats), AWS key ID, port, bool, LLM provider. 422 lists keys and reasons, never values. _SENSITIVE_SUFFIXES is now used (is_sensitive). - PATCH /orgs/{org}/config merges (null removes) so a key can be rotated without resending the rest; PUT still replaces and now reports ignored keys. - DELETE /orgs/{org}/config (all or ?keys=) revokes; the blob is overwritten before deletion. MCP: revoke_org_credentials, configure_org_credentials(merge). - Per-key updated_at/updated_by metadata; status shows source, age_days and stale secrets (CREDENTIAL_MAX_AGE_DAYS, default 90). - Audit events (actor = role + token fingerprint, keys added/changed/removed, never values) under {org}/credential_audit/; GET /orgs/{org}/config/audit. - docs/CREDENTIAL_ROTATION.md runbook (rotation and leak response). Fixes #62 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Fixes #62.
What the issue asked for, and what's here
validate_credentials: control chars and line breaks, an 8 KB cap, secret length and whitespace, http(s) URLs,hooks.slack.com,sk-ant-/sk-/xoxb-, GitHub token formats (ghp_…github_pat_, 40-hex classic), AWSAKIA/ASIAkey IDs, SMTP port,AUTO_APPLY,LLM_PROVIDER. Returns 422{"errors": {key: reason}}and never echoes a value.CREDENTIAL_VALIDATION=strict(default),warnoroff, in case a vendor changes its format._SENSITIVE_SUFFIXESis now used.{action, org_id, actor, timestamp, added, changed, removed}to{org}/credential_audit/<y>/<m>/.actoris the role plus the first 12 hex characters of the token's SHA-256 (ormcp), never the token. Changes are detected by comparing hashes, so values never appear in events or logs. NewGET /orgs/{org}/config/audit(admin).DELETE /orgs/{org}/config(all keys) or?keys=A,B(admin). MCPrevoke_org_credentials. The stored blob is overwritten before it's deleted.updated_at/updated_byper key.GET …/config/statusnow addsdetails(source, sensitive, age, updater) andstale(secrets older thanCREDENTIAL_MAX_AGE_DAYS, default 90).docs/CREDENTIAL_ROTATION.md(in the mkdocs nav) covers the endpoints, validation rules, audit format, the step-by-step rotation, the leak response, and a versioned-bucket caveat.Also:
PATCH /orgs/{org}/configmerges: send one key to rotate it, andnullremoves a key. Without it,PUTreplaces the org's whole set, so rotating one key meant resending every other key too (the same gotcha noted in fix(security): per-org webhook secrets and tenant binding (Fixes #61) #189). MCPconfigure_org_credentialsgetsmerge: truefor the same behaviour.PUTnow reportsignored_keys(unknown names) instead of dropping them silently.Tests
tests/test_credential_lifecycle.py, 41 tests: the validation matrix (reject and accept), no values in errors, warn mode, merge/remove, ignored keys, per-key metadata, unchanged values keep their timestamp, stale detection, audit events without values, selective and full deletion with overwrite, and API 422/PATCH/DELETE/audit.tests/conftest.pyturns validation off for the rest of the suite, which stores placeholder keys such as"gh-token". The new tests turn strict mode back on.🤖 Generated with Claude Code