plug_rails_cookie_session_store alternatives and similar packages
Based on the "Framework Components" category.
Alternatively, view plug_rails_cookie_session_store alternatives based on common mentions on social networks and blogs.
-
commanded
Use Commanded to build Elixir CQRS/ES applications -
surface
A server-side rendering component library for Phoenix -
ex_admin
ExAdmin is an auto administration package for Elixir and the Phoenix Framework -
phoenix_html
Phoenix.HTML functions for working with HTML strings and templates -
phoenix_ecto
Phoenix and Ecto integration with support for concurrent acceptance testing -
absinthe_plug
Plug support for Absinthe, the GraphQL toolkit for Elixir -
corsica
Elixir library for dealing with CORS requests. ๐ -
react_phoenix
Make rendering React.js components in Phoenix easy -
scrivener_html
HTML view helpers for Scrivener -
phoenix_live_reload
Provides live-reload functionality for Phoenix -
Raxx
Interface for HTTP webservers, frameworks and clients -
phoenix_slime
Phoenix Template Engine for Slime -
params
Easy parameters validation/casting with Ecto.Schema, akin to Rails' strong parameters. -
phoenix_pubsub_redis
The Redis PubSub adapter for the Phoenix framework -
rummage_ecto
Search, Sort and Pagination for ecto queries -
dayron
A repository `similar` to Ecto.Repo that maps to an underlying http client, sending requests to an external rest api instead of a database -
passport
Provides authentication for phoenix application -
rummage_phoenix
Full Phoenix Support for Rummage. It can be used for searching, sorting and paginating collections in phoenix. -
phoenix_haml
Phoenix Template Engine for Haml -
phoenix_token_auth
Token authentication solution for Phoenix. Useful for APIs for e.g. single page apps. -
recaptcha
A simple reCaptcha 2 library for Elixir applications. -
plug_graphql
Plug (Phoenix) integration for GraphQL Elixir -
sentinel
DEPRECATED - Phoenix Authentication library that wraps Guardian for extra functionality -
phx_component_helpers
Extensible Phoenix liveview components, without boilerplate -
filterable
Filtering from incoming params in Elixir/Ecto/Phoenix with easy to use DSL. -
multiverse
Elixir package that allows to add compatibility layers via API gateways. -
ashes
A code generation tool for the Phoenix web framework -
scrivener_headers
Scrivener pagination with headers and web linking -
better_params
Cleaner request parameters in Elixir web applications ๐ -
access pass
provides a full user authentication experience for an API. Includes login,logout,register,forgot password, forgot username, confirmation email and all that other good stuff. Includes plug for checking for authenticated users and macro for generating the required routes. -
plug_auth
A collection of authentication-related plugs -
phoenix_pubsub_rabbitmq
RabbitMQ adapter for Phoenix's PubSub layer -
plug_checkup
PlugCheckup provides a Plug for adding simple health checks to your app -
plug_statsd
Send connection response time and count to statsd -
plug_rest
REST behaviour and Plug router for hypermedia web applications in Elixir -
Votex
Implements vote / like / follow functionality for Ecto models in Elixir. Inspired from Acts as Votable gem in Ruby on Rails -
plug_canonical_host
PlugCanonicalHost ensures that all requests are served by a single canonical host. -
trailing_format_plug
An elixir plug to support legacy APIs that use a rails-like trailing format: http://api.dev/resources.json -
phoenix_html_simplified_helpers
Some helpers for phoenix html( truncate, time_ago_in_words, number_with_delimiter, url_for, current_page? )
Static code analysis for 29 languages.
Do you think we are missing an alternative of plug_rails_cookie_session_store or a related project?
README
PlugRailsCookieSessionStore
Rails compatible Plug session store.
This allows you to share session information between Rails and a Plug-based framework like Phoenix.
Installation
Add PlugRailsCookieSessionStore as a dependency to your mix.exs
file:
def deps do
[{:plug_rails_cookie_session_store, "~> 1.0"}]
end
How to use with Phoenix
Copy/share the encryption information from Rails to Phoenix.
There are 4 things to copy:
- secret_key_base
- signing_salt
- encryption_salt
- session_key
Since Rails 5.2, secret_key_base
in test and development is derived as a MD5 hash of the application's name. To fetch key value you can run:
Rails.application.secret_key_base
https://www.rubydoc.info/github/rails/rails/Rails%2FApplication:secret_key_base
The secret_key_base
should be copied to Phoenix's config.exs
file. There should already be a key named like that and you should override it.
The other three values can be found somewhere in the initializers directory of your Rails project. Some people don't set the signing_salt
and encryption_salt
. If you don't find them, set them like so:
Rails.application.config.session_store :cookie_store, key: '_SOMETHING_HERE_session'
Rails.application.config.action_dispatch.encrypted_cookie_salt = 'encryption salt'
Rails.application.config.action_dispatch.encrypted_signed_cookie_salt = 'signing salt'
Configure the Cookie Store in Phoenix.
Edit the endpoint.ex
file and add the following:
# ...
plug Plug.Session,
store: PlugRailsCookieSessionStore,
key: "_SOMETHING_HERE_session",
domain: '.myapp.com',
secure: true,
signing_with_salt: true,
signing_salt: "signing salt",
encrypt: true,
encryption_salt: "encryption salt",
key_iterations: 1000,
key_length: 64,
key_digest: :sha,
serializer: Poison # see serializer details below
end
Set up a serializer
Plug & Rails must use the same strategy for serializing cookie data.
- JSON: Since 4.1, Rails defaults to serializing cookie data with JSON. Support this strategy by getting a JSON serializer and passing it to
Plug.Session
. For example, addPoison
to your dependencies, then:
plug Plug.Session,
store: PlugRailsCookieSessionStore,
# ... see encryption config above
serializer: Poison
end
You can confirm that your app uses JSON by searching for
Rails.application.config.action_dispatch.cookies_serializer = :json
in an initializer.
- Marshal: Previous to 4.1, Rails defaulted to Ruby's
Marshal
library for serializing cookie data. You can deserialize this by addingExMarshal
to your project and defining a serializer module:
defmodule RailsMarshalSessionSerializer do
@moduledoc """
Share a session with a Rails app using Ruby's Marshal format.
"""
def encode(value) do
{:ok, ExMarshal.encode(value)}
end
def decode(value) do
{:ok, ExMarshal.decode(value)}
end
end
Then, pass that module as a serializer to Plug.Session
:
plug Plug.Session,
store: PlugRailsCookieSessionStore,
# ... see encryption config above
serializer: RailsMarshalSessionSerializer
end
- Rails 3.2: Rails 3.2 uses unsalted signing, to make Phoenix share session with Rails 3.2 project you need to set up
ExMarshal
mentioned above, with following configuration in yourPlug.Session
:
plug Plug.Session,
store: PlugRailsCookieSessionStore,
# ... see encryption/ExMarshal config above
signing_with_salt: false,
end
That's it!
To test it, set a session value in your Rails application:
session[:foo] = 'bar'
And print it on Phoenix in whatever Controller you want:
Logger.debug get_session(conn, "foo")