Class: JWT::Claims::IssuedAt

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

Overview

The IssuedAt class is responsible for validating the issued at claim (‘iat’) in a JWT token.

Instance Method Summary collapse

Instance Method Details

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

Verifies the issued at claim (‘iat’) in the JWT token.

Parameters:

  • context (Object)

    the context containing the JWT payload.

  • _args (Hash)

    additional arguments (not used).

Returns:

  • (nil)

Raises:



13
14
15
16
17
18
19
# File 'lib/jwt/claims/issued_at.rb', line 13

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

  iat = context.payload['iat']
  raise(JWT::InvalidIatError, 'Invalid iat') if !iat.is_a?(::Numeric) || iat.to_f > Time.now.to_f
end