PlugDeviseSession v0.9.1 PlugDeviseSession View Source
Simple plug for sharing Devise session in Elixir.
Usage
Add the following to your application's endpoint (or replace an existing call to Plug.Session
):
plug PlugDeviseSession,
key: "_my_rails_project_session"
Here's a list of additional options:
domain
: set it todomain
provided in thesession_store()
call of your Ruby on Rails projectextra
: lets specify arbitrary options that are added to cookiemax_age
: desired validity of remember user cookie in secondspath
: send cookie only on matching URL pathsecure
: a secure cookie is only sent to the server over the HTTPS protocolserializer
: set it toPoison
or other JSON serializer of choice if your Ruby on Rails project setscookies_serializer
to:json
(default in Rails 4.1 and newer)signing_salt
: set it to the value ofencrypted_signed_cookie_salt
if your Ruby on Rails project sets itencryption_salt
: set it to the value ofencrypted_cookie_salt
if your Ruby on Rails project sets itsigning_with_salt
: set it tofalse
if your Ruby on Rails project is based on Rails 3.2 or older
Remember to also set secret key base to match the one in your Rails project:
config :my_project, MyProject.Web.Endpoint,
secret_key_base: "secret..."
In order to read the session, you must first fetch the session in your router pipeline:
plug :fetch_session
Finally, you can get the current user's identifier as follows:
PlugDeviseSession.Helpers.get_user_id()