class JWT::Claims::Crit
Responsible of validation the crit header
def initialize(expected_crits:)
-
expected_crits
(String
) -- the expected crit header values for the JWT token.
def initialize(expected_crits:) @expected_crits = Array(expected_crits) end
def verify!(context:, **_args)
-
(nil)
-
Raises:
-
(JWT::InvalidCritError)
- if the crit claim is invalid.
Parameters:
-
_args
(Hash
) -- additional arguments (not used). -
context
(Object
) -- the context containing the JWT payload and header.
def verify!(context:, **_args) raise(JWT::InvalidCritError, 'Crit header missing') unless context.header['crit'] raise(JWT::InvalidCritError, 'Crit header should be an array') unless context.header['crit'].is_a?(Array) missing = (expected_crits - context.header['crit']) raise(JWT::InvalidCritError, "Crit header missing expected values: #{missing.join(', ')}") if missing.any? nil end