Session::Configuration
Inherits Reference < Object
Constants
The secret older releases signed with when none was configured. It is public, so it is never
used by default any more and is refused where require_secure_secret holds.
AES-256 takes a 32-byte key, and the secret is that key unless use_kdf derives one. The HMAC
signature always uses the secret itself, so the minimum holds with use_kdf too.
Environments that must not run on the published default secret.
Constructors
Load configuration from a preset (returns a new Configuration instance) Available presets: :development, :production, :high_security, :testing, :clustered
Class methods
The random fallback, one per process so every configuration agrees on it; warns once.
Instance methods
Where a secure secret is required (production, staging), insecure cookies are refused too, unless this opts out explicitly.
Where a secure secret is required (production, staging), insecure cookies are refused too, unless this opts out explicitly.
Apply a preset's settings to this configuration instance Available presets: :development, :production, :high_security, :testing, :clustered
Session binding: bind sessions to client fingerprint for security
Circuit breaker configuration for Redis connections
Cluster configuration for multi-node deployments with Redis Pub/Sub
Data compression: when enabled, session data is compressed before storage
Minimum size in bytes before compression is applied (smaller data may grow with compression)
Minimum size in bytes before compression is applied (smaller data may grow with compression)
Cookie attributes. Cookies are always HttpOnly. Secure keeps them off plain http (browsers still accept a Secure cookie over http on localhost); turn it off only for an http-only setup.
Cookie attributes. Cookies are always HttpOnly. Secure keeps them off plain http (browsers still accept a Secure cookie over http on localhost); turn it off only for an http-only setup.
Digest algorithm for HMAC signatures (:sha256 recommended, :sha1 for legacy)
Enable auto-fallback to SHA1 for migrating old sessions (logs deprecation warning)
Enable auto-fallback to SHA1 for migrating old sessions (logs deprecation warning)
Redis encryption: when enabled, session data stored in Redis is encrypted
The encryptor for the current settings. It is reused while they stay the same, so PBKDF2
(use_kdf) runs once per secret, salt and iteration count, not on every encrypt and decrypt.
Metrics backend for observability (default: NullBackend discards all metrics)
Whether a missing or published secret is an error rather than a warning. Unless set, it holds
in production and staging, read from CRYSTAL_ENV (case-insensitive) each time it is checked.
The key sessions are encrypted and signed with: the one configured, else SESSION_SECRET.
Without either, InsecureSecretException where require_secure_secret holds, and otherwise a
random key for this process only (sessions do not survive a restart or reach another instance).
Not memoised: the random fallback is refused again as soon as require_secure_secret holds.
Sliding expiration: when enabled, session timeout resets on each access
Whether X-Forwarded-For and X-Real-IP name the client for IP binding. Any client can
send them, so they are believed only when a trusted proxy in front of the app sets them.
Whether X-Forwarded-For and X-Real-IP name the client for IP binding. Any client can
send them, so they are believed only when a trusted proxy in front of the app sets them.
Key Derivation Function (KDF) settings When enabled, derives cipher key from secret using PBKDF2-SHA256
Key Derivation Function (KDF) settings When enabled, derives cipher key from secret using PBKDF2-SHA256
Raises InvalidCookieOptions for cookie options browsers reject or that defeat the secret requirement.
Raises InsecureSecretException when store encrypts with the secret (Store#encrypts_with_secret?:
a CookieStore, or a Redis store with encrypt_redis_data) and the secret is missing, published
or too short.