Class: Fernet::Verifier

Inherits:
Object
  • Object
show all
Defined in:
lib/fernet/verifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(secret) ⇒ Verifier

Returns a new instance of Verifier.



12
13
14
# File 'lib/fernet/verifier.rb', line 12

def initialize(secret)
  @secret        = secret
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/fernet/verifier.rb', line 9

def data
  @data
end

#seconds_valid=(value) ⇒ Object (writeonly)

Sets the attribute seconds_valid

Parameters:

  • value

    the value to set the attribute seconds_valid to.



10
11
12
# File 'lib/fernet/verifier.rb', line 10

def seconds_valid=(value)
  @seconds_valid = value
end

#secretObject (readonly)

Returns the value of attribute secret.



9
10
11
# File 'lib/fernet/verifier.rb', line 9

def secret
  @secret
end

#tokenObject (readonly)

Returns the value of attribute token.



9
10
11
# File 'lib/fernet/verifier.rb', line 9

def token
  @token
end

Instance Method Details

#verify_token(token) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/fernet/verifier.rb', line 16

def verify_token(token)
  @token = token
  deconstruct

  custom_verification = yield self

  signatures_match? && token_recent_enough? && custom_verification
end