Class: RailsIam::Authentication::BearerExtractor

Inherits:
RailsIamService show all
Defined in:
app/services/rails_iam/authentication/token_extractor.rb

Instance Method Summary collapse

Methods inherited from RailsIamService

call

Methods included from ConfigLoader

#authentication_strategies, #authorization_rule_error, #cookie_options, #jwt_algorithm, #jwt_audience, #jwt_expiry, #jwt_issuer, #jwt_secret_key, #refresh_token_transport, #session_strategy, #user_class

Constructor Details

#initialize(request) ⇒ BearerExtractor

Returns a new instance of BearerExtractor.



21
22
23
24
# File 'app/services/rails_iam/authentication/token_extractor.rb', line 21

def initialize(request)
  super()
  @request = request
end

Instance Method Details

#callObject



26
27
28
29
30
31
32
33
# File 'app/services/rails_iam/authentication/token_extractor.rb', line 26

def call
  authorization = request.headers["Authorization"]
  return if authorization.blank?

  scheme, token = authorization.split(" ", 2)

  scheme == "Bearer" ? token : nil
end