Class: UriSigner::UriSignature
- Inherits:
-
Object
- Object
- UriSigner::UriSignature
- Defined in:
- lib/uri_signer/uri_signature.rb
Overview
This is the object that will be used to verify properly signed API URI requests The #secret is stored in the persistence layer for comparison. There is an API Key and a shared secret. All requests will be signed with the shared secret. The URI will also include a _signature param, where the client will sign the request and store it in the URI.
The signing algorithm looks like this:
Instance Method Summary collapse
-
#initialize(signature_string, secret) ⇒ void
constructor
Create a new UriSignature instance.
-
#signature ⇒ String
(also: #to_s)
Return the signature_string after being signed with the secret.
-
#signature_string ⇒ String
Return the signature string that was provided in the constructor.
Constructor Details
#initialize(signature_string, secret) ⇒ void
Create a new UriSignature instance
39 40 41 42 43 44 45 |
# File 'lib/uri_signer/uri_signature.rb', line 39 def initialize(signature_string, secret) @signature_string = signature_string @secret = secret raise UriSigner::Errors::MissingSignatureStringError.new("Please provide a string to sign") unless signature_string? raise UriSigner::Errors::MissingSecretError.new("Please provide a secret to sign the string") unless secret? end |
Instance Method Details
#signature ⇒ String Also known as: to_s
Return the signature_string after being signed with the secret
57 58 59 |
# File 'lib/uri_signer/uri_signature.rb', line 57 def signature @signature ||= sign! end |
#signature_string ⇒ String
Return the signature string that was provided in the constructor
50 51 52 |
# File 'lib/uri_signer/uri_signature.rb', line 50 def signature_string @signature_string end |