Core Concepts

Identity and Token Exchange / Delegation

PPE resolves the inbound caller and mints the outbound credential on every request.

Praxis Policy Engine v0.7.0 38 min read
On this page

PPE resolves the inbound caller and mints the outbound credential on every request. Select the recipe matching the required principal, copy its plugin and route configuration, then check the support matrix for tested IdPs.

The same config runs wherever you place it: in front of the tools, inside the tool server, or agent-side (see Where to place PPE). Throughout this page “the enforcement point” means “wherever this PPE instance runs.”

For the conceptual model first, read Use Cases and Deployment; for the full config schema, see Configuration.

The model in one picture

Every request crosses two identity boundaries:

Two identity boundaries. Inbound: identity.resolve validates credentials and fills typed identity slots, additively. Outbound: token.delegate mints the downstream credential, chosen per route by subject.

  • Inbound. identity.resolve plugins each read one credential (from a header, cookie, or query parameter) and land a typed identity in a slot. They are additive: one request can carry a user token and a workload SVID, both validated.
  • Outbound. A delegate(...) step in the route runs a token.delegate plugin that mints the credential attached to the upstream call. The step’s subject: chooses what the minted token speaks for.

Building blocks

Identity slots (inbound)

SlotPrincipalCredentialJWT role
subjectHuman userX-User-Tokenuser
clientCalling appAuthorizationclient
caller_workloadCalling serviceX-Workload-Tokencaller_workload

Each resolver reads from one wire location — header, cookie, or query parameter — named in the credential: block. See Configuration — Credential location.

Delegation and non-header credentials. Delegated tokens are attached to the upstream call as HTTP headers (Bearer tokens). When the inbound credential came from a cookie or query parameter, the delegator still mints a header-based outbound token. The inbound cookie or query parameter is not automatically stripped from the upstream request the way an inbound header is. Hosts that forward the raw request must handle this themselves.

Delegation subjects (outbound)

The subject: on a delegate(...) step decides the OAuth mechanism the delegator uses:

subject:Minted token speaks forMechanism
user (default)the human, on-behalf-ofRFC 8693 token exchange (subject_token = the user’s token)
caller_workloadthe calling agent, as itselfRFC 7523 client assertion (the SVID) → then scope down
this_workloadthe PPE instance’s own identity, as itself, no inbound credentialRFC 6749 §4.4 client_credentials

this_workload names this PPE instance acting as its own identity, whatever you’ve deployed it as. It does not claim PPE is a gateway. (gateway is accepted as a deprecated alias.)

“I want to…” → mechanism

I want to…UseSpec
act as a service with no usersubject: this_workload → client_credentialsRFC 6749 §4.4
act on behalf of a signed-in usersubject: user → token exchangeRFC 8693
let a workload authenticate as itself by its SVIDsubject: caller_workload → client assertionRFC 7523 + draft-ietf-oauth-spiffe-client-auth
record both the user and the calling agent in the tokensubject: user, actor: caller_workloadRFC 8693 actor_token
forward a token the caller already obtainedno delegate, pass the header through—
authenticate a caller holding an opaque API keyidentity/api-key → directory lookup—
require the agent to prove it holds the key its token is bound todpop on the trusted issuer, then Recipe 11RFC 9449

Scoping: how broadly to apply it

PPE resolves the pipeline for each request across one broad → narrow stack, and both identity and policy (including delegation) ride it. Narrower layers add to (or override) broader ones. Pick the broadest layer that’s still correct.

A group is a named, reusable bundle of policy (authentication steps + authorization steps + plugins) that routes opt into. The layers, broad to narrow:

LayerApplies toIdentity uses…Policy / delegation uses…
Globalevery requestglobal.authenticationalways-on global policy
Default (per entity type)every tool / prompt / resource—global.defaults.<tool|prompt|resource>
Grouproutes that join <name> (via groups: or a matching tag)groups.<name>.authenticationgroups.<name>.authorization / plugins
Route (entity)one route (a tool: "*" route is the catch-all)route authentication:route authorization: steps / plugins:

delegate(...) is not route-only. Place it (or a token.delegate plugin) at the matching layer:

  • every tool → a delegate() in a tool: "*" route, or the delegator plugin in defaults.tool,
  • a class of tools → a group,
  • one tool → a specific route (which overrides the * default; more specific wins).

The stack in one config

plugins:
  - name: jwt-user
    kind: identity/jwt
    hooks: [identity.resolve]
  - name: jwt-manager
    kind: identity/jwt
    hooks: [identity.resolve]
  - name: workday-oauth
    kind: delegator/oauth
    hooks: [token.delegate]

global:
  authentication: [jwt-user]            # every request gets user identity

groups:
  hr-tools:
    authentication: [jwt-manager]       # + manager identity for this group
    authorization:
      pre_invocation:
        - "require(role.hr)"            # + policy for this group

routes:
  - tool: get_compensation
    groups: hr-tools                    # join the group: jwt-user + jwt-manager, require(role.hr)
    authorization:
      pre_invocation:
        - "delegate(workday-oauth, target: workday-api, audience: workday-api, permissions: [read_compensation])"

groups: hr-tools is the first-class way to join a group, and it is sugar over tags: meta: { tags: [hr-tools] } is exactly equivalent, and host-injected runtime tags join groups the same way.

The override. A route that must stand alone drops the inherited layers:

plugins:
  - name: jwt-workload
    kind: identity/jwt
    hooks: [identity.resolve]

routes:
  - tool: get_directory
    authentication:
      replace_inherited: true           # ignore global + group layers
      steps: [jwt-workload]             # authenticate by the SVID alone

That is what Recipe 2 uses. (Full group / defaults syntax: Configuration.)

Rule of thumb

You want…Put it at
the same identity everywhereglobal authentication
a recurring identity/plugin set across many toolsa group
one route handled differently, standalonea route (authentication: replace_inherited for identity)
one delegation for most tools, exceptions for a fewa default (tool: "*" route or defaults.tool) + specific overrides

Recipes

Each recipe is a drop-in: the plugins it needs, the route layout, and where it’s been tested. All config is unified-config YAML.

One spelling. These recipes write policy under authorization:, with pre_invocation: and post_invocation: inside it. That is now the only spelling. The apl: wrapper is gone at every scope, and a phase list written flat on a route is a load error. Both were accepted once; see Upgrading APL for the rewrite.

