Class: Warden::Auth0::Strategy
- Inherits:
-
Strategies::Base
- Object
- Strategies::Base
- Warden::Auth0::Strategy
- Defined in:
- lib/warden/auth0/strategy.rb
Overview
Warden strategy to authenticate a user through a JWT token in the ‘Authorization` request header
Instance Method Summary collapse
Instance Method Details
#authenticate! ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/warden/auth0/strategy.rb', line 18 def authenticate! raise Errors::WrongIssuer, 'wrong issuer' unless issuer_claim_valid? raise Errors::WrongAud, 'wrong audience' unless aud_claim_valid? resolver_method = "#{scope}_resolver" raise "unimplemented resolver #{resolver_method}" unless respond_to?(resolver_method) user = send(resolver_method, decoded_token) raise Warden::Auth0::Errors::NilUser, 'nil user' unless user success!(user) rescue JWT::DecodeError => e puts "Failing to authenticate with #{e.}" fail!(e.) end |
#store? ⇒ Boolean
14 15 16 |
# File 'lib/warden/auth0/strategy.rb', line 14 def store? false end |
#valid? ⇒ Boolean
10 11 12 |
# File 'lib/warden/auth0/strategy.rb', line 10 def valid? token_exists? && issuer_claim_valid? && aud_claim_valid? end |