Sigra.JWT.Signer (Sigra v0.2.4)

Copy Markdown View Source

JWT key loading and signer creation.

Derives signing keys from the application's secret_key_base for HS256, or loads PEM keys for RS256/ES256. All functions guard against Joken availability at runtime.

Summary

Functions

Creates a Joken.Signer for the configured algorithm.

Ensures Joken is available at runtime.

Functions

create_signer(config)

@spec create_signer(Sigra.Config.t()) :: struct()

Creates a Joken.Signer for the configured algorithm.

For HS256, derives the signing key from secret_key_base using HMAC-SHA256 with the salt "sigra-jwt-signing-key".

For RS256/ES256, loads the PEM private key from configuration.

Parameters

  • config - A Sigra.Config.t() struct with JWT configuration.

Raises

ensure_joken!()

@spec ensure_joken!() :: :ok

Ensures Joken is available at runtime.

Raises a clear RuntimeError with installation instructions if Joken is not loaded. Called before any JWT operation.