Packages

A standalone, production-ready Elixir library that provides an in-process emergency access subsystem (break-glass authentication) for any Elixir or Phoenix application.

Current section

Files

Jump to
breakglass lib break_glass default_user_provider.ex
Raw

lib/break_glass/default_user_provider.ex

defmodule BreakGlass.DefaultUserProvider do
@moduledoc """
Default implementation of `BreakGlass.UserProvider` that returns the raw
`attrs` map unchanged.
This enables zero-config use in tests and simple host applications. For
production use, implement your own `BreakGlass.UserProvider` module that
returns your application's user struct.
## Example
config :break_glass_ex,
user_provider: BreakGlass.DefaultUserProvider
When `build_user/1` is called, it returns the map passed to it directly,
which contains at minimum `:email`, `:sentinel_id`, `:authenticated_at`,
and `:break_glass`.
"""
@behaviour BreakGlass.UserProvider
@doc """
Returns the `attrs` map unchanged.
"""
@impl BreakGlass.UserProvider
def build_user(attrs), do: attrs
end