PlugSessionRedisStore
Extendable Redis store for Plug.Session
Abstract
This library is a dummy connector between Plug and Redis, nothing more. It allows the configuration of the session ID generation, data serialization and Redis connection.
Installation
Declare the dependency on your mix.exs file.
def deps do
[
{:plug_session_redis_store, "~> 0.1.0"}
]
endConfiguration
PlugSessionRedisStore
condig :plug_session_redis_store,
sid_generator: PlugSessionRedisStore.Generator.StrongRandBytes,
encoder: PlugSessionRedisStore.Encoder.Binary,
redis: [
host: "localhost",
database: 2
]sid_generator: Session ID Generator (default RandBytes)encoder: Session Data Serializer (default Binary)redis: Redis Connection. This configuration is forwarded as is toRedix(redix-configuration).
Plug
plug Plug.Session,
store: :redis,
key: "SSID",
max_age: 2_592_000, # Optional - default 30 days
secure: true,
http_only: true,
signing_salt: "some $3cr3t salt key" # change this valueNOTE: PlugSessionRedisStore relies on the Plug configuration when it comes to handling session expiration. The duration is directly tied to the cookie one. Like the cookie, the session expiration is reset upon each request.
Contributing
- Fork it (https://github.com/gearnode/judge/fork)
-
Create your feature branch (
git checkout -b feature/fooBar) -
Commit your changes (
git commit -am 'Add some fooBar') -
Push to the branch (
git push origin feature/fooBar) - Create a new Pull Request