Class: JWT::Claims::Audience

Inherits:
Object
  • Object
show all
Defined in:
lib/jwt/claims/audience.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected_audience:) ⇒ Audience

Returns a new instance of Audience.



6
7
8
# File 'lib/jwt/claims/audience.rb', line 6

def initialize(expected_audience:)
  @expected_audience = expected_audience
end

Instance Method Details

#verify!(context:, **_args) ⇒ Object



10
11
12
13
# File 'lib/jwt/claims/audience.rb', line 10

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