Class: JWT::Claims::NotBefore
- Inherits:
-
Object
- Object
- JWT::Claims::NotBefore
- Defined in:
- lib/jwt/claims/not_before.rb
Overview
The NotBefore class is responsible for validating the ‘nbf’ (Not Before) claim in a JWT token.
Instance Method Summary collapse
-
#initialize(leeway:) ⇒ NotBefore
constructor
Initializes a new NotBefore instance.
-
#verify!(context:, **_args) ⇒ nil
Verifies the ‘nbf’ (Not Before) claim in the JWT token.
Constructor Details
#initialize(leeway:) ⇒ NotBefore
Initializes a new NotBefore instance.
10 11 12 |
# File 'lib/jwt/claims/not_before.rb', line 10 def initialize(leeway:) @leeway = leeway || 0 end |
Instance Method Details
#verify!(context:, **_args) ⇒ nil
Verifies the ‘nbf’ (Not Before) claim in the JWT token.
20 21 22 23 24 25 |
# File 'lib/jwt/claims/not_before.rb', line 20 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 |