nova_auth behaviour (nova_auth v0.2.0)

View Source

Behaviour for nova_auth configuration. Implementing modules define authentication settings (repo, schemas, token lifetimes). Configuration is cached in persistent_term for fast repeated access.

Password-related keys (repo, user_schema, token_schema) are only required when using password authentication modules (nova_auth_accounts, nova_auth_session, etc.). OIDC-only applications can omit them entirely.

Summary

Functions

Return the merged auth configuration for Mod, caching in persistent_term.

Return a single config value for Key from the auth module Mod.

Evict the cached configuration for Mod from persistent_term.

Types

actor()

-type actor() :: #{id := binary() | integer(), provider := atom(), atom() => term()}.

Callbacks

config()

-callback config() ->
                    #{repo => module(),
                      user_schema => module(),
                      token_schema => module(),
                      user_identity_field => atom(),
                      user_password_field => atom(),
                      session_validity_days => pos_integer(),
                      confirm_validity_days => pos_integer(),
                      reset_validity_hours => pos_integer(),
                      hash_algorithm => pbkdf2_sha256 | bcrypt | argon2,
                      token_bytes => pos_integer()}.

Functions

config(Mod)

-spec config(module()) -> map().

Return the merged auth configuration for Mod, caching in persistent_term.

config(Mod, Key)

-spec config(module(), atom()) -> term().

Return a single config value for Key from the auth module Mod.

invalidate_cache(Mod)

-spec invalidate_cache(module()) -> true.

Evict the cached configuration for Mod from persistent_term.