Class: ActionDispatch::Request
Instance Method Summary
collapse
#hmac_token, #sign_headers
Instance Method Details
#hmac_api_id(auth_prefix = '\w+') ⇒ Object
5
6
7
8
|
# File 'lib/action-dispatch/request.rb', line 5
def hmac_api_id(auth_prefix='\w+')
result = parse_hmac(auth_prefix)
result && result[1]
end
|
#hmac_valid?(api_secret, options = {}) ⇒ Boolean
10
11
12
13
14
15
16
17
18
|
# File 'lib/action-dispatch/request.rb', line 10
def hmac_valid?(api_secret, options={})
options = { timeout_seconds: 900, auth_prefix: '\w+' }.merge(options)
timeout_seconds = options.delete :timeout_seconds
auth_prefix = options.delete :auth_prefix
result = parse_hmac(auth_prefix)
result &&
((Time.now.utc - Time.httpdate(timestamp).utc < timeout_seconds) rescue false) &&
result[2] == hmac_token(request_method, content_type, calculate_content_md5, url, timestamp, api_secret, options)
end
|