Recipe 1: User acting through an agent (on-behalf-of)

When: a human is signed in; the agent calls a downstream API as that user. PPE exchanges the user’s IdP token for a downstream-audience token.

plugins:
  - name: jwt-user
    kind: identity/jwt
    hooks: [identity.resolve]
    config:
      role: user
      credential:
        kind: header
        name: X-User-Token
      trusted_issuers:
        - issuer: "https://idp.example.com/realms/corp"
          audiences: ["ppe"]        # the audience the user token is minted for
          algorithms: ["RS256"]
          decoding_key: { kind: jwks_url, url: "https://idp.example.com/realms/corp/protocol/openid-connect/certs" }

  - name: workday-oauth
    kind: delegator/oauth
    hooks: [token.delegate]
    capabilities: [read_inbound_credentials, write_delegated_tokens]
    config:
      token_endpoint: "https://idp.example.com/realms/corp/protocol/openid-connect/token"
      client_id: "ppe"              # this PPE instance's own OAuth client
      client_secret_source: { kind: env_var, name: IDP_CLIENT_SECRET }

global:
  authentication: [jwt-user]

routes:
  - tool: get_compensation
    authorization:
      pre_invocation:
        - "require(role.hr)"
        - "delegate(workday-oauth, target: workday-api, audience: workday-api, permissions: [read_compensation])"

The minted workday-api token is attached to the upstream call. Tested: Keycloak 26.x (Standard Token Exchange v2).

Recipe 2: Agent acting as itself, by its SPIFFE SVID

When: the agent is the principal (no human), and you don’t trust the agent to hold downstream authority. The agent presents its SVID; PPE brokers a scoped downstream token. The agent holds no standing entitlement to the target.

The SVID is a JWT, but not an IdP token. A JWT-SVID is an ES256 JWT signed by SPIRE (validated against SPIRE’s JWKS, not your IdP’s): a SPIFFE identity credential, not an OAuth access token. It can’t be forwarded to the downstream or used as a bearer/subject token as-is; PPE must turn it into an IdP-issued token first (leg 1 below). Contrast Recipe 5, whose input is a token already minted from an SVID.

Add a workload resolver, scoped to the route so only it runs there:

plugins:
  - name: jwt-workload
    kind: identity/jwt
    hooks: [identity.resolve]
    on_error: fail
    config:
      role: caller_workload
      credential:
        kind: header
        name: X-Workload-Token
      trusted_issuers:
        - issuer: "https://spire-oidc.internal:8443"   # SPIRE OIDC discovery
          audiences: ["https://idp.example.com/realms/corp"]   # SVID aud = the IdP
          algorithms: ["ES256"]                                # SVIDs are EC-signed
          decoding_key: { kind: jwks_url, url: "https://spire-oidc.internal:8443/keys" }

routes:
  - tool: get_directory
    # Authenticate this route by the SVID alone: drop the global user/client
    # resolvers. `jwt-workload` is NOT in global.authentication.
    authentication:
      replace_inherited: true
      steps: [jwt-workload]
    authorization:
      pre_invocation:
        - "delegate(workday-oauth, target: workday-api,
                    audience: workday-api,
                    permissions: [read_compensation],
                    subject: caller_workload)"
        - "!delegation.granted: deny"

For subject: caller_workload, the OAuth delegator runs two legs: leg 1 presents the SVID as an RFC 7523 client_assertion (type …:jwt-spiffe) to authenticate the agent as its IdP client; leg 2 exchanges that for the scoped downstream token. The IdP side needs a SPIFFE identity provider (validates the SVID against SPIRE’s trust bundle) and a client bound to that SVID via SPIFFE/federated client authentication; consult your IdP’s SPIFFE client-auth docs. Tested: Keycloak 26.6 (feature spiffe:v1).

Why route-scope it: keeping the workload authority off the agent’s own identity, and requiring the enforcement point’s credential for the scope-up, is what makes PPE the trust boundary. A compromised agent can prove who it is but cannot mint the downstream token itself.

Recipe 3: A service acting as itself

When: PPE calls a downstream as itself, with no inbound credential to exchange (e.g. a scheduled job, or PPE’s own housekeeping).

routes:
  - tool: sync_directory
    authorization:
      pre_invocation:
        - "delegate(svc-oauth, target: workday-api, audience: workday-api, subject: this_workload)"

subject: this_workload switches the delegator to client_credentials: no subject_token, PPE’s own client_id/secret is the identity. Tested: Keycloak (client_credentials).

Recipe 4: Forward a token the caller already has (passthrough)

When: the agent authenticated to the IdP itself and hands PPE a ready token. PPE validates it inbound and lets the route forward it, with no delegate step. This is the “agent-brokered” case; it needs no delegation code, only that the inbound resolver validates the token and the route allows the call.

Recipe 5: Scope a token the agent already holds (1-leg)

When: the agent authenticated to the IdP itself with its SVID and got back a normal JWT, and you still want PPE to narrow that token per-tool (least privilege at the boundary) without ever handling the SVID.

The token is not the SVID. The agent presented its SVID as a client_assertion upstream and received an ordinary IdP access token. That token arrives here like a user token: same header, same JWKS validation, RS256 (an IdP-signed JWT), not the ES256 SVID. PPE never sees the SVID; it sees a normal token.

plugins:
  - name: jwt-agent
    kind: identity/jwt
    hooks: [identity.resolve]
    config:
      role: client                 # the agent as an OAuth client
      credential:
        kind: header
        name: Authorization        # a normal bearer token, NOT X-Workload-Token
      trusted_issuers:
        - issuer: "https://idp.example.com/realms/corp"
          audiences: ["ppe"]
          algorithms: ["RS256"]    # an IdP-issued JWT, not the ES256 SVID
          decoding_key: { kind: jwks_url, url: "https://idp.example.com/realms/corp/protocol/openid-connect/certs" }
routes:
  - tool: get_directory
    authorization:
      pre_invocation:
        - "delegate(workday-oauth, target: workday-api,
                    audience: workday-api,
                    permissions: [read_compensation],
                    subject: client)"

This is a plain RFC 8693 exchange, the same engine as Recipe 1, scoping the agent’s token instead of a user’s. One leg (the scope): the agent did the authenticate leg upstream, so PPE doesn’t.

Don’t confuse this with Recipe 2. The trigger is what the agent presents: an SVID, or a token minted from one:

