Class: JWT::Claims::Required
- Inherits:
-
Object
- Object
- JWT::Claims::Required
- Defined in:
- lib/jwt/claims/required.rb
Instance Method Summary collapse
-
#initialize(required_claims:) ⇒ Required
constructor
A new instance of Required.
- #verify!(context:, **_args) ⇒ Object
Constructor Details
#initialize(required_claims:) ⇒ Required
Returns a new instance of Required.
6 7 8 |
# File 'lib/jwt/claims/required.rb', line 6 def initialize(required_claims:) @required_claims = required_claims end |
Instance Method Details
#verify!(context:, **_args) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/jwt/claims/required.rb', line 10 def verify!(context:, **_args) required_claims.each do |required_claim| next if context.payload.is_a?(Hash) && context.payload.key?(required_claim) raise JWT::MissingRequiredClaim, "Missing required claim #{required_claim}" end end |