Class: DistributedPress::V1::Social::SignedHeaders
- Inherits:
-
Hash
- Object
- Hash
- DistributedPress::V1::Social::SignedHeaders
- Defined in:
- lib/distributed_press/v1/social/signed_headers.rb
Overview
Headers need to be signed by knowing the HTTP method (verb) and path. Since we’re using caching, we need to change the signature after it’s changed.
Constant Summary collapse
- ALGORITHM =
TODO:
is it possible to use other algorithms?
Signing algorithm
'rsa-sha256'
- REQUEST_TARGET =
Required by HTTP Signatures
'(request-target)'
- SIGNABLE_HEADERS =
Headers included in the signature rubocop:disable Style/MutableConstant
[REQUEST_TARGET, 'Host', 'Date', 'Digest']
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#to_hash ⇒ Hash
Takes advantage of HTTParty::Request.setup_raw_request running to_hash on the headers, so we sign as soon as we’re ready to send the request.
Instance Attribute Details
#private_key ⇒ OpenSSL::PKey::RSA
27 28 29 |
# File 'lib/distributed_press/v1/social/signed_headers.rb', line 27 def private_key @private_key end |
#public_key_url ⇒ String
30 31 32 |
# File 'lib/distributed_press/v1/social/signed_headers.rb', line 30 def public_key_url @public_key_url end |
#request ⇒ HTTParty::Request
24 25 26 |
# File 'lib/distributed_press/v1/social/signed_headers.rb', line 24 def request @request end |
Instance Method Details
#to_hash ⇒ Hash
Takes advantage of HTTParty::Request.setup_raw_request running to_hash on the headers, so we sign as soon as we’re ready to send the request.
37 38 39 40 41 42 43 |
# File 'lib/distributed_press/v1/social/signed_headers.rb', line 37 def to_hash request_target! sign_headers! # xxx: converts to an actual Hash to facilitate marshaling super.to_h end |