Class: JWT::Claims::NotBefore

Inherits:
Object
  • Object
show all
Defined in:
lib/jwt/claims/not_before.rb

Instance Method Summary collapse

Constructor Details

#initialize(leeway:) ⇒ NotBefore

Returns a new instance of NotBefore.



6
7
8
# File 'lib/jwt/claims/not_before.rb', line 6

def initialize(leeway:)
  @leeway = leeway || 0
end

Instance Method Details

#verify!(context:, **_args) ⇒ Object



10
11
12
13
14
15
# File 'lib/jwt/claims/not_before.rb', line 10

def verify!(context:, **_args)
  return unless context.payload.is_a?(Hash)
  return unless context.payload.key?('nbf')

  raise JWT::ImmatureSignature, 'Signature nbf has not been reached' if context.payload['nbf'].to_i > (Time.now.to_i + leeway)
end