Module: Landline::Session

Defined in:
lib/landline/extensions/session.rb

Overview

Module for controlling session signing secrets

Defined Under Namespace

Classes: Session, SessionError

Class Method Summary collapse

Class Method Details

.hmac_secretObject

Get hmac secret



15
16
17
18
19
20
21
22
23
# File 'lib/landline/extensions/session.rb', line 15

def self.hmac_secret
  unless @hmac_secret or ENV['HMAC_SECRET']
    warn <<~MSG
      warn: hmac secret not supplied, using randomized one
      warn: provide hmac secret with $HMAC_SECRET or Landline::Session.hmac_secret
    MSG
  end
  @hmac_secret ||= ENV.fetch('HMAC_SECRET', SecureRandom.base64(80))
end

.hmac_secret=(secret) ⇒ Object

Set hmac secret

Parameters:

  • secret (String)


10
11
12
# File 'lib/landline/extensions/session.rb', line 10

def self.hmac_secret=(secret)
  @hmac_secret = secret
end