Skip to main content

delcred: Short-lived credentials for AI agents, not your real keys.

Security notice: upgrade from 0.2.0. 0.2.0 has a policy bypass for setups that register an external IdP (see SECURITY.md). Use 0.2.1 or later: pip install -U delcred.

Platform: Linux and macOS only. delcred relies on fcntl file locks and POSIX 0600 permission checks; on Windows import delcred raises a clear ImportError (and the test suite is skipped). On a Windows machine, run it inside WSL (the 141-test suite passes there).

delcred mints short-lived, per-task, per-user-scoped credentials for AI agents, so you can stop giving agents your real API keys. One credential names both the human (sub) and the agent (act), is pinned to a single API, and expires in minutes. Revoke the agent without locking out the human.

pip install delcred && delcred init

Then edit ~/.delcred/policy.yaml: one grant per (user, agent) pair. Nothing is allowed until a grant exists.

A real run (Ubuntu under WSL, throwaway home folder; token trimmed to 30 characters):

$ delcred init
initialized delcred home at /tmp/dd/home/.delcred
  issuer key : 0600, never leaves this directory
  policy     : /tmp/dd/home/.delcred/policy.yaml  (edit your grants there)
$ delcred exchange --subject-token-file user.jwt --actor-token-file agent.jwt                    --scope invoices:read --resource https://api.acme.test/v1 > tok.jwt
# sub=u_alice act=billing-agent scope='invoices:read' resource=https://api.acme.test/v1 ttl=900s jti=SCacxuktABz_LuNyISVvGA
$ cut -c1-30 tok.jwt
eyJhbGciOiJFZERTQSIsInR5cCI6Im
$ delcred verify "$(cat tok.jwt)" --resource https://api.acme.test/v1
VALID  sub=u_alice act=billing-agent scope='invoices:read' aud=https://api.acme.test/v1 exp_in=900s jti=SCacxuktABz_LuNyISVvGA
$ delcred revoke --agent billing-agent --reason "suspected prompt injection"
revoked ALL credentials for agent 'billing-agent' (user unaffected)
$ delcred exchange ... ; echo "exit $?"
exchange denied: agent is revoked: agent 'billing-agent' revoked: suspected prompt injection
exit 3
  • Agents get capability-shaped credentials, never the underlying secret. A scoped JWT or an opaque dk_... key. The built-in key broker is the redemption half of delegation.
  • Deny by default, short by default. A grant in policy.yaml is the only thing that lets an exchange mint. Default lifetime 15 minutes, hard cap 60.
  • Kill switches that do not hit the human. Revoke one token, one agent, or one user. Checked on every verify.

Release PyPI License Python


Quickstart (30-second tour)

# 1. identities (agent = actor_token, user = subject_token)
delcred agent-token billing-agent > /tmp/agent.jwt
delcred user-token u_alice > /tmp/user.jwt        # dev only; prod uses your IdP's JWT

# 2. exchange -> delegation (RFC 8693 style).
#    Prefer files/env over CLI args: command lines are visible in `ps`.
delcred exchange --subject-token-file /tmp/user.jwt                  --actor-token-file   /tmp/agent.jwt                  --scope "invoices:read" --resource https://api.acme.test/v1
# ($DELCRED_SUBJECT_TOKEN / $DELCRED_ACTOR_TOKEN work too)
# -> eyJhbGciOiJFZERTQSIs...   (15-min JWT: sub=u_alice, act=billing-agent)

# 3. or an opaque API-key-shaped credential instead of a JWT
delcred exchange ... --as-api-key
# -> dk_7f3a...

# 4. verify: --resource is REQUIRED (audience pinning is the confused-deputy defense)
delcred verify <token> --resource https://api.acme.test/v1

# 5. revoke the agent: the human is untouched
delcred revoke --agent billing-agent --reason "suspected prompt injection"

Run delcred doctor after init and after every policy edit (see Limits up front).

External IdPs (production subject tokens)

Compatibility first: trusted IdP subject tokens must be signed with EdDSA (Ed25519), RS256 or ES256, one algorithm pinned per issuer. Okta, Auth0 and Microsoft Entra sign with RS256: register them with --alg RS256. delcred does not fetch JWKS URLs: export the IdP's current signing key as a PEM file. Only one key per issuer is held, so when your IdP rotates its signing key, tokens signed with the new key are rejected until you re-run trust-add with it.

