Class: Drillbit::Requests::Rack

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

Constant Summary collapse

ACCEPT_PARAM_PATTERN =
/(?:\A|&)accept=(.+?)(?=\z|&)/
BASE64_TOKEN_PARAM_PATTERN =
/(?:\A|&)#{BASE64_TOKEN_PARAM_NAME}=(.*)(?=\z|&)/
JSON_WEB_TOKEN_PARAM_PATTERN =
/(?:\A|&)#{JSON_WEB_TOKEN_PARAM_NAME}=(.*)(?=\z|&)/

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



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/drillbit/requests/rack.rb', line 16

def authorization_token_from_params
  case request['QUERY_STRING']
  when JSON_WEB_TOKEN_PARAM_PATTERN
    Tokens::JsonWebToken.__send__(
      "from_#{Drillbit.configuration.token_type.downcase}",
      request['QUERY_STRING'][JSON_WEB_TOKEN_PARAM_PATTERN, 1] || '',
      private_key: token_private_key,
    )
  when BASE64_TOKEN_PARAM_PATTERN
    base64_token = request['QUERY_STRING'][BASE64_TOKEN_PARAM_PATTERN, 1]

    Tokens::Base64.convert(raw_token: base64_token)
  else
    Tokens::Null.instance
  end
end