Surgex v2.1.1 Surgex.DeviseSession
Configures Ruby on Rails + Devise session in Plug.
Usage
Add the following to your application’s endpoint (or replace an existing call to Plug.Session):
plug Surgex.DeviseSession,
key: "_my_rails_project_session"
Here’s a list of additional options:
domain: set it todomainprovided in thesession_store()call of your Ruby on Rails projectserializer: set it toPoisonor other JSON serializer of choice if your Ruby on Rails project setscookies_serializerto:json(default in Rails 4.1 and newer)signing_salt: set it to the value ofencrypted_signed_cookie_saltif your Ruby on Rails project sets itencryption_salt: set it to the value ofencrypted_cookie_saltif your Ruby on Rails project sets itsigning_with_salt: set it tofalseif 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:
Surgex.DeviseSession.Helpers.get_user_id()