Class: ApiAuth::RequestDrivers::CurbRequest

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/api_auth/request_drivers/curb.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from Helpers

#b64_encode, #capitalize_keys, #md5_base64digest

Constructor Details

#initialize(request) ⇒ CurbRequest

Returns a new instance of CurbRequest.


6
7
8
9
10
# File 'lib/api_auth/request_drivers/curb.rb', line 6

def initialize(request)
  @request = request
  fetch_headers
  true
end

Instance Method Details

#authorization_headerObject


59
60
61
# File 'lib/api_auth/request_drivers/curb.rb', line 59

def authorization_header
  find_header %w[Authorization AUTHORIZATION HTTP_AUTHORIZATION]
end

#content_md5Object


38
39
40
# File 'lib/api_auth/request_drivers/curb.rb', line 38

def content_md5
  find_header(%w[CONTENT-MD5 CONTENT_MD5])
end

#content_typeObject


34
35
36
# File 'lib/api_auth/request_drivers/curb.rb', line 34

def content_type
  find_header(%w[CONTENT-TYPE CONTENT_TYPE HTTP_CONTENT_TYPE])
end

#fetch_headersObject


26
27
28
# File 'lib/api_auth/request_drivers/curb.rb', line 26

def fetch_headers
  @headers = capitalize_keys @request.headers
end

#http_methodObject


30
31
32
# File 'lib/api_auth/request_drivers/curb.rb', line 30

def http_method
  nil # not possible to get the method at this layer
end

#md5_mismatch?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'lib/api_auth/request_drivers/curb.rb', line 22

def md5_mismatch?
  false
end

#original_uriObject


42
43
44
# File 'lib/api_auth/request_drivers/curb.rb', line 42

def original_uri
  find_header(%w[X-ORIGINAL-URI X_ORIGINAL_URI HTTP_X_ORIGINAL_URI])
end

#populate_content_md5Object


18
19
20
# File 'lib/api_auth/request_drivers/curb.rb', line 18

def populate_content_md5
  nil # doesn't appear to be possible
end

#request_uriObject


46
47
48
# File 'lib/api_auth/request_drivers/curb.rb', line 46

def request_uri
  @request.url
end

#set_auth_header(header) ⇒ Object


12
13
14
15
16
# File 'lib/api_auth/request_drivers/curb.rb', line 12

def set_auth_header(header)
  @request.headers['Authorization'] = header
  fetch_headers
  @request
end

#set_dateObject


50
51
52
53
# File 'lib/api_auth/request_drivers/curb.rb', line 50

def set_date
  @request.headers['DATE'] = Time.now.utc.httpdate
  fetch_headers
end

#timestampObject


55
56
57
# File 'lib/api_auth/request_drivers/curb.rb', line 55

def timestamp
  find_header(%w[DATE HTTP_DATE])
end