Class: SignedUrl::UrlEncoder
- Inherits:
-
Object
- Object
- SignedUrl::UrlEncoder
- Defined in:
- lib/signed_url.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#key_id ⇒ Object
Returns the value of attribute key_id.
-
#secret ⇒ Object
Returns the value of attribute secret.
Instance Method Summary collapse
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
33 34 35 |
# File 'lib/signed_url.rb', line 33 def host @host end |
#key_id ⇒ Object
Returns the value of attribute key_id.
33 34 35 |
# File 'lib/signed_url.rb', line 33 def key_id @key_id end |
#secret ⇒ Object
Returns the value of attribute secret.
33 34 35 |
# File 'lib/signed_url.rb', line 33 def secret @secret end |
Instance Method Details
#encode(path:, expires:) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/signed_url.rb', line 35 def encode(path:, expires:) expires = expires.to_i digest = OpenSSL::Digest.new('sha256') hmac = OpenSSL::HMAC.digest(digest, @secret, "GET\n\n\n#{expires}\n/#{path}") signature = CGI.escape(URI.escape(Base64.encode64(hmac).strip)) generate_url(host: @host, path: path, access_key_id: @key_id, expires: expires, signature: signature) end |