esdb_capability_verifier (reckon_db v1.2.6)
View SourceServer-side capability token verification for reckon-db.
Verifies UCAN-inspired capability tokens for authorization decisions. Tokens are created client-side (reckon-gater) and verified server-side here.
Verification steps:
- Decode token (JWT or binary format, auto-detected)
- Verify Ed25519 signature using issuer's public key from DID
- Check token is not expired (exp less than now)
- Check token is active (nbf less than or equal to now, if present)
- Check token is not revoked (via gossip list)
- Match resource URI against request
- Match action against permitted actions
See also: esdb_capability, esdb_identity.
Summary
Functions
Authorize a request with a capability token
Authorize a request with options
Check if a verified capability grants permission for resource/action
Extract a content-addressed identifier for a token
Check if a token CID is revoked
Verify a capability token
Verify a capability token with options
Types
-type verification_result() :: #verification_result{capability :: capability(), issuer_chain :: [binary()], resource :: binary(), action :: binary(), verified_at :: integer()}.
Functions
-spec authorize(binary(), binary(), binary()) -> {ok, verification_result()} | {error, capability_error()}.
Authorize a request with a capability token
Verifies the token AND checks it grants permission for the specified resource and action.
-spec authorize(binary(), binary(), binary(), verify_opts()) -> {ok, verification_result()} | {error, capability_error()}.
Authorize a request with options
-spec check_permission(capability(), binary(), binary()) -> ok | {error, capability_error()}.
Check if a verified capability grants permission for resource/action
The capability should already be verified (signature, expiration). This function only checks the grants against the requested resource/action.
-spec extract_token_cid(capability()) -> binary().
Extract a content-addressed identifier for a token
Uses SHA-256 hash of the token's core fields (excluding signature). This CID can be used for revocation.
Check if a token CID is revoked
Currently returns false (not revoked) as revocation gossip is not yet implemented. This will be integrated with a gossip-based revocation list in Phase 4.
-spec verify(binary()) -> {ok, capability()} | {error, capability_error()}.
Verify a capability token
Decodes the token and verifies: - Signature is valid (Ed25519) - Token is not expired - Token is not revoked
Does NOT check permissions against a specific resource/action. Use authorize/3 for full authorization.
-spec verify(binary(), verify_opts()) -> {ok, capability()} | {error, capability_error()}.
Verify a capability token with options