Agent presentsSlot → subjectPPE doesLegs
its SVID (ES256, SPIRE JWKS)caller_workload → subject: caller_workloadauthenticate + scope2 (Recipe 2)
a token minted from its SVID (RS256, IdP JWKS)client → subject: clientscope only1 (this recipe)
a token already right for the tool—forward as-is0 (Recipe 4)

Using subject: caller_workload on an already-minted token misroutes it down the two-leg client_assertion path.

Recipe 6: User acting through an agent, with the agent named (dual-principal)

When: a human is signed in and you want the record to name the agent that carried out the call. The minted token speaks for the user (sub), and PPE additionally names the calling agent as the RFC 8693 acting party (act), so a token service that honors delegation records both who authorized the action and who performed it.

It composes two inbound resolvers: jwt-user (Recipe 1) for the human on X-User-Token, and jwt-workload (Recipe 2) for the agent’s SVID on X-Workload-Token. Both must resolve; both credentials arrive on every call.

plugins:
  - name: jwt-user            # Recipe 1
    kind: identity/jwt
    hooks: [identity.resolve]
  - name: jwt-workload        # Recipe 2
    kind: identity/jwt
    hooks: [identity.resolve]
  - name: workday-oauth
    kind: delegator/oauth
    hooks: [token.delegate]

global:
  authentication: [jwt-user, jwt-workload]   # run both

routes:
  - tool: get_compensation
    authorization:
      pre_invocation:
        - "require(role.hr)"
        - "delegate(workday-oauth, target: workday-api, audience: workday-api,
                    permissions: [read_compensation],
                    subject: user, actor: caller_workload)"

subject: user makes the user’s token the RFC 8693 subject_token (exactly as Recipe 1); actor: caller_workload additionally attaches the agent’s SVID as the actor_token, requesting that the minted token carry act alongside sub. This is one exchange call with two principals in the request, not a second leg. actor accepts only inbound credentials (user, client, caller_workload): the acting party is by definition one that presented itself to PPE.

Subject vs. actor. The subject is who the token speaks for (whose authority); the actor is who is doing it (attribution). Least-privilege scoping still follows the subject. The act claim records the agent, it doesn’t grant it anything.

Which actor, client or caller_workload? Match it to how the agent authenticated. An agent that presented a SPIFFE SVID is a caller_workload (above); one that authenticated as a registered OAuth client (an Authorization bearer token, resolved with role: client) is actor: client:

- "delegate(workday-oauth, target: workday-api, audience: workday-api,
            permissions: [read_compensation], subject: user, actor: client)"

Valid combinations. actor: pairs with subject: user or subject: client, the on-behalf-of shape. It is not supported with subject: caller_workload (the workload is already the subject) or subject: this_workload (a client_credentials grant carries no actor_token); PPE rejects those at config time rather than silently dropping the actor.

PPE side: implemented and e2e-tested against a mock IdP. The delegator puts the actor on the wire exactly as RFC 8693 delegation prescribes (actor_token + actor_token_type), and omits it when no actor is configured.

Interop: act is the token service’s job (impersonation vs. delegation). RFC 8693 (§1.1) exchanges come in two flavors. Impersonation returns a token that speaks purely for the subject, indistinguishable from one the subject fetched directly, with no act claim. Delegation additionally records the actor in a nested act. The actor_token parameter is what asks for delegation; only a token service that implements the delegation path emits act. PPE always sends the delegation request, but the claim only appears if the service honors it.

Keycloak’s Standard Token Exchange (v2, tested here on 26.6) does not: it implements impersonation only, silently ignores actor_token, and returns a subject-only token with no act. The tell (probed 2026-07-28): passing even a raw, untrusted-issuer SVID as the exchange’s actor_token produces no error.

Keycloak 26.8 adds delegation as a preview feature (token-exchange-delegation), and it changes that outcome for this recipe. It takes over any exchange carrying an actor_token, requires the actor token to be an access token from the same realm, and requires the subject token to name the actor in a may_act claim (details). A raw SVID is not a realm token, so with that feature on, this recipe’s exchange is refused rather than the actor being ignored. Against Keycloak, capture the acting agent at the PPE boundary (audit / downstream header) instead. PPE resolves both principals either way.


Recipe 7: An opaque API key, resolved against a directory

Use identity/api-key when a caller presents an opaque key. The resolver looks up its record and maps fields into the same identity attributes as identity/jwt.

File directory:

plugins:
  - name: api-keys
    kind: identity/api-key
    hooks: [identity.resolve]
    config:
      credential:
        kind: header
        name: X-API-Key
      provider:
        kind: file
        path: /etc/ppe/keys.yaml
        refresh_secs: 30
        max_staleness_secs: 300
      record_map:
        subject:
          id: user
          roles: groups

global:
  authentication: [api-keys]

The file stores SHA-256 digests, not plaintext keys. Use high-entropy keys to resist offline guessing if the file leaks:

keys:
  - hash: "sha256:59ecf12ac9ef5ee967ddd8aa324f39c7fe13f2a54fb76e3e69bc866887cff903"
    user: alice
    groups: [reader, writer]
    tenant: acme
    expires_at: 2027-01-01T00:00:00Z

Generate a digest with printf %s "$KEY" | sha256sum and add the sha256: prefix.

HTTP directory: This example uses the RHOAI MaaS maas-api validate endpoint.

plugins:
  - name: maas-keys
    kind: identity/api-key
    hooks: [identity.resolve]
    capabilities: [perform_http]
    config:
      credential:
        kind: header
        name: Authorization
      prefix: "Bearer sk-oai-"
      provider:
        kind: http
        url: "https://maas-api.example.com/internal/v1/api-keys/validate"
        timeout_secs: 5
      record_map:
        subject:
          id: username
          roles: groups
      claims:
        exclude: [userId, keyId, keyName]
      cache:
        ttl_secs: 60
        negative_ttl_secs: 10

global:
  authentication: [maas-keys]

maas-api sets both userId and keyId to the key’s database row ID. Map username to subject.id instead. A captured response uses a Kubernetes service account name (system:serviceaccount:example-tenant:example-consumer) and Kubernetes groups. These are subject values; caller_workload requires a SPIFFE ID.

Group names containing : cannot be used in attribute paths such as role.system:authenticated. Use the canonical set:

require(subject.roles contains "system:authenticated")

