Class: OracleBMC::Signer
- Inherits:
-
Object
- Object
- OracleBMC::Signer
- Defined in:
- lib/oraclebmc/signer.rb
Overview
Used to sign HTTP requests as required by Oracle Bare Metal Cloud services.
Constant Summary collapse
- SIGNATURE_VERSION =
The Oracle Bare Metal Cloud Services API signature version
"1"
Instance Method Summary collapse
-
#initialize(user, fingerprint, tenancy, private_key_file, pass_phrase: nil) ⇒ Signer
constructor
Creates a Signer.
-
#sign(method, uri, headers, body) ⇒ Object
Generates the correct signature and adds it to the headers that are passed in.
Constructor Details
#initialize(user, fingerprint, tenancy, private_key_file, pass_phrase: nil) ⇒ Signer
Creates a Signer
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/oraclebmc/signer.rb', line 26 def initialize(user, fingerprint, tenancy, private_key_file, pass_phrase:nil) fail 'Missing required parameter user.' unless user fail 'Missing required parameter fingerprint.' unless fingerprint fail 'Missing required parameter tenancy.' unless tenancy fail 'Missing required parameter private_key_file.' unless private_key_file @key_id = tenancy + "/" + user + "/" + fingerprint @private_key_file = private_key_file @pass_phrase = pass_phrase end |
Instance Method Details
#sign(method, uri, headers, body) ⇒ Object
Generates the correct signature and adds it to the headers that are passed in. Also injects any required headers that might be missing.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/oraclebmc/signer.rb', line 45 def sign(method, uri, headers, body) method = method.to_sym.downcase uri = URI(uri) path = uri.query.nil? ? uri.path : "#{uri.path}?#{uri.query}" inject_missing_headers(method, headers, body, uri) signature = compute_signature(headers, method, path) unless signature.nil? (headers, method, signature) end end |