Module: Toktok

Defined in:
lib/toktok.rb,
lib/toktok/token.rb,
lib/toktok/version.rb,
lib/toktok/configuration.rb

Defined Under Namespace

Classes: Configuration, Token

Constant Summary collapse

InvalidIdentity =
Class.new(StandardError)
InvalidSignature =
Class.new(StandardError)
VERSION =
'0.2.0'

Class Method Summary collapse

Class Method Details

.algorithm=(value) ⇒ String

Set the algorithm used to encode and decode JWT tokens (default: HS256)

Acceptable values are:

  • none

  • HS256, HS384, HS512

  • RS256, RS384, RS512

  • ES256, ES384, ES512

Parameters:

  • value (String)

    the algorithm name

Returns:

  • (String)

    the algorithm



16
17
18
# File 'lib/toktok.rb', line 16

def self.algorithm=(value)
  @algorithm = value
end

.configToktok::Configuration

Gets a Toktok::Configuration instance using the module values.

Returns:



38
39
40
41
42
43
44
# File 'lib/toktok.rb', line 38

def self.config
  ::Toktok::Configuration.new(
    algorithm: @algorithm,
    lifetime: @lifetime,
    secret_key: @secret_key
  )
end

.lifetime=(value) ⇒ Integer?

Set the lifetime in seconds before a token expires (default: nil)

Parameters:

  • value (Integer, nil)

    the number of seconds before a token expires

Returns:

  • (Integer, nil)

    the lifetime



24
25
26
# File 'lib/toktok.rb', line 24

def self.lifetime=(value)
  @lifetime = value
end

.secret_key=(value) ⇒ String

Set the secret key that will be used to encode and decode JWT tokens

Parameters:

  • value (String)

    the secret key

Returns:

  • (String)

    the secret key



31
32
33
# File 'lib/toktok.rb', line 31

def self.secret_key=(value)
  @secret_key = value
end