Documentation
¶
Overview ¶
Package vcvalidator provides a processing Step that validates W3C Verifiable Credentials embedded in a beckn request body. It is built as validateVC.so, so pipelines reference it by the step id validateVC — matching the verb naming of the built-in steps (validateSign, validateSchema).
For the configured beckn actions it verifies every embedded credential's proof, validity window and revocation status. On any failure the step returns an error, which the handler pipeline turns into the standard signed beckn NACK — the request never reaches routing.
The package is organised in two files:
- vcvalidator.go — the plugin surface: the Step, its Config, and credential extraction from the request body.
- verify.go — the verification engine: proof/JWT checks, DID resolution (did:key / did:jwk / did:web), and revocation.
verify.go is the verification engine behind the vcvalidator Step: proof and validity-window checks, DID resolution (did:key / did:jwk / did:web), and revocation (StatusList2021 / BitstringStatusList, DEDI, generic).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Enabled controls whether the plugin is active. When false the step
// passes every request through untouched.
Enabled bool
// Actions is the list of beckn actions whose payloads are validated.
// REQUIRED — no code default. Declared explicitly in the devkit YAML so
// the operator can see exactly which messages are gated (e.g.
// "confirm,init,select").
Actions []string
// AllowedDIDMethods restricts which issuer/verification-method DID
// methods are accepted. Default: key,jwk,web.
AllowedDIDMethods []string
// CheckExpiry toggles validity-window enforcement (validFrom/validUntil
// and JWT nbf/exp). Default: true.
CheckExpiry bool
// CheckRevocation toggles credentialStatus revocation checks.
// Default: true.
CheckRevocation bool
// RequireProof rejects credentials whose proof cannot be cryptographically
// verified by this plugin (e.g. JSON-LD Data Integrity proofs such as
// Ed25519Signature2020 that require RDF canonicalization, which this
// plugin does not perform). When false such proofs are skipped with a
// warning and the remaining checks (expiry/revocation) still run.
// Default: true.
RequireProof bool
// FailOpen controls behaviour on transient network errors while
// resolving a did:web document or fetching a revocation list. When true
// such errors are logged and the credential is allowed through; when
// false the request is rejected. Default: false (fail closed).
FailOpen bool
// HTTPTimeout bounds did:web and revocation-list HTTP fetches.
// Default: 10s.
HTTPTimeout time.Duration
// MaxCredentials caps how many embedded credentials a single request may
// carry. Each credential can cost up to two HTTP fetches (did:web
// resolution + revocation), so the cap bounds the per-request work; a
// request exceeding it is rejected with a Bad Request NACK before any
// network I/O. Default: 10.
MaxCredentials int
// AllowPrivateNetworks permits did:web and revocation fetches to resolve
// to private, loopback or link-local addresses. The fetched URLs come from
// the request body, so this MUST stay false in production (SSRF); it
// exists for local/devkit deployments where issuers and registries live on
// a private docker network. Default: false.
AllowPrivateNetworks bool
// DebugLogging enables verbose per-credential logging.
DebugLogging bool
}
Config holds configuration for the VC Validator plugin.
The plugin inspects Verifiable Credentials carried in the request body (by default the credential objects nested under message.contract.participants[].participantAttributes) and, for the configured beckn actions, verifies that each credential:
- has a cryptographically valid proof (did:key / did:jwk / did:web),
- was signed by the did:web issuer when the issuer id is a did:web that is web accessible,
- is within its validity window (validFrom / validUntil, nbf / exp), and
- is not revoked (credentialStatus).
On any failure the request is rejected with a beckn NACK and never reaches routing.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config seeded with sensible defaults for the non-primary fields. The primary behaviour knob (Actions) is intentionally left empty — ParseConfig requires it in the YAML.
func ParseConfig ¶
ParseConfig parses the plugin configuration map supplied by beckn-onix.
func (*Config) IsActionEnabled ¶
IsActionEnabled reports whether the given beckn action is gated.
func (*Config) IsMethodAllowed ¶
IsMethodAllowed reports whether the given DID method (without the "did:" prefix, e.g. "key", "web") is permitted.