Class: ApiAuth::RequestDrivers::RackRequest
- Inherits:
-
Object
- Object
- ApiAuth::RequestDrivers::RackRequest
show all
- Includes:
- Helpers
- Defined in:
- lib/api_auth/request_drivers/rack.rb
Overview
Instance Method Summary
collapse
Methods included from Helpers
#b64_encode, #capitalize_keys, #md5_base64digest
Constructor Details
#initialize(request) ⇒ RackRequest
Returns a new instance of RackRequest.
6
7
8
9
10
|
# File 'lib/api_auth/request_drivers/rack.rb', line 6
def initialize(request)
@request = request
true
end
|
Instance Method Details
75
76
77
|
# File 'lib/api_auth/request_drivers/rack.rb', line 75
def
%w(Authorization AUTHORIZATION HTTP_AUTHORIZATION)
end
|
#calculated_md5 ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'lib/api_auth/request_drivers/rack.rb', line 18
def calculated_md5
if @request.body
body = @request.body.read
@request.body.rewind
else
body = ''
end
md5_base64digest(body)
end
|
#content_md5 ⇒ Object
56
57
58
59
|
# File 'lib/api_auth/request_drivers/rack.rb', line 56
def content_md5
value = (%w(CONTENT-MD5 CONTENT_MD5 HTTP-CONTENT-MD5 HTTP_CONTENT_MD5))
value.nil? ? '' : value
end
|
#content_type ⇒ Object
51
52
53
54
|
# File 'lib/api_auth/request_drivers/rack.rb', line 51
def content_type
value = (%w(CONTENT-TYPE CONTENT_TYPE HTTP_CONTENT_TYPE))
value.nil? ? '' : value
end
|
43
44
45
|
# File 'lib/api_auth/request_drivers/rack.rb', line 43
def
@headers = capitalize_keys @request.env
end
|
#http_method ⇒ Object
47
48
49
|
# File 'lib/api_auth/request_drivers/rack.rb', line 47
def http_method
@request.request_method.upcase
end
|
#md5_mismatch? ⇒ Boolean
35
36
37
38
39
40
41
|
# File 'lib/api_auth/request_drivers/rack.rb', line 35
def md5_mismatch?
if %w(POST PUT).include?(@request.request_method)
calculated_md5 != content_md5
else
false
end
end
|
#populate_content_md5 ⇒ Object
28
29
30
31
32
33
|
# File 'lib/api_auth/request_drivers/rack.rb', line 28
def populate_content_md5
if %w(POST PUT).include?(@request.request_method)
@request.env['Content-MD5'] = calculated_md5
end
end
|
#request_uri ⇒ Object
61
62
63
|
# File 'lib/api_auth/request_drivers/rack.rb', line 61
def request_uri
@request.fullpath
end
|
12
13
14
15
16
|
# File 'lib/api_auth/request_drivers/rack.rb', line 12
def ()
@request.env['Authorization'] =
@request
end
|
#set_date ⇒ Object
65
66
67
68
|
# File 'lib/api_auth/request_drivers/rack.rb', line 65
def set_date
@request.env['DATE'] = Time.now.utc.httpdate
end
|
#timestamp ⇒ Object
70
71
72
73
|
# File 'lib/api_auth/request_drivers/rack.rb', line 70
def timestamp
value = (%w(DATE HTTP_DATE))
value.nil? ? '' : value
end
|