class JWT::Claims::Numeric
The Numeric
class is responsible for validating numeric claims in a JWT
token. The numeric claims are: exp, iat and nbf
Constants
- NUMERIC_CLAIMS
List of numeric claims that can be validated.
Public Class Methods
new(*args)
click to toggle source
@api private
Calls superclass method
# File lib/jwt/claims/numeric.rb, line 30 def self.new(*args) return super if args.empty? Deprecations.warning('Calling ::JWT::Claims::Numeric.new with the payload will be removed in the next major version of ruby-jwt') Compat.new(*args) end
verify!(payload:, **_args)
click to toggle source
Verifies the numeric claims in the JWT
payload.
@param payload [Hash] the JWT
payload containing the claims. @param _args [Hash] additional arguments (not used). @raise [JWT::InvalidClaimError] if any numeric claim is invalid. @return [nil] @deprecated The ::JWT::Claims::Numeric.verify!
method will be removed in the next major version of ruby-jwt
# File lib/jwt/claims/numeric.rb, line 53 def self.verify!(payload:, **_args) Deprecations.warning('The ::JWT::Claims::Numeric.verify! method will be removed in the next major version of ruby-jwt.') JWT::Claims.verify_payload!(payload, :numeric) end
Public Instance Methods
verify!(context:)
click to toggle source
Private Instance Methods
validate_is_numeric(payload, claim)
click to toggle source
# File lib/jwt/claims/numeric.rb, line 66 def validate_is_numeric(payload, claim) return unless payload.is_a?(Hash) return unless payload.key?(claim) || payload.key?(claim.to_s) return if payload[claim].is_a?(::Numeric) || payload[claim.to_s].is_a?(::Numeric) raise InvalidPayload, "#{claim} claim must be a Numeric value but it is a #{(payload[claim] || payload[claim.to_s]).class}" end
validate_numeric_claims(payload)
click to toggle source
# File lib/jwt/claims/numeric.rb, line 60 def validate_numeric_claims(payload) NUMERIC_CLAIMS.each do |claim| validate_is_numeric(payload, claim) end end