mirror of
https://github.com/team-alembic/ash_authentication.git
synced 2024-09-21 05:43:05 +12:00
8797005175
* improvement(docs): change all references to `actor` to `user`. The word "actor" has special meaning in the Ash ecosystem. * chore: format `dev` directory also. * feat(Ash.PlugHelpers): Support standard actor configuration. * Adds the `:set_actor` plug which will set the actor to a resource based on the subject name. * Also includes GraphQL and JSON:API interfaces in the devserver for testing.
23 lines
511 B
Elixir
23 lines
511 B
Elixir
defmodule AshAuthentication.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
|