Module: Devise::JWT::TestHelpers
- Defined in:
- lib/devise/jwt/test_helpers.rb
Overview
Helpers to make testing authorization through JWT easier
Class Method Summary collapse
-
.auth_headers(headers, user, scope: nil, aud: nil) ⇒ Object
Returns headers with a valid token in the ‘Authorization` header added.
Class Method Details
.auth_headers(headers, user, scope: nil, aud: nil) ⇒ Object
Returns headers with a valid token in the ‘Authorization` header added.
Be aware that a fresh copy of ‘headers` is returned with the new key/value pair added, instead of modifying given argument.
autodetected. the header name configured in ‘Devise::JWT.config.aud_header`.
:reek:LongParameterList
21 22 23 24 25 26 27 28 |
# File 'lib/devise/jwt/test_helpers.rb', line 21 def self.auth_headers(headers, user, scope: nil, aud: nil) scope ||= Devise::Mapping.find_scope!(user) aud ||= headers[Warden::JWTAuth.config.aud_header] token, _payload = Warden::JWTAuth::UserEncoder.new.call( user, scope, aud ) Warden::JWTAuth::HeaderParser.to_headers(headers, token) end |