Class: OCI::Signer

Inherits:
BaseSigner show all
Defined in:
lib/oci/signer.rb

Overview

Used to sign HTTP requests as required by Oracle Cloud Infrastructure.

Constant Summary collapse

SIGNING_STRATEGY_ENUM =

enum to define the signing strategy

[STANDARD = 'standard', OBJECT_STORAGE = 'object_storage']

Constants inherited from BaseSigner

BaseSigner::BODY_HEADERS, BaseSigner::GENERIC_HEADERS, BaseSigner::SIGNATURE_VERSION

Instance Method Summary collapse

Methods inherited from BaseSigner

#sign

Constructor Details

#initialize(user, fingerprint, tenancy, private_key_file, pass_phrase: nil, private_key_content: nil, signing_strategy: STANDARD) ⇒ Signer

Creates a Signer

Parameters:

  • user (String)

    OCID of the user to be used for authentication, for example “ocidv1:user:oc1:phx:1460406592659:aaaaaaaawcbqrkycbolrirg2n3xjl5fyxe”.

  • fingerprint (String)

    Fingerprint of the key used for authentication, for example “20:3b:97:13:55:1c:5b:0d:d3:37:d8:50:4e:c5:3a:34”

  • tenancy (String)

    OCID of the tenancy

  • private_key_file (String)

    It can be nil if private_key_content is provided. Full path and filename of the unencrypted PEM file, for example “/Users/bgustafs/.ssh/id_rsa.pem”

  • pass_phrase (String) (defaults to: nil)

    Optional pass phrase used to encrypt the private key

  • private_key_content (String) (defaults to: nil)

    Optional if private_key_file is provided. The value should be the content of the unencrypted PEM file.

  • signing_strategy (SIGNING_STRATEGY_ENUM) (defaults to: STANDARD)

    Optional signing for standard service or object storage service



21
22
23
24
25
26
27
28
29
# File 'lib/oci/signer.rb', line 21

def initialize(user, fingerprint, tenancy, private_key_file, pass_phrase:nil, private_key_content:nil, signing_strategy:STANDARD)
  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 or private_key_content.' unless private_key_file || private_key_content

  private_key = private_key_content.nil? ? File.read(private_key_file) : private_key_content
  super("#{tenancy}/#{user}/#{fingerprint}", private_key, pass_phrase: pass_phrase, signing_strategy: signing_strategy)
end