Class: Mach::Request
- Inherits:
-
Rack::Request
- Object
- Rack::Request
- Mach::Request
show all
- Includes:
- HMAC
- Defined in:
- lib/mach/request.rb
Instance Method Summary
collapse
Methods included from HMAC
#mac_host, #mac_path, #mac_port, #mac_request_method
Instance Method Details
#authorization ⇒ Object
8
9
10
|
# File 'lib/mach/request.rb', line 8
def authorization
@env['HTTP_AUTHORIZATION']
end
|
#mac_authorization? ⇒ Boolean
12
13
14
|
# File 'lib/mach/request.rb', line 12
def mac_authorization?
!!(self.authorization =~ /^\s*MAC .*$/)
end
|
#mac_ext ⇒ Object
28
29
30
|
# File 'lib/mach/request.rb', line 28
def mac_ext
self.authorization.scan(/^\s*MAC\s*.*ext="(.*?)".*/).flatten[0]
end
|
#mac_id ⇒ Object
16
17
18
|
# File 'lib/mach/request.rb', line 16
def mac_id
self.authorization.scan(/^\s*MAC\s*.*id="(.*?)".*/).flatten[0]
end
|
#mac_nonce ⇒ Object
24
25
26
|
# File 'lib/mach/request.rb', line 24
def mac_nonce
self.authorization.scan(/^\s*MAC\s*.*nonce="(.*?)".*/).flatten[0]
end
|
#mac_normalized_request_string ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/mach/request.rb', line 36
def mac_normalized_request_string
if mac_authorization?
NormalizedString.new(:timestamp => mac_timestamp,
:nonce => mac_nonce,
:request_method => request_method,
:path => mac_path(path, query_string),
:host => host,
:port => mac_port(self.port, self.scheme),
:ext => mac_ext
).to_s
else
""
end
end
|
#mac_signature ⇒ Object
32
33
34
|
# File 'lib/mach/request.rb', line 32
def mac_signature
self.authorization.scan(/^\s*MAC\s*.*mac="(.*?)".*/).flatten[0]
end
|
#mac_timestamp ⇒ Object
20
21
22
|
# File 'lib/mach/request.rb', line 20
def mac_timestamp
self.authorization.scan(/^\s*MAC\s*.*ts="(.*?)".*/).flatten[0]
end
|