Class: Drillbit::Requests::Rails

Inherits:
Base
  • Object
show all
Defined in:
lib/drillbit/requests/rails.rb

Constant Summary

Constants inherited from Base

Base::BASE64_PATTERN, Base::BASE64_TOKEN_HEADER_PATTERN, Base::BASE64_TOKEN_PARAM_NAME, Base::JSON_WEB_TOKEN_HEADER_PATTERN, Base::JSON_WEB_TOKEN_PARAM_NAME, Base::JSON_WEB_TOKEN_PATTERN

Instance Attribute Summary

Attributes inherited from Base

#request, #token_private_key

Instance Method Summary collapse

Methods inherited from Base

#accept_header, #application_name, #authorization_token, #initialize, rack_request_class, rails_request_class, resolve, #subdomain

Constructor Details

This class inherits a constructor from Drillbit::Requests::Base

Instance Method Details

#authorization_token_from_paramsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/drillbit/requests/rails.rb', line 12

def authorization_token_from_params
  if request.params.has_key?(JSON_WEB_TOKEN_PARAM_NAME)
    Tokens::JsonWebToken.__send__(
      "from_#{Drillbit.configuration.token_type.downcase}",
      request.params[JSON_WEB_TOKEN_PARAM_NAME] || '',
      private_key: token_private_key,
    )
  elsif request.params.has_key?(BASE64_TOKEN_PARAM_NAME)
    Tokens::Base64.convert(raw_token: request.params[BASE64_TOKEN_PARAM_NAME] || '')
  else
    Tokens::Null.instance
  end
end