An invalid key returns HTTP 200 with valid: false; a failed directory request denies as auth.directory_unavailable. In prefix: "Bearer sk-oai-", the Bearer scheme is matched without case and removed. The sk-oai- prefix stays in the key sent to the directory. To accept several key populations on one route, configure a resolver for each prefix; nonmatching resolvers skip their directory lookup.

The presented key is not stored in raw_credentials for downstream forwarding. Use secret.<name> on an assertion to authenticate to an upstream.

Denial codes

CodeMeans
auth.missing_credentialnothing at the configured location
auth.empty_credentialthe location held an empty value
auth.key_unknownthe directory answered, and no record matched
auth.key_expireda record matched and has expired
auth.directory_unavailablethe directory could not answer
auth.mapping_faileda record resolved and the map could not project it

The revocation window

A revoked key may still authenticate until the file’s next successful reload (refresh_secs) or the HTTP cache entry expires (cache.ttl_secs). If a file reload fails, old records remain in use until max_staleness_secs; after that, lookups deny as auth.directory_unavailable. A cache cannot be configured over a file directory.

The MaaS mapping was checked against a captured valid response on 2026-09-24. HTTP error handling follows the maas-api source; error responses were not captured from the deployment.


Recipe 8: A user’s Vault-stored credential

Use delegator/vault when each user has enrolled a downstream PAT or API key and PPE should retrieve it only for an authorized call. The isolation boundary is Vault policy, not path naming alone.

Enable Vault JWT auth, bind the role to the same issuer and audience PPE accepts, and note the auth mount accessor:

vault auth enable jwt
vault write auth/jwt/config \
  oidc_discovery_url=https://idp.example.com/realms/corp \
  bound_issuer=https://idp.example.com/realms/corp
vault auth list -format=json

Replace <jwt-mount-accessor> below with the jwt/ accessor returned by vault auth list. The KV v2 policy path must contain data/; the PPE plugin path must not.

path "secret/data/agents/{{identity.entity.aliases.<jwt-mount-accessor>.name}}/*" {
  capabilities = ["read"]
}

Save the policy as ppe-user.hcl, install it, create the role, and enroll Alice’s GitHub token at the corresponding logical path:

vault policy write ppe-user ppe-user.hcl
vault write auth/jwt/role/ppe-user role_type=jwt \
  bound_audiences=ppe user_claim=sub policies=ppe-user ttl=5m
vault kv put -mount=secret agents/alice/github token=ghp_xxx
plugins:
  - name: github-vault
    kind: delegator/vault
    hooks: [token.delegate]
    capabilities:
      - perform_http
      - read_inbound_credentials
      - read_subject
      - read_claims
      - write_delegated_tokens
    config:
      vault_addr: "https://vault.example.com:8200"
      kv_mount: secret
      secret_path_template: "agents/{{identity}}/github"
      secret_field: token
      outbound_header: Authorization
      scheme_prefix: "token "
      auth:
        user:
          method: jwt
          identity_claim: sub
          mount: jwt
          role: ppe-user

routes:
  - tool: create_github_issue
    authorization:
      pre_invocation:
        - "require(authenticated)"
        - "delegate(github-vault, target: github-api, audience: https://api.github.com, subject: user)"

identity_claim must name a stable, issuer-asserted principal. sub is the usual choice. Do not use a mutable display name, email address, request label, or session id. The Vault role’s user_claim and PPE’s identity_claim must resolve to the same path component.

Recipe 9: A caller workload’s Vault-stored credential

A workload can use the same model with its JWT-SVID. Configure the Vault JWT role’s user_claim to the SPIFFE claim your issuer provides, bind its audience, and attach an identity-templated policy to that role. If the alias name is spiffe://example.com/agent, enroll at the exact logical path, including its slashes:

vault auth enable -path=jwt-spiffe jwt
vault write auth/jwt-spiffe/config \
  oidc_discovery_url=https://spire-oidc.internal:8443 \
  bound_issuer=https://spire-oidc.internal:8443
vault auth list -format=json

Use the jwt-spiffe/ mount accessor in the workload policy:

path "secret/data/agents/{{identity.entity.aliases.<jwt-spiffe-mount-accessor>.name}}/*" {
  capabilities = ["read"]
}
vault policy write ppe-workload ppe-workload.hcl
vault write auth/jwt-spiffe/role/ppe-workload role_type=jwt \
  bound_audiences=vault user_claim=sub policies=ppe-workload ttl=5m
vault kv put -mount=secret agents/spiffe://example.com/agent/github token=ghp_xxx
plugins:
  - name: jwt-workload
    kind: identity/jwt
    hooks: [identity.resolve]
    capabilities: [perform_http]
    config:
      role: caller_workload
      credential:
        kind: header
        name: X-Workload-Token
      trusted_issuers:
        - issuer: "https://spire-oidc.internal:8443"
          audiences: ["vault"]
          algorithms: [ES256]
          decoding_key:
            kind: jwks_url
            url: "https://spire-oidc.internal:8443/keys"

  - name: workload-github-vault
    kind: delegator/vault
    hooks: [token.delegate]
    capabilities:
      - perform_http
      - read_inbound_credentials
      - read_workload
      - write_delegated_tokens
    config:
      vault_addr: "https://vault.example.com:8200"
      secret_path_template: "agents/{{identity}}/github"
      outbound_header: Authorization
      scheme_prefix: "token "
      auth:
        caller_workload:
          method: jwt
          identity_claim: spiffe_id
          mount: jwt-spiffe
          role: ppe-workload

routes:
  - tool: create_github_issue
    authentication:
      replace_inherited: true
      steps: [jwt-workload]
    authorization:
      pre_invocation:
        - "delegate(workload-github-vault, target: github-api, audience: https://api.github.com, subject: caller_workload)"

The caller-workload JWT-SVID is sent to Vault as the login JWT. A single Vault delegator may contain separate user, client, and caller_workload auth entries; each entry selects its own identity_claim, mount, and role. In this example Vault’s JWT alias comes from the SVID’s sub, while PPE’s validated workload slot exposes the same value as spiffe_id.

Recipe 10: A shared credential owned by this workload

For a legacy backend that has one credential owned by this PPE deployment, use AppRole and a fixed path. Keep the role and secret IDs in environment variables or mounted secret files rather than policy YAML. Save this policy as ppe-legacy.hcl:

