ExIcaoVds.TrustResolvers.DatabaseStore (ex_icao_vds v0.3.2)

Copy Markdown

Trust resolver backed by an Ecto repo.

The caller provides an Ecto repo and schema module. The schema is queried by signer identifier and key reference to return the public key bytes and curve.

Config opts

KeyDefaultDescription
:repoEcto repo module (required)
:schemaEcto schema module (required)
:signer_identifier_field:signer_identifierSchema field name for signer ID
:key_reference_field:key_referenceSchema field name for key reference
:public_key_field:public_keySchema field name for public key binary
:curve_field:curveSchema field name for curve atom/string
:default_curve:secp256r1Curve to use when :curve_field is nil

Example schema

defmodule MyApp.TrustedSigner do
  use Ecto.Schema

  schema "trusted_signers" do
    field :signer_identifier, :string
    field :key_reference, :string
    field :public_key, :binary
    field :curve, :string, default: "secp256r1"
  end
end

Usage

ExIcaoVds.verify(raw_vds, %{
  verifier: %{
    trust_resolver: ExIcaoVds.TrustResolvers.DatabaseStore,
    repo: MyApp.Repo,
    schema: MyApp.TrustedSigner
  }
})