Class: JWT::Claims::Subject

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

Instance Method Summary collapse

Constructor Details

#initialize(expected_subject:) ⇒ Subject

Returns a new instance of Subject.



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

def initialize(expected_subject:)
  @expected_subject = expected_subject.to_s
end

Instance Method Details

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



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

def verify!(context:, **_args)
  sub = context.payload['sub']
  raise(JWT::InvalidSubError, "Invalid subject. Expected #{expected_subject}, received #{sub || '<none>'}") unless sub.to_s == expected_subject
end