Spikard.JwtAuthConfig (spikard v0.17.0)

Copy Markdown

Per-route JWT authentication requirement.

spikard-http defines the canonical JwtConfig used by ServerConfig.jwt_auth, but spikard-core cannot depend on spikard-http (the dependency runs the other way), so that type cannot be reused here. This mirrors its fields so a later enforcement phase in spikard-http can convert between the two without losing information.

secret and public_key are both optional because asymmetric algorithms (RS256, ES256, ...) verify against a public key rather than a shared secret; see fixtures/auth.json's jwt_config_algorithm_rs256, which carries public_key and no secret at all. Exactly one is expected to be populated for a given algorithm, but that cross-field invariant is left to a later enforcement phase rather than the type itself.

Summary

Types

t()

Per-route JWT authentication requirement.

Types

t()

@type t() :: %Spikard.JwtAuthConfig{
  algorithm: String.t() | nil,
  audience: [String.t()] | nil,
  enabled: boolean(),
  issuer: String.t() | nil,
  leeway: non_neg_integer(),
  public_key: String.t() | nil,
  secret: String.t() | nil
}

Per-route JWT authentication requirement.