View Source Charon.SessionStore.RedisStore (Charon v2.8.0)

A persistent session store based on Redis, which implements behaviour Charon.SessionStore. In addition to the required callbacks, this store also provides get_all/3 and delete_all/3 (for a user) functions.

redis-requirements

Redis requirements

This module needs a Redis >= 6.2.0 instance.

config

Config

Additional config is required for this module (see Charon.SessionStore.RedisStore.Config):

Charon.Config.from_enum(
  ...,
  optional_modules: %{
    Charon.SessionStore.RedisStore => %{
      redix_module: MyApp.Redix,
      key_prefix: "charon_",
      get_signing_key: &RedisStore.default_signing_key/1,
      allow_unsigned?: true
    }
  }
)

The following options are supported:

  • :redix_module (required). A module that implements a command/1 and a pipeline/1 function for Redis commands like Redix.
  • :key_prefix (optional). A string prefix for the Redis keys that are sessions.
  • :get_signing_key (optional). A getter/1 that returns the key that is used to sign and verify serialized session binaries.
  • :allow_unsigned? (optional). Allow unsigned sessions for legacy reasons. This option will be removed and no unsigned session will be allowed anymore in a future major release.

redix

Redix

This module depends on a correctly configured Redix module with command/1 and pipeline/1 functions. See https://hexdocs.pm/redix for instructions.

Link to this section Summary

Functions

cleanup(config) deprecated

This should run periodically, for example once per day at a quiet moment. Deprecated; periodic cleanup is no longer required.

Get the default session signing key that is used if config option :get_signing_key is not set explicitly.

Migrate sessions to new storage format

Link to this section Functions

This function is deprecated. Periodic cleanup is no longer required..
@spec cleanup(Charon.Config.t()) :: :ok | {:error, binary()}

This should run periodically, for example once per day at a quiet moment. Deprecated; periodic cleanup is no longer required.

Link to this function

default_signing_key(config)

View Source
@spec default_signing_key(Charon.Config.t()) :: binary()

Get the default session signing key that is used if config option :get_signing_key is not set explicitly.

Link to this function

migrate_sessions(config)

View Source
@spec migrate_sessions(Charon.Config.t()) :: :ok

Migrate sessions to new storage format:

  • keys no longer hashed
  • sessions are signed