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
@private
Public Class Methods
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 67 def payload_errors(payload, *options) token_errors(VerificationContext.new(payload: payload), *options) end
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 59 def valid_payload?(payload, *options) payload_errors(payload, *options).empty? end
@deprecated Use {verify_payload!} instead. Will be removed in the next major version of ruby-jwt.
# File lib/jwt/claims.rb, line 36 def verify!(payload, options) DecodeVerifier.verify!(payload, options) end
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 50 def verify_payload!(payload, *options) verify_token!(VerificationContext.new(payload: payload), *options) end
Private Class Methods
# File lib/jwt/claims.rb, line 77 def token_errors(token, *options) Verifier.errors(token, *options) end
# File lib/jwt/claims.rb, line 73 def verify_token!(token, *options) Verifier.verify!(token, *options) end