delcred is not an IdP — it never does login or OAuth flows. But it accepts your IdP's user JWTs as subject_token: register the issuer once (its public key and the one algorithm it signs with), then pass the IdP's tokens straight into exchange:

delcred trust-add --iss https://idp.example.com --key-file ./idp-pub.pem
# → EdDSA (Ed25519) issuer; copies the key to ~/.delcred/trusted_issuers/
#   and records the mapping in policy.yaml under `trusted_issuers:`
delcred trust-add --iss https://okta.example.com --key-file ./okta-pub.pem --alg RS256
# → RS256 issuer (RSA >= 2048 bits); --alg ES256 takes an EC P-256 key

delcred exchange --subject-token-file /tmp/idp-user.jwt \
                 --actor-token-file   /tmp/agent.jwt \
                 --scope "invoices:read" --resource https://api.acme.test/v1
# subject claims come from the IdP token (iss/sub verified against the
# registered key, with that issuer's pinned alg only).

Or declare it directly in policy.yaml:

trusted_issuers:
  "https://idp.example.com": "trusted_issuers/idp.pem"   # EdDSA; relative to ~/.delcred
  "https://okta.example.com": {key: "trusted_issuers/okta.pem", alg: RS256}

Each issuer is pinned to exactly one algorithm and the key type must match it (checked when the policy loads). A token's own alg header never picks the algorithm: an RS256 token for an EdDSA issuer, or an HS256 token signed with an issuer's public key as the HMAC secret, is rejected.

Notes: the local issuer (iss: delcred) can never be shadowed by this registry; unknown issuers are rejected; a trusted token with kind: agent is still refused as a subject (no token laundering). Trusted IdPs vouch for users only: actor (agent) tokens and delegation tokens are accepted only from the local issuer, so an IdP cannot mint around your policy.

Library (5 lines)

import delcred

tok = delcred.delegate(scope="invoices:read",
                       resource="https://api.acme.test/v1",
                       user_token=user_jwt, agent_token=agent_jwt)
claims = delcred.verify(tok, expected_resource="https://api.acme.test/v1")

key = delcred.delegate_api_key(...)          # opaque dk_… credential
cap = delcred.verify_broker_key(key)         # redeem → capability record

delcred.revoke_agent("billing-agent", reason="...")  # kill switch
delcred.revoke_user("u_alice")                       # kill switch
delcred.revoke_token(jti)                            # single token

Agents should never see tokens at all. Run the sidecar; it mints, caches, and injects credentials for allowlisted upstreams:

delcred sidecar --port 8080 \
  --map 'api.acme.test=invoices:read|https://api.acme.test/v1' \
  --user-token-file /tmp/user.jwt --agent-token-file /tmp/agent.jwt
# agent calls http://localhost:8080 with X-Delcred-Upstream: api.acme.test
# sidecar injects: Authorization: Bearer <15-min delegation token>
#
# The sidecar's own identity can come from --user-token/--agent-token,
# --user-token-file/--agent-token-file, or $DELCRED_SIDECAR_USER_TOKEN /
# $DELCRED_SIDECAR_AGENT_TOKEN. Prefer files or env — command lines are
# visible in `ps`. The sidecar reads them once at startup into memory.

Or run the HTTP API: delcred serve --port 8400 (POST /exchange, /verify, /broker/redeem, /revoke, GET /health).

Policy (~/.delcred/policy.yaml)

Deny by default. A grant is the only thing that lets an exchange mint:

grants:
  - user: u_alice
    agent: billing-agent
    scopes: ["invoices:read"]
    resources: ["https://api.acme.test/v1"]  # exact match (RFC 8707)
    max_ttl: 900        # seconds; global hard cap is 3600
    single_use: false   # true → jti burned on first verify

Dry-run: delcred policy check --user u_alice --agent billing-agent --scope invoices:read --resource https://api.acme.test/v1

