PlugDeviseSession v0.9.1 PlugDeviseSession.Rememberable View Source
Helps issuing and reading Devise's remember user cookie.
Important module assumptions:
- All
Plug.Conn
structures should have a validsecret_key_base
set. - User authorization info is a three element tuple of the form:
{id, auth_key, timestamp}
. - Remember timestamps are required to be in the
Etc/UTC
time zone.
Link to this section Summary
Functions
Removes the remember user cookie.
Recovers user authentication info from remember cookie.
Sets a signed remember user cookie on the connection.
Link to this section Types
Link to this section Functions
Link to this function
forget_user(conn, scope \\ :user, opts \\ [])
View Sourceforget_user(Plug.Conn.t(), scope(), [{:domain, String.t()}]) :: Plug.Conn.t()
Removes the remember user cookie.
Options
:domain
- domain the remember user cookie was issued in.
Link to this function
recover_user(conn, scope \\ :user, opts \\ [])
View Sourcerecover_user(Plug.Conn.t(), scope(), key_digest: atom(), key_iterations: integer(), key_length: integer(), serializer: module(), signing_salt: binary() ) :: {:ok, user_auth_info()} | {:error, :unauthorized}
Recovers user authentication info from remember cookie.
Options
:key_digest
- digest algorithm to use for deriving the signing key. Accepts any value supported byPlug.Crypto.KeyGenerator.generate/3
, defaults to:sha
.:key_iterations
- number of iterations for signing key derivation. Accepts any value supported byPlug.Crypto.KeyGenerator.generate/3
, defaults to 1000.:key_length
- desired length of derived signing key. Accepts any value supported byPlug.Crypto.KeyGenerator.generate/3
, defaults to 64.:serializer
- module used for cookie data serialization, defaults toPlugDeviseSession.Marshal
which in turn usesExMarshal
(a Rails-compatible marshal module).:signing_salt
- salt used for signing key derivation. Should be set to the value used by Rails, defaults to "signed cookie".
Link to this function
remember_user(conn, arg, scope \\ :user, opts \\ [])
View Sourceremember_user(Plug.Conn.t(), user_auth_info(), scope(), domain: String.t(), key_digest: atom(), key_iterations: integer(), key_length: integer(), max_age: integer(), path: String.t(), secure: boolean(), serializer: module(), signing_salt: binary() ) :: Plug.Conn.t()
Sets a signed remember user cookie on the connection.
Options
:domain
- domain to issue the remember user cookie in.:extra
- lets specify arbitrary options that are added to cookie.:key_digest
- digest algorithm to use for deriving the signing key. Accepts any value supported byPlug.Crypto.KeyGenerator.generate/3
, defaults to:sha
.:key_iterations
- number of iterations for signing key derivation. Accepts any value supported byPlug.Crypto.KeyGenerator.generate/3
, defaults to 1000.:key_length
- desired length of derived signing key. Accepts any value supported byPlug.Crypto.KeyGenerator.generate/3
, defaults to 64.:max_age
- desired validity of remember user cookie in seconds, defaults to 2 weeks.:path
- send cookie only on matching URL path.:secure
- a secure cookie is only sent to the server over the HTTPS protocol.:serializer
- module used for cookie data serialization, defaults toPlugDeviseSession.Marshal
which in turn usesExMarshal
(a Rails-compatible marshal module).:signing_salt
- salt used for signing key derivation. Should be set to the value used by Rails, defaults to "signed cookie".