Class: Rack::Authenticate::Client
- Inherits:
-
Object
- Object
- Rack::Authenticate::Client
- Defined in:
- lib/rack/authenticate/client.rb
Instance Attribute Summary collapse
-
#access_id ⇒ Object
readonly
Returns the value of attribute access_id.
-
#secret_key ⇒ Object
readonly
Returns the value of attribute secret_key.
Instance Method Summary collapse
-
#initialize(access_id, secret_key) ⇒ Client
constructor
A new instance of Client.
- #request_signature_headers(method, url, content_type = nil, content = nil) ⇒ Object
Constructor Details
#initialize(access_id, secret_key) ⇒ Client
Returns a new instance of Client.
9 10 11 |
# File 'lib/rack/authenticate/client.rb', line 9 def initialize(access_id, secret_key) @access_id, @secret_key = access_id, secret_key end |
Instance Attribute Details
#access_id ⇒ Object (readonly)
Returns the value of attribute access_id.
8 9 10 |
# File 'lib/rack/authenticate/client.rb', line 8 def access_id @access_id end |
#secret_key ⇒ Object (readonly)
Returns the value of attribute secret_key.
8 9 10 |
# File 'lib/rack/authenticate/client.rb', line 8 def secret_key @secret_key end |
Instance Method Details
#request_signature_headers(method, url, content_type = nil, content = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rack/authenticate/client.rb', line 13 def request_signature_headers(method, url, content_type = nil, content = nil) {}.tap do |headers| headers['Date'] = date = Time.now.httpdate request = [method.to_s.upcase, url, date] if content_md5 = content_md5_for(content_type, content) headers['Content-MD5'] = content_md5 request += [content_type, content_md5] end digest = HMAC::SHA1.hexdigest(secret_key, request.join("\n")) headers['Authorization'] = "HMAC #{access_id}:#{digest}" end end |