ash_authentication/test/support/session_pipeline.ex
James Harton 1c8f138c67
improvement!: Major redesign of DSL and code structure. (#35)
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.
2022-11-23 09:09:41 +13:00

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