Class: RubySlime::JWTKit::GenericVerifier
- Inherits:
-
Object
- Object
- RubySlime::JWTKit::GenericVerifier
- Defined in:
- lib/ruby_slime/jwt_kit/generic_verifier.rb
Direct Known Subclasses
Instance Method Summary collapse
- #call(token) ⇒ Object
-
#initialize(fetch_secret:, handle_result:, required_claims:, payload_schema:) ⇒ GenericVerifier
constructor
A new instance of GenericVerifier.
Constructor Details
#initialize(fetch_secret:, handle_result:, required_claims:, payload_schema:) ⇒ GenericVerifier
Returns a new instance of GenericVerifier.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ruby_slime/jwt_kit/generic_verifier.rb', line 6 def initialize( fetch_secret:, handle_result:, required_claims:, payload_schema: ) @fetch_secret = fetch_secret @handle_result = handle_result @required_claims = required_claims @payload_schema = payload_schema end |
Instance Method Details
#call(token) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ruby_slime/jwt_kit/generic_verifier.rb', line 18 def call(token) validated_cache = {} ::JWT.decode(token, nil, true, { algorithm: 'HS256', required_claims: @required_claims, }) do |header_section| @fetch_secret.call( validated_cache[:header] ||= check_jwt_section(header_section, P_GenericCache.instance.header_schema), ) end.then do |sections| payload_section, header_section = sections [ validated_cache[:header] ||= check_jwt_section(header_section, P_GenericCache.instance.header_schema), validated_cache[:payload] ||= check_jwt_section(payload_section, @payload_schema), ].reverse end.then do |sections| @handle_result.call(*sections) end end |