Class: Toktok::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/toktok/configuration.rb

Constant Summary collapse

SecretKeyMissingError =

Error raised when an algorithm is given but the secret_key is missing.

Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(algorithm: nil, lifetime: nil, secret_key: nil) ⇒ Configuration

Returns a new instance of Configuration.



8
9
10
11
12
13
14
15
16
# File 'lib/toktok/configuration.rb', line 8

def initialize(algorithm: nil, lifetime: nil, secret_key: nil)
  @algorithm = algorithm || 'HS256'
  @lifetime = lifetime
  @secret_key = secret_key

  if algorithm != 'none' && (secret_key || '') == ''
    raise SecretKeyMissingError, "Toktok: The algorithm #{algorithm} requires you to setup a 'secret_key'"
  end
end

Instance Attribute Details

#algorithmObject (readonly)

Returns the value of attribute algorithm.



3
4
5
# File 'lib/toktok/configuration.rb', line 3

def algorithm
  @algorithm
end

#lifetimeObject (readonly)

Returns the value of attribute lifetime.



3
4
5
# File 'lib/toktok/configuration.rb', line 3

def lifetime
  @lifetime
end

#secret_keyObject (readonly)

Returns the value of attribute secret_key.



3
4
5
# File 'lib/toktok/configuration.rb', line 3

def secret_key
  @secret_key
end