mirror of
https://github.com/team-alembic/ash_authentication.git
synced 2024-09-20 13:24:20 +12:00
1c8f138c67
Highlights: * Replaced `AshAuthentication.Provider` with the much more flexible `AshAuthentication.Strategy`. * Moved strategies to within the `authentication` DSL using entities and removed excess extensions. * Added a lot more documentation and test coverage.
23 lines
493 B
Elixir
23 lines
493 B
Elixir
defmodule SessionPipeline do
|
|
@moduledoc """
|
|
A simple plug pipeline that ensures that the session is set up ready to be consumed.
|
|
"""
|
|
use Plug.Builder
|
|
import Ecto.UUID, only: [generate: 0]
|
|
|
|
plug(:set_secret)
|
|
|
|
plug(Plug.Session,
|
|
store: :cookie,
|
|
key: inspect(__MODULE__),
|
|
encryption_salt: generate(),
|
|
signing_salt: generate()
|
|
)
|
|
|
|
plug(:fetch_session)
|
|
|
|
@doc false
|
|
def set_secret(conn, _) do
|
|
put_in(conn.secret_key_base, generate() <> generate())
|
|
end
|
|
end
|