module JwtClaims

Constants

VERSION

Public Instance Methods

verified(claims, options) click to toggle source
# File lib/jwt_claims.rb, line 20
def verified(claims, options)
  rejected_claims = Validation.rejected(claims, options)
  return {ok: claims} if rejected_claims.empty?
  {error: rejected_claims}
end
verify(jwt, options) click to toggle source

@param jwt [String] JSON web token @param options [Hash] expected values for certain claims;

optional keys include: :aud, :iss, :jti, :sub, :leeway_seconds

@return [Hash] { ok: { the jwt claims set hash } }, or { error: [symbols of all rejected claims] }

# File lib/jwt_claims.rb, line 12
def verify(jwt, options)
  hsh = JsonWebToken.verify(jwt, options)
  return {error: 'invalid JWT'} if hsh[:error]
  claims = hsh[:ok]
  return {error: 'invalid input'} unless claims
  verified(claims, options)
end