module JwtClaims::Validation
Validate registered claims @see tools.ietf.org/html/rfc7519#section-4.1
Public Instance Methods
registered_claim(sym)
click to toggle source
# File lib/jwt_claims/validation.rb, line 32 def registered_claim(sym) case sym when :aud then Claim::Aud when :exp then Claim::Exp when :iat then Claim::Iat when :iss then Claim::Iss when :jti then Claim::Jti when :nbf then Claim::Nbf when :sub then Claim::Sub else nil # custom claim end end
reject(key, val, options)
click to toggle source
# File lib/jwt_claims/validation.rb, line 27 def reject(key, val, options) return unless reg_claim = registered_claim(key) key if reg_claim.reject?(val, options) end
rejected(claims, options = {})
click to toggle source
@param claims [Hash] JWT claims @param options [Hash] expected values for certain claims
optional keys include: :aud, :iss, :jti, :sub, :leeway_seconds
@return [Array] symbols of the registered claims that fail validation
# File lib/jwt_claims/validation.rb, line 20 def rejected(claims, options = {}) claims.each_with_object([]) do |claim, memo| sym = reject(*claim, options) memo << sym if sym end end