path "secret/data/shared/legacy-api" {
  capabilities = ["read"]
}
vault auth enable approle
vault policy write ppe-legacy ppe-legacy.hcl
vault kv put -mount=secret shared/legacy-api api_key=replace-me
vault write auth/approle/role/ppe-legacy policies=ppe-legacy token_ttl=5m
vault read auth/approle/role/ppe-legacy/role-id
vault write -f auth/approle/role/ppe-legacy/secret-id
plugins:
  - name: legacy-vault
    kind: delegator/vault
    hooks: [token.delegate]
    capabilities: [perform_http, write_delegated_tokens]
    config:
      vault_addr: "https://vault.example.com:8200"
      secret_path_template: shared/legacy-api
      secret_field: api_key
      outbound_header: X-API-Key
      auth:
        this_workload:
          method: approle
          mount: approle
          role_id_source: { kind: env_var, name: VAULT_ROLE_ID }
          secret_id_source: { kind: file, path: /var/run/secrets/vault/secret-id }

routes:
  - tool: legacy_lookup
    authorization:
      pre_invocation:
        - "delegate(legacy-vault, target: legacy-api, subject: this_workload)"

Omitting scheme_prefix deliberately produces the bare X-API-Key value.

Vault delegator configuration

FieldMeaning / default
vault_addrRequired Vault base URL. HTTPS is required unless insecure_http: true.
kv_mountKV v2 mount; default secret.
secret_path_templateRequired logical KV path. {{identity}} is mandatory when any caller-scoped auth entry is configured. Do not include the KV v2 data/ segment.
secret_fieldString field containing the downstream credential; default token.
outbound_headerHeader used by the downstream transport; default Authorization.
scheme_prefixOptional exact prefix the host prepends when constructing the outbound header value, such as "token " or "Bearer ". Unset means bare.
timeout_secondsTimeout for each Vault request; default 5.
insecure_httpPermit http:// for development; default false.
auth.<subject>One entry for each allowed user, client, caller_workload, or this_workload subject. Missing entries deny.
auth.*.methodjwt or approle.
auth.*.identity_claimPrincipal claim/field substituted for {{identity}}; required for a templated path.
auth.*.mountAuth mount; defaults to jwt or approle.
auth.*.roleVault role for JWT auth.
auth.*.role_id_source, secret_id_sourceAppRole credential sources: env_var, file, or development-only literal.
cache.enabledReuse a resolved credential; default false.
cache.ttl_secondsReread interval and host-side delegated-token expiry bound; default 300.
cache.max_entriesMaximum entries when enabled; default 10000.

Praxis host compatibility: RawDelegatedToken carries the exact outbound_prefix, and this repository’s reference host honors it. The separately maintained Praxis proxy filter currently hard-codes Bearer when attaching delegated tokens. Bare values and prefixes such as token are therefore deferred until that consumer reads outbound_prefix; do not deploy those configurations through the Praxis filter yet.

Vault delegation denial codes

CodeMeaning
delegation.vault_auth_unconfiguredNo usable auth entry exists for the selected subject.
delegation.vault_auth_failedVault rejected login or returned a malformed login response.
delegation.identity_missingThe configured identity claim/field was unavailable.
delegation.identity_invalidThe resolved identity was unsafe for a path.
delegation.unsupported_subjectThe subject variant is unsupported.
delegation.actor_unsupportedStatic credentials cannot record an actor.
delegation.attenuation_unsupportedA stored credential cannot honor route attenuation.
delegation.permissions_unsupportedA stored credential cannot prove requested permissions.
delegation.bad_requestRequired request or credential input was absent or invalid.
delegation.no_transportThe host installed no HTTP transport.
delegation.vault_timeoutA Vault request timed out.
delegation.vault_unreachableVault could not be reached.
delegation.vault_forbiddenVault denied the KV read.
delegation.vault_secret_not_foundNo secret exists at the resolved path.
delegation.vault_field_missingThe configured field was absent or not a string.
delegation.vault_revoke_failedPPE could not revoke the temporary login token; delegation fails closed.
delegation.vault_errorVault returned another error or an invalid response.

Vault revocation window

After every KV read attempt, successful or failed, PPE calls Vault auth/token/revoke-self. Revocation is armed before the KV request, so task cancellation also releases an independent, single-request cleanup operation. If an awaited revocation fails, PPE returns no downstream credential. This bounds the lifetime of the temporary Vault login token; it does not revoke the PAT or API key stored in KV.

With caching enabled, cache.ttl_seconds is the maximum interval before PPE rereads Vault, so a rotated or deleted KV value may remain in memory until that TTL expires. The same TTL supplies RawDelegatedToken.expires_at, including when caching is disabled. That timestamp is a PPE/host handling bound, not evidence that the static downstream credential expires at its provider.

Recipe 11: An agent with a DPoP-bound token

When: the agent’s own credential should be useless to anyone who copies it, from a log, a proxy, or a compromised service in between.

What DPoP is. An ordinary access token is a bearer token: whoever holds it can use it. DPoP binds the token to a key pair the agent holds. When the agent requests the token, the IdP records the public key’s thumbprint in the token (cnf.jkt). On every call the agent then sends, in a DPoP header, a short proof signed with the private key, naming the HTTP method and URL, the time, a unique id, and a hash of the token. PPE checks the proof against the key the token names, so a copied token is useless without the private key, and a copied proof is useless for any other request, after a minute, or a second time. The key belongs to the agent’s application, not to a person. Binding tokens to the caller’s key lists every check, setting and denial code.

What changes compared with the other options:

Bearer token (Recipes 1, 3)DPoP-bound token (this recipe)SPIFFE SVID (Recipe 2)
A copied credential works for someone elseyes, until it expiresno, it needs the private keyyes, until it expires
What PPE checks on each callsignature, expiry, audiencethe same, plus a proof for this exact requestthe same, against SPIRE’s keys
PPE can exchange it downstream (RFC 8693)yesno: only the client it was issued to can, with its keynot directly; PPE uses it as a client assertion first
What policy can requireclient.*, subject.*also client.key_binding == 'dpop'caller_workload.*

The third row is the one that shapes the configuration. PPE verifies the agent’s bound token on the way in, but cannot pass it on in a token exchange, so the downstream token has to come from something else. There are two ways.

