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
@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- ASigra.Config.t()struct with JWT configuration.
Raises
RuntimeErrorif Joken is not loadedRuntimeErrorifsecret_key_baseis nil for HS256KeyErrorifprivate_keyis missing for RS256/ES256
@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.