Sha256: 235ddc8c1445898e6b34940fe9dd87fe62f5f7e0ac39db0c7382fc1687d22a1b

Contents?: true

Size: 520 Bytes

Versions: 4

Compression:

Stored size: 520 Bytes

Contents

# frozen_string_literal: true

module JWT
  module Claims
    class Required
      def initialize(required_claims:)
        @required_claims = required_claims
      end

      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

      private

      attr_reader :required_claims
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jwt-2.9.3 lib/jwt/claims/required.rb
jwt-2.9.2 lib/jwt/claims/required.rb
jwt-2.9.1 lib/jwt/claims/required.rb
jwt-2.9.0 lib/jwt/claims/required.rb