Acting for a user. The agent sends two tokens: its own DPoP-bound token in Authorization, with a proof in the DPoP header, and the signed-in user’s token, an ordinary bearer token, in X-User-Token. They go to different places:

  1. jwt-agent verifies the agent’s token and its proof, and fills the client slot, including client.key_binding. The agent’s token goes no further.
  2. jwt-user verifies the user’s token, fills the subject slot, and keeps the raw token for delegation.
  3. delegate(..., subject: user) sends the user’s token to the IdP as the RFC 8693 subject_token, authenticating as PPE’s own client (ppe).
  4. The IdP returns a workday-api token for the user, and PPE attaches it to the call to the tool.

PPE is the client that requests the downstream token, the user is who it speaks for (sub), and the agent does not appear in it.

plugins:
  - name: jwt-agent
    kind: identity/jwt
    hooks: [identity.resolve]
    capabilities: [perform_http, read_headers]   # read_headers: the proof names the request line
    config:
      role: client
      credential:
        kind: header
        name: Authorization
      trusted_issuers:
        - issuer: "https://idp.example.com/realms/corp"
          audiences: ["ppe"]
          algorithms: ["RS256"]
          decoding_key: { kind: jwks_url, url: "https://idp.example.com/realms/corp/protocol/openid-connect/certs" }
          dpop: { mode: required }               # the agent's token must be bound

  - name: jwt-user
    kind: identity/jwt
    hooks: [identity.resolve]
    capabilities: [perform_http]
    config:
      role: user
      credential:
        kind: header
        name: X-User-Token
      trusted_issuers:
        - issuer: "https://idp.example.com/realms/corp"   # same IdP, its own settings: no dpop
          audiences: ["ppe"]
          algorithms: ["RS256"]
          decoding_key: { kind: jwks_url, url: "https://idp.example.com/realms/corp/protocol/openid-connect/certs" }

  - name: workday-oauth
    kind: delegator/oauth
    hooks: [token.delegate]
    capabilities: [perform_http, read_inbound_credentials, write_delegated_tokens]
    config:
      token_endpoint: "https://idp.example.com/realms/corp/protocol/openid-connect/token"
      client_id: "ppe"
      client_secret_source: { kind: env_var, name: IDP_CLIENT_SECRET }

global:
  authentication: [jwt-agent, jwt-user]

routes:
  - tool: get_compensation
    authorization:
      pre_invocation:
        - "require(role.hr)"
        # subject: user (the default, written out): exchange the user's token
        # from X-User-Token. The agent's bound token cannot be exchanged.
        - "delegate(workday-oauth, target: workday-api, audience: workday-api, permissions: [read_compensation], subject: user)"

Each resolver has its own issuer settings, so one IdP can be trusted with DPoP for the agent’s token and without it for the user’s. The proof is checked against the token in the agent resolver’s own header, so the user resolver never reads it.

This works only while the user’s token is not itself bound to the agent’s key. DPoP binds a token to whichever application requested it, so if the agent obtained the user’s token through its own DPoP-bound client, that token is bound too, PPE cannot exchange it, and only the second option remains. The user’s token is also still a bearer token: the binding protects the agent’s credential, not the user’s. Naming the agent as the actor in the exchange (Recipe 6) does not help here, because the IdP checks the actor token’s binding and only the agent can prove it.

Acting as itself. With no user, PPE gets the downstream token on its own credential, as in Recipe 3, after verifying the agent. With the plugins above, a route for it:

routes:
  - tool: sync_directory
    authentication:
      replace_inherited: true
      steps: [jwt-agent]                         # the agent alone, no user token
    authorization:
      pre_invocation:
        - "delegate(workday-oauth, target: workday-api, audience: workday-api, subject: this_workload)"

Here PPE requests the downstream token with client_credentials on its own client, and the token speaks for PPE (sub is PPE’s service account). Neither the agent’s token nor any user token is sent to the IdP.

In both variants the agent is verified on the way in and governed by policy, but it is not named in the downstream token, because its bound token is the one credential PPE cannot pass on. A tool that needs to know which agent called has to be told separately, for example with an assertion built from the agent’s verified identity.

Requiring the binding per route. With mode: required, every token from that issuer is already bound when policy runs, so a route needs nothing more. During a rollout, mode: optional lets bearer tokens through, and a route can still insist on a bound token for its own calls:

client.key_binding == 'dpop'

Used as require(client.key_binding == 'dpop'), it denies a bearer token, because client.key_binding is set only after a proof verifies.

Tested: inbound verification against Keycloak 26.8 (dpop_live, see Testing); the delegation legs are those of Recipes 1 and 3.

Reading claims the way your IdP writes them

The JWT identity plugin infers a subject from a token’s claims. Which claims, and where they sit, differs by IdP, so the mapping is configuration rather than something to patch a crate for.

Name one of the five shipped presets:

claim_mapper: keycloak       # standard | keycloak | auth0 | cognito | ibmverify

Or write the map inline, with candidate paths tried in order:

claim_map:
  subject:
    roles:
      paths:
        - realm_access.roles
        - resource_access.my-api.roles
      merge: union             # first_match (default) | union
    permissions:
      paths:
        - { path: permissions, array_only: true }
        - scope
      split: whitespace        # break a delimited string into elements
      on_missing: deny         # ignore (default) | deny

. separates path segments and \ escapes one; every other character, : and / included, is a literal. cognito:groups is one segment written plainly, and escaping the colon is rejected rather than quietly accepted. A field whose candidates all miss is left empty and logged, naming every path tried; on_missing: deny makes that a refusal instead.

Each preset records what it omits. The Keycloak preset maps realm_access.roles; roles under resource_access.<client-id>.roles require a custom map because the client ID varies by deployment. Auth0 roles also require a custom map because their namespace is deployment-specific. Presets leave fields empty rather than assign the wrong concept: Keycloak’s groups can contain realm roles, and Cognito’s cognito:roles contains IAM role ARNs. The ibmverify preset accepts scalar or array values for tenant-provisioned roles, teams, permissions, client roles, and authorized scopes. Verify can emit a scalar when one value is present; the standard preset reads these collections as arrays and would leave a scalar value empty.

Naming no mapper resolves to standard, so an existing configuration is unaffected.

Gating on which IdP minted a token

Registered claims are dropped from the policy-visible bag by default. That left a deployment trusting several issuers unable to gate on which one signed. claims: overrides that, and is a sibling of both the preset and the inline map:

claim_mapper: keycloak
claims:
  include: [iss]               # keep one the inference drops
  exclude: [internal_debug]    # drop an otherwise-visible claim

claim.iss is then readable from policy. Both lists take top-level claim names, since the bag is keyed by name: a dotted entry is refused at load rather than matching nothing, and a claim whose own name holds a dot is written with \.. A role: caller_workload resolver carries no claims bag and says so at load rather than ignoring the setting.

Binding tokens to the caller’s key (DPoP)

The reference for DPoP (RFC 9449) in identity/jwt: settings, checks, the policy view, denial codes and limits. For what DPoP is, how it compares with bearer tokens and SVIDs, and how to delegate when the caller’s token is bound, start with Recipe 11.

Turn it on per trusted issuer. The plugin must hold read_headers, because the proof is checked against the request line; without it the plugin refuses to load.

- name: jwt-agent
  kind: identity/jwt
  capabilities: [perform_http, read_headers]
  config:
    trusted_issuers:
      - issuer: https://idp.example.com/realms/agents
        audiences: [gateway]
        algorithms: [RS256]
        decoding_key: { kind: jwks_url, url: https://idp.example.com/realms/agents/protocol/openid-connect/certs }
        dpop:
          mode: required            # off (default) | optional | required
          algorithms: [ES256]       # proof algorithms; asymmetric only
          iat_window_seconds: 60    # how old or early a proof may be (max 300)
          # external_base_url: https://api.example.com   # behind a proxy
ModeUnbound tokenBound token (cnf.jkt)
offaccepted as beareraccepted as bearer; the DPoP scheme is refused
optionalaccepted as bearerneeds the DPoP scheme and a valid proof
requireddeniedneeds the DPoP scheme and a valid proof

A bound token presented with the Bearer scheme is denied in either checking mode, as RFC 9449 requires, even if a proof is attached. So is a token whose cnf carries no usable jkt, such as one bound to a certificate: it is bound in a way this check cannot verify, and accepting it as a bearer token would drop the binding.

With mode: off the binding is not checked at all, and a bound token presented as Bearer is accepted like any other. A token stolen from a client of a DPoP-checking issuer therefore works without its key wherever the same issuer is trusted with off. Turn checking on for every entry of an issuer whose tokens are bound.

The proof is checked for: type dpop+jwt; an accepted algorithm; a public key in its header, with no private members; that key’s RFC 7638 thumbprint equal to cnf.jkt; its signature; htm equal to the request method; htu equal to the request URL (scheme and host compared case-insensitively, default port, query and fragment ignored); iat within the window; ath equal to the token’s hash; and a jti not seen before.

Behind a proxy that changes the scheme, host or port, set external_base_url to the URL clients address; htu is then compared against it plus the request path. Without it the URL is rebuilt from the host’s request scheme, host and path, and a host that supplies neither denies every bound token.

A verified binding is recorded on the identity the token filled, so a route can require it for one credential and not another:

subject.key_binding == 'dpop'

subject.key_binding (client.key_binding, caller_workload.key_binding) names the proof method, and …_thumbprint what the token is bound to: for dpop, the RFC 7638 thumbprint of the key. The method is the only one today; the value is an open name so a certificate-bound method can follow, and its thumbprint would be the certificate’s, so compare a thumbprint together with the method:

subject.key_binding == 'dpop' & subject.key_binding_thumbprint in data.agents.approved_keys

The thumbprint is not a secret. It is a hash of a public key that travels in every proof, so it is safe to log, and it is the stable handle for pinning an agent to registered keys, blocking a leaked key, or correlating requests across token refreshes. Treat it like subject.id for retention: it identifies the key’s holder. Both are absent for a token accepted without a proof, including a token whose cnf was never checked because the issuer’s mode is off. cnf.jkt itself reaches policy as claim.cnf.jkt, but that is the issuer’s statement, not proof that the caller holds the key.

DPoP denial codes

CodeMeans
auth.dpop_missinga bound token without a proof, a bound token sent without the DPoP scheme, or an unbound token where binding is required
auth.dpop_invalida malformed proof or one failing a check above, a cnf with no usable jkt, or the DPoP scheme to an issuer with mode: off
auth.dpop_key_mismatchthe proof is signed by a key other than the one the token is bound to
auth.dpop_replaythe proof’s jti was already used
auth.dpop_replay_unavailablethe replay store could not answer, or this key already has its quota of live proofs; the proof is not accepted unchecked
auth.config_errorthe host supplied no request line, method, or path, or no scheme and host with no external_base_url set

The replay window

The default factory remembers each accepted jti in this gateway instance’s memory for twice the iat window plus one second after first use (121 seconds with the default window). This also covers a proof first seen near the end of one gateway’s window and later seen by a gateway whose clock is behind. It holds at most 10,000 live proofs per key and 100,000 in all. Rebuilding the resolver starts a fresh store. Use this default only for a single instance.

For several instances, the embedding host must register a factory with a shared replay guard. With the jwt and valkey features, the host can pass its existing deadpool_redis::Pool to ValkeyReplayGuard. Register this factory after install_builtins, if the host uses that helper:

use std::sync::Arc;
use praxis_policy_builtins::plugins::identity_jwt::{
    JwtIdentityFactory, KIND,
    dpop_valkey::ValkeyReplayGuard,
};

// `pool` is a host-owned deadpool_redis::Pool for the shared Valkey database.
let guard = Arc::new(ValkeyReplayGuard::new(pool, "dpop:replay:v1"));
engine.register_factory(KIND, Box::new(JwtIdentityFactory::with_replay_guard(guard)));

Every instance must use the same Valkey database and prefix. The guard uses an atomic SET NX EX with the same conservative retention, so a second instance denies the same proof as auth.dpop_replay. Configure Valkey with a noeviction policy: evicting a live replay key would allow reuse before its window ends. Connection and command failures deny as auth.dpop_replay_unavailable. The host owns the pool and can retain it across policy reloads; the factory retains the guard. The generic host-managed store service remains tracked by #127.

Resolving identity more than once per request

A host may resolve identity twice for one request, for example at the HTTP gate and again at the tool. The proof is the same both times, so a second first_use would deny it as auth.dpop_replay. To avoid that, the resolver records each proof it accepts in the request’s PluginContextTable, under a key in global_state that only identity/jwt writes. When identity is resolved again with that table, every check runs again: signature, iat, method, URL, ath and key. If an unexpired record matches the issuer, key, jti, method, normalized URL, access-token hash and replay guard, the replay guard is not consulted a second time. A failed verification records nothing.

A route authentication: step with its own config: builds a second resolver instance. The record is shared through the table rather than kept per instance, so the route’s instance reuses the gate’s verification when the two share a replay guard. That is the case when the host registered the factory with JwtIdentityFactory::with_replay_guard. With the default factory each instance has its own in-memory guard, and the record does not cross between them.

This holds only when the host passes the PipelineResult.context_table from one identity.resolve of the request into the next, as HTTP routing asks. A fresh table is a new request, and the same proof in it is a replay. The table is request-scoped host state. Never build it from client input, such as a header or a cookie: a forged record would let a captured proof be replayed.

Only the serial modes, sequential and transform, commit context back to the table. A resolver with DPoP turned on in any other mode is refused at load.

Another plugin in the same pipeline can also write global_state. A plugin that writes a forged record could make the resolver skip the replay guard for a proof whose other checks pass. It still could not produce a valid proof, a binding for a key it does not hold, or an identity. Plugins are trusted configuration, so run only plugins you trust ahead of the resolver.

Server-issued nonces (DPoP-Nonce) are not supported yet.

A request must carry one DPoP header. A host that receives several should join them with a comma, as HTTP does for repeated headers, so the resolver can refuse the request; a host that keeps only one of them hides the duplicate.

Keycloak

Keycloak issues DPoP-bound tokens when the client sets “Require DPoP bound tokens” (dpop.bound.access.tokens). A bound token can be exchanged only by the client it was issued to, with a proof from the same key. So a gateway that verifies the agent’s bound token cannot then present it in an RFC 8693 exchange. Recipe 11 shows the two ways to get a downstream token instead: exchange a separate user token, or delegate on PPE’s own credential (subject: this_workload).

Caching a delegated token

The OAuth delegator checks each token-exchange response by default. It requires an access-token or JWT issued_token_type, rejects scopes outside a non-empty requested set unless listed in allowed_extra_scopes, and checks a JWT access token’s readable scope claim by the same rule. It checks aud against the requested audience and sub against the caller token’s subject or the authenticated identity when the caller token is opaque. If neither supplies a subject, a JWT response is rejected. Opaque issued access tokens have no claims to inspect locally, even when they contain periods. These claim reads do not verify the returned token’s signature; the configured token endpoint and TLS connection are the trust boundary. Set strict_response_validation: false under the delegator’s config: only for an IdP whose response cannot satisfy these checks. The default is true.

An empty requested scope set accepts the scopes the IdP returns, as in Recipe 3’s client_credentials grant. When requesting scopes from an IdP that always adds defaults, configure the delegator with, for example, allowed_extra_scopes: [profile, email]. Only those named extras pass strict validation. For a readable JWT with a scope claim, required permissions must be present in that claim and the delegated token reports its scopes. Otherwise, the granted scopes come from the token response or the request when the IdP omits them.

The JWT identity resolver rejects non-empty crit headers with auth.unsupported_critical_header; it implements no critical header extensions.

A token exchange is a network call on the request path. The optional cache: block holds a minted token until it expires:

cache:
  enabled: true
  subjects: [this_workload, client]
  max_entries: 10000
  ttl_ceiling_seconds: 300

The default subjects are this_workload and client, which have bounded cardinality. user and caller_workload are opt-in through cache.subjects for exactly that reason: one entry per user is not a cache, it is a leak with an eviction policy.

Concurrent misses for one key share a single exchange rather than stampeding the IdP, and a failure is never cached. ttl_ceiling_seconds bounds how long a cached token can outlive a revocation at the IdP, which is the real cost of caching here: the IdP can revoke, and a cached token does not hear about it until the ceiling expires.

A route that delegates an unvalidated credential

A delegate step whose subject exchanges the caller’s own token relies on identity resolution having checked that token. But authentication: is per-route and optional, so a route can reach the delegator with a credential this process never validated.

Loading reports it, under alarm = "delegation_without_identity_resolution", naming the route and the delegate plugins on it. subject: this_workload is excluded, since it carries no inbound credential.

Where to place PPE

See Deployment → Placement guidance. The identity-specific read:

PlacementUse it whenBecause
In front of the tools (proxy / gateway)agents are untrusted; you want one chokepointPPE becomes the trust boundary that holds downstream authority; agents can’t bypass it
In the MCP / tool serverdefense in depth, or no proxy in the paththe resource enforces even if a front door is skipped; validates the caller right at the data
Agent-sidethe agent is trusted and you want it to self-limitleast-privilege hygiene at the source, not a control against a compromised agent

Run PPE at multiple points to combine agent-side restriction, a gateway chokepoint, and resource defense in depth. Each placement uses the same APL policy at a different boundary.

IdP support matrix

PPE’s identity/delegation plugins are configured against OAuth/OIDC standards, not any one vendor. Per layer:

CapabilityStandardTestedShould work (untested)
JWT validation (any inbound token)JWT + JWKS (RFC 7519/7517)KeycloakOkta, IBM Verify, Auth0, any OIDC IdP; point at its JWKS + issuer
Service token (client_credentials)RFC 6749 §4.4Keycloakbroadly supported
On-behalf-of exchangeRFC 8693Keycloak (STE v2)IdPs vary in RFC 8693 support; verify per target
SVID as client credentialRFC 7523 + draft-ietf-oauth-spiffe-client-authKeycloak 26.6 (spiffe:v1)emerging; an IETF OAuth WG draft, other IdPs not yet confirmed

If the IdP does not support SPIFFE, PPE can still validate the SVID itself (it already fetches SPIRE’s JWKS in identity.resolve), establish caller_workload, and then mint the downstream token using its own credentials (subject: this_workload). This changes attribution: a client_credentials grant carries no caller identity, so the minted token speaks for PPE, not the agent. Capture the caller at the PPE boundary (audit) if the backend needs it. That “PPE-validates, PPE-mints-as-itself” mode works with any OIDC IdP today; only the recipe-2 native flow needs the IdP to understand SVIDs.

“Tested” means the flow passed an end-to-end test against that IdP. “Should work” means the IdP documents support for the required standards, but the flow has no end-to-end result.

Next

  • Header Assertions: project resolved identity onto upstream requests.
  • Deployment: place identity and delegation controls at the required boundary.