Sha256: 5561488e82ecf7558f3dd3e756f16dbde3ecd397798369d8e7f579110a8ae4ff

Contents?: true

Size: 581 Bytes

Versions: 1

Compression:

Stored size: 581 Bytes

Contents

module Toktok
  class Configuration
    attr_reader :algorithm, :lifetime, :secret_key

    # Error raised when an algorithm is given but the secret_key is missing.
    SecretKeyMissingError = Class.new(StandardError)

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
toktok-0.2.0 lib/toktok/configuration.rb