Security model

  • One algorithm per issuer. Everything delcred mints (user, agent and delegation tokens) is Ed25519 with strict algorithms=["EdDSA"], issuer pinned, typ: at+jwt on delegations. Trusted IdP subject tokens are verified with the single alg pinned to that issuer (EdDSA, RS256 or ES256). none/HS256/alg-swap confusion rejected.
  • Short lifetimes are the primary control: default 15 min, hard cap 60 min, clamped server-side no matter what the requester asks.
  • Confused-deputy defense: every token carries an RFC 8707 resource indicator; verifiers must check audience (delcred verify --resource).
  • Scope discipline: requested scopes must be ⊆ the grant; agents can never mint beyond their grant.
  • Revocation: per-token jti denylist + per-agent and per-user kill switches, checked on every verify. Single-use tokens burn on first verify.
  • Broker keys: only SHA-256 hashes stored; constant-time compare on redeem; uniform error messages (no key-existence oracle); every broker key is bound to its delegation JWT — revoking the JWT's jti kills the key too.
  • Hygiene: private keys 0600 (refuses to load otherwise), state dir 0700, fcntl-locked append-only JSONL, audit log never contains token/key values, token inputs via file/env (not ps-visible CLI args).
  • Trust boundary: agent identity tokens are operator-asserted — whoever controls the delcred home defines agent identities. Host access control is the identity root.

Limits up front (read before production)

Run delcred doctor first: a read-only check of home (0700) and issuer key (0600) permissions, policy syntax, grants (exact http(s) resource URLs, no * scopes, max_ttl within 3600, boolean single_use), trusted-issuer key files, and audit-log writability. Exit 0 = clean, 1 = issues, 2 = no home. It checks configuration only; it does not prove your grants are the right ones.

  1. Bearer tokens. Delegation JWTs and dk_… keys are bearer credentials: anyone holding one can use it until it expires. Mitigations shipped: 15-min default TTL, single-use option, resource pinning, instant local revocation. Sender-constrained tokens (DPoP/mTLS) are not in v1 — on the roadmap.
  2. Single-writer revocation. The denylist lives in one delcred home. There is no multi-host revocation sync in v1 — run one issuer per trust domain, or accept that a revocation on host A doesn't reach host B.
  3. Single-use semantics. The burn is atomic across processes and threads (check-and-set under an exclusive lock): exactly one concurrent verify or redeem wins, the rest are rejected. Don't use single-use as an exactly-once execution primitive — it bounds credential replay, not downstream effects.
  4. Local user assertions are dev-only. delcred user-token mints a self-asserted subject token. In production, register your IdP with delcred trust-add and pass its real user JWTs as subject_token — delcred verifies signature/issuer/expiry against the registered key, not your login flow. delcred is a token service, not an IdP.
  5. delcred serve binds localhost without auth. Put TLS + authentication in front before exposing it; anyone who can reach /exchange can mint within policy.
  6. External IdPs: one static key per issuer, no JWKS. EdDSA, RS256 and ES256 subject tokens are accepted (one alg pinned per issuer). Keys are PEM files you export; delcred does not fetch or rotate JWKS, so an IdP key rotation needs a fresh trust-add. Other algorithms (PS256, ES384, HS*) are rejected.
  7. No chained delegation. may_act (agent→sub-agent) is deferred to v2.
  8. Clock skew. 60s leeway is assumed; larger drift breaks verification.

Development

python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"
.venv/bin/python -m pytest tests/ -q

Layout: delcred/{tokens,keys,policy,exchange,revocation,broker,audit,cli,server,sidecar}.py

Made by Calas Automations (CAL-us). Need help? Call Cara 431-244-9026.

Metadata

Release files for delcred 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for delcred 0.2.3
File Size Uploaded Provenance Actions
delcred-0.2.3.tar.gz 51.7 kB Without provenance Details for delcred-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for delcred 0.2.3
File Interpreter ABI Platform Actions
delcred-0.2.3-py3-none-any.whl Python 3 none any Details for delcred-0.2.3-py3-none-any.whl

Total release size: 91.4 kB

Release files / delcred-0.2.3.tar.gz

Download URL delcred-0.2.3.tar.gz
Size 51.7 kB
Tags Source
SHA-256 checksum
How to use checksums
94a8357c11ffe299647a8e75e34fdde34b95021b9affe941d93847f70ad95155
BLAKE2b-256 checksum
How to use checksums
7608c4df24a69068003325f0ea609b1d78a770c434fb281762a189b67a4edc5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / delcred-0.2.3-py3-none-any.whl

Download URL delcred-0.2.3-py3-none-any.whl
Size 39.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb578073812ef89d212739a63711a2709af021854eeac0c867510f5574957974
BLAKE2b-256 checksum
How to use checksums
cc02220a573af687c7abdf18b08e819f7ec83cf683186f105d0995f32cde5cd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for delcred 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page