module JWT::Claims

JWT Claim verifications datatracker.ietf.org/doc/html/rfc7519#section-4

Verification is supported for the following claims: exp nbf iss iat jti aud sub required numeric

Constants

Error

Represents a claim verification error

VerificationContext

Context class to contain the data passed to individual claim validators

@api private

Public Class Methods

payload_errors(payload, *options) click to toggle source

Returns the errors in the claims of the JWT token.

@param options [Array] the options for verifying the claims. @return [Array<JWT::Claims::Error>] the errors in the claims of the JWT

# File lib/jwt/claims.rb, line 69
def payload_errors(payload, *options)
  Verifier.errors(VerificationContext.new(payload: payload), *options)
end
valid_payload?(payload, *options) click to toggle source

Checks if the claims in the JWT payload are valid.

@param payload [Hash] the JWT payload. @param options [Array] the options for verifying the claims. @return [Boolean] true if the claims are valid, false otherwise

# File lib/jwt/claims.rb, line 61
def valid_payload?(payload, *options)
  payload_errors(payload, *options).empty?
end
verify!(payload, options) click to toggle source

@deprecated Use {verify_payload!} instead. Will be removed in the next major version of ruby-jwt.

# File lib/jwt/claims.rb, line 37
def verify!(payload, options)
  Deprecations.warning('The ::JWT::Claims.verify! method is deprecated will be removed in the next major version of ruby-jwt')
  DecodeVerifier.verify!(payload, options)
end
verify_payload!(payload, *options) click to toggle source

Checks if the claims in the JWT payload are valid. @example

::JWT::Claims.verify_payload!({"exp" => Time.now.to_i + 10}, :exp)
::JWT::Claims.verify_payload!({"exp" => Time.now.to_i - 10}, exp: { leeway: 11})

@param payload [Hash] the JWT payload. @param options [Array] the options for verifying the claims. @return [void] @raise [JWT::DecodeError] if any claim is invalid.

# File lib/jwt/claims.rb, line 52
def verify_payload!(payload, *options)
  Verifier.verify!(VerificationContext.new(payload: payload), *options)
end