Class: JWT::Claims::Crit
- Inherits:
-
Object
- Object
- JWT::Claims::Crit
- Defined in:
- lib/jwt/claims/crit.rb
Overview
Responsible of validation the crit header
Instance Method Summary collapse
-
#initialize(expected_crits:) ⇒ Crit
constructor
Initializes a new Crit instance.
-
#verify!(context:, **_args) ⇒ nil
Verifies the critical claim (‘crit’) in the JWT token header.
Constructor Details
#initialize(expected_crits:) ⇒ Crit
Initializes a new Crit instance.
10 11 12 |
# File 'lib/jwt/claims/crit.rb', line 10 def initialize(expected_crits:) @expected_crits = Array(expected_crits) end |
Instance Method Details
#verify!(context:, **_args) ⇒ nil
Verifies the critical claim (‘crit’) in the JWT token header.
20 21 22 23 24 25 26 27 28 |
# File 'lib/jwt/claims/crit.rb', line 20 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 |