Sha256: a54c68bc3d37702eda4538aef54e3e385e774ff54e1fa1ad869260c7d442ffa6

Contents?: true

Size: 488 Bytes

Versions: 4

Compression:

Stored size: 488 Bytes

Contents

# frozen_string_literal: true

module JWT
  module Claims
    class Audience
      def initialize(expected_audience:)
        @expected_audience = expected_audience
      end

      def verify!(context:, **_args)
        aud = context.payload['aud']
        raise JWT::InvalidAudError, "Invalid audience. Expected #{expected_audience}, received #{aud || '<none>'}" if ([*aud] & [*expected_audience]).empty?
      end

      private

      attr_reader :expected_audience
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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