oci 2.0.6 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -1
  3. data/lib/oci.rb +4 -7
  4. data/lib/oci/api_client.rb +51 -6
  5. data/lib/oci/auth/auth.rb +5 -2
  6. data/lib/oci/auth/federation_client.rb +2 -2
  7. data/lib/oci/auth/internal/auth_token_request_signer.rb +2 -2
  8. data/lib/oci/auth/security_token_container.rb +2 -2
  9. data/lib/oci/auth/session_key_supplier.rb +3 -4
  10. data/lib/oci/auth/signers/instance_principals_security_token_signer.rb +30 -17
  11. data/lib/oci/auth/signers/security_token_signer.rb +13 -6
  12. data/lib/oci/auth/signers/x509_federation_client_based_security_token_signer.rb +8 -4
  13. data/lib/oci/auth/url_based_certificate_retriever.rb +3 -4
  14. data/lib/oci/auth/util.rb +6 -4
  15. data/lib/oci/base_signer.rb +54 -50
  16. data/lib/oci/config_file_loader.rb +3 -11
  17. data/lib/oci/core/blockstorage_client.rb +211 -0
  18. data/lib/oci/core/compute_client.rb +4 -2
  19. data/lib/oci/core/core.rb +9 -0
  20. data/lib/oci/core/models/attach_i_scsi_volume_details.rb +5 -1
  21. data/lib/oci/core/models/attach_volume_details.rb +13 -1
  22. data/lib/oci/core/models/create_public_ip_details.rb +186 -0
  23. data/lib/oci/core/models/create_vnic_details.rb +8 -2
  24. data/lib/oci/core/models/create_volume_backup_details.rb +27 -1
  25. data/lib/oci/core/models/create_volume_backup_policy_assignment_details.rb +133 -0
  26. data/lib/oci/core/models/create_volume_details.rb +15 -1
  27. data/lib/oci/core/models/get_public_ip_by_ip_address_details.rb +125 -0
  28. data/lib/oci/core/models/get_public_ip_by_private_ip_id_details.rb +124 -0
  29. data/lib/oci/core/models/i_scsi_volume_attachment.rb +5 -1
  30. data/lib/oci/core/models/public_ip.rb +328 -0
  31. data/lib/oci/core/models/update_public_ip_details.rb +140 -0
  32. data/lib/oci/core/models/volume_attachment.rb +13 -1
  33. data/lib/oci/core/models/volume_backup.rb +72 -1
  34. data/lib/oci/core/models/volume_backup_policy.rb +161 -0
  35. data/lib/oci/core/models/volume_backup_policy_assignment.rb +159 -0
  36. data/lib/oci/core/models/volume_backup_schedule.rb +191 -0
  37. data/lib/oci/core/virtual_network_client.rb +374 -4
  38. data/lib/oci/database/database_client.rb +3 -1
  39. data/lib/oci/dns/dns.rb +34 -0
  40. data/lib/oci/dns/dns_client.rb +985 -0
  41. data/lib/oci/dns/models/create_zone_details.rb +174 -0
  42. data/lib/oci/dns/models/external_master.rb +145 -0
  43. data/lib/oci/dns/models/patch_domain_records_details.rb +120 -0
  44. data/lib/oci/dns/models/patch_rr_set_details.rb +120 -0
  45. data/lib/oci/dns/models/patch_zone_records_details.rb +120 -0
  46. data/lib/oci/dns/models/record.rb +204 -0
  47. data/lib/oci/dns/models/record_collection.rb +121 -0
  48. data/lib/oci/dns/models/record_details.rb +204 -0
  49. data/lib/oci/dns/models/record_operation.rb +253 -0
  50. data/lib/oci/dns/models/rr_set.rb +123 -0
  51. data/lib/oci/dns/models/sort_order.rb +12 -0
  52. data/lib/oci/dns/models/tsig.rb +149 -0
  53. data/lib/oci/dns/models/update_domain_records_details.rb +120 -0
  54. data/lib/oci/dns/models/update_rr_set_details.rb +120 -0
  55. data/lib/oci/dns/models/update_zone_details.rb +122 -0
  56. data/lib/oci/dns/models/update_zone_records_details.rb +120 -0
  57. data/lib/oci/dns/models/zone.rb +272 -0
  58. data/lib/oci/dns/models/zone_summary.rb +230 -0
  59. data/lib/oci/dns/util.rb +2 -0
  60. data/lib/oci/errors.rb +20 -0
  61. data/lib/oci/identity/identity_client.rb +1 -0
  62. data/lib/oci/identity/models/create_dynamic_group_details.rb +4 -2
  63. data/lib/oci/identity/models/dynamic_group.rb +9 -6
  64. data/lib/oci/identity/models/update_dynamic_group_details.rb +4 -2
  65. data/lib/oci/load_balancer/load_balancer.rb +6 -0
  66. data/lib/oci/load_balancer/load_balancer_client.rb +219 -0
  67. data/lib/oci/load_balancer/models/create_listener_details.rb +17 -1
  68. data/lib/oci/load_balancer/models/create_load_balancer_details.rb +12 -1
  69. data/lib/oci/load_balancer/models/create_path_route_set_details.rb +138 -0
  70. data/lib/oci/load_balancer/models/listener.rb +17 -1
  71. data/lib/oci/load_balancer/models/listener_details.rb +17 -1
  72. data/lib/oci/load_balancer/models/load_balancer.rb +12 -1
  73. data/lib/oci/load_balancer/models/path_match_type.rb +153 -0
  74. data/lib/oci/load_balancer/models/path_route.rb +161 -0
  75. data/lib/oci/load_balancer/models/path_route_set.rb +139 -0
  76. data/lib/oci/load_balancer/models/path_route_set_details.rb +122 -0
  77. data/lib/oci/load_balancer/models/update_listener_details.rb +17 -1
  78. data/lib/oci/load_balancer/models/update_path_route_set_details.rb +122 -0
  79. data/lib/oci/load_balancer/util.rb +1 -3
  80. data/lib/oci/object_storage/transfer/multipart/internal/file_part_io_wrapper.rb +111 -0
  81. data/lib/oci/object_storage/transfer/multipart/internal/multipart_upload_parts_collection.rb +41 -0
  82. data/lib/oci/object_storage/transfer/multipart/internal/seekable_non_file_part_io_wrapper.rb +48 -0
  83. data/lib/oci/object_storage/transfer/multipart/internal/stdin_part_io_wrapper.rb +54 -0
  84. data/lib/oci/object_storage/transfer/multipart/multipart_object_assembler.rb +545 -0
  85. data/lib/oci/object_storage/transfer/transfer.rb +31 -0
  86. data/lib/oci/object_storage/transfer/upload_manager.rb +212 -0
  87. data/lib/oci/object_storage/transfer/upload_manager_config.rb +60 -0
  88. data/lib/oci/regions.rb +3 -1
  89. data/lib/oci/response.rb +1 -3
  90. data/lib/oci/version.rb +1 -1
  91. data/lib/oci/waiter.rb +16 -11
  92. data/lib/oraclebmc.rb +1 -1
  93. metadata +46 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38b3af475a0f7eb30b1f26b775ae4121b5fdb7f8
4
- data.tar.gz: 245eb1ec30aacc7266559e3f9a8669593282fd30
3
+ metadata.gz: 38997be752356f7675ae441e8484117e64d915db
4
+ data.tar.gz: a69876808a735db9203b22f513c5001f87c1dd6d
5
5
  SHA512:
6
- metadata.gz: 45e486bdf5f719d842281e33fb05b98433346d786018009abb5d7c9b64b3d19dad1db37fa35d248f215baa5623fc78708e8f2136c6a6072ae075fcea7787c898
7
- data.tar.gz: 009fdb794589d0821d5c789e3ea332a2a62acb02f4c7ca3f8a06790442594add8e3af721d97c0c34ec193d6e91a57d97d89e865f53449ed076979705a5caf82f
6
+ metadata.gz: 2576ec59cbd7d9add589c6ec00d8c710804bfec442b89cb361cfd091a0e41e7fe1ca46ddbd882136378acc751794ef2ecec709d40f404d90584e992721f949a0
7
+ data.tar.gz: 45c2aa5111c5fc29fc99acfe918b5f7c8ce66a815df125e472b99801f9083b5229dcf0c7d71cd9be959b09fb240f1b18fe0637e0cc18fdb4d80e286e8d3172e5
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Oracle Cloud Infrastructure Ruby SDK
2
- **Version 2.0.6**
2
+ **Version 2.0.7**
3
3
 
4
4
  This topic describes how to install, configure, and use the Oracle Cloud Infrastructure Ruby SDK.
5
5
 
@@ -13,6 +13,7 @@ The Ruby SDK supports the following services:
13
13
  * Identity and Access Management Service
14
14
  * Load Balancing Service
15
15
  * Object Storage Service
16
+ * Domain Name System Service
16
17
 
17
18
  **Licensing:** This SDK and sample is dual licensed under the Universal Permissive License 1.0 and the Apache License.
18
19
 
@@ -55,6 +56,27 @@ The following table provides details about some of the attributes of the SDK.
55
56
  <td>The Ruby SDK uses Net::HTTP for HTTP requests, if needed, options may be passed to each Net::HTTP by specifying them in {OCI::ApiClient#request_option_overrides ApiClient.request_option_overrides}.</br>
56
57
  Please check http://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/Net/HTTP.html#method-c-start for the supported options.</td>
57
58
  </tr>
59
+ <tr>
60
+ <td>Instance Principals Authentication</td>
61
+ <td>
62
+ The Ruby SDK supports <a href="">Instance Principals</a> authentication via the use of the {OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner} class. An example of using Instance Principals authentication can be found in the examples folder of the Ruby SDK <a href="https://docs.us-phoenix-1.oraclecloud.com/tools/ruby/latest/download/oci-ruby-sdk.zip">download</a>
63
+ </td>
64
+ </tr>
65
+ <tr>
66
+ <td>Upload Manager</td>
67
+ <td>
68
+ The Object Storage service supports multipart uploads to make large object uploads easier by splitting the large object into parts. The Ruby SDK supports raw multipart upload operations for advanced use cases, as well as a higher-level upload class that uses the multipart upload APIs.
69
+ <p>
70
+ <a href="https://docs.us-phoenix-1.oraclecloud.com/Content/Object/Tasks/managingmultipartuploads.htm">Managing Multipart Uploads</a> provides links to the APIs used for raw multipart upload operations. Higher-level uploads can be performed using the {OCI::ObjectStorage::Transfer::UploadManager}.
71
+ </p>
72
+ <p>
73
+ The UploadManager simplifies interaction with the Object Storage service by abstracting away the method used to upload objects and can handle uploading an entire object at once, or in multiple parts if it is of sufficient size (which is configurable via a {OCI::ObjectStorage::Transfer::UploadManagerConfig} object). In the latter case, the UploadManager will split a large object into parts for you, upload the parts in parallel, and then recombine and commit the parts as a single object in Object Storage.
74
+ </p>
75
+ <p>
76
+ Examples of using the Upload Manager can be found in the examples folder of the Ruby SDK <a href="https://docs.us-phoenix-1.oraclecloud.com/tools/ruby/latest/download/oci-ruby-sdk.zip">download</a>
77
+ </p>
78
+ </td>
79
+ </tr>
58
80
  </tbody>
59
81
  </table>
60
82
 
data/lib/oci.rb CHANGED
@@ -15,22 +15,19 @@ require 'oci/version'
15
15
  require 'oci/waiter'
16
16
 
17
17
  require 'oci/auth/auth'
18
-
19
18
  require 'oci/audit/audit'
20
19
  require 'oci/core/core'
21
20
  require 'oci/database/database'
21
+ require 'oci/dns/dns'
22
22
  require 'oci/identity/identity'
23
23
  require 'oci/load_balancer/load_balancer'
24
24
  require 'oci/object_storage/object_storage'
25
+ require 'oci/object_storage/transfer/transfer'
25
26
 
26
27
  # Top level module for the Oracle Cloud Infrastructure SDK
27
28
  module OCI
28
- @@sdk_name = ''
29
- def self.sdk_name
30
- @@sdk_name
31
- end
32
- def self.sdk_name=(value)
33
- @@sdk_name = value
29
+ class << self
30
+ attr_accessor :sdk_name
34
31
  end
35
32
  end
36
33
 
@@ -14,6 +14,20 @@ require_relative 'response'
14
14
 
15
15
  module OCI
16
16
  class ApiClient
17
+ # Maps collection format types (as per the collectionFormat types described here:
18
+ # https://swagger.io/docs/specification/2-0/describing-parameters/) to the delimiters
19
+ # we should use to separate values.
20
+ #
21
+ # The :multi type contains no delimiter because this means we should preserve values as
22
+ # a collection rather than transforming them into a single string
23
+ VALID_COLLECTION_FORMATS = {
24
+ multi: nil,
25
+ csv: ',',
26
+ ssv: ' ',
27
+ tsv: "\t", # this is double quoted so it is interpreted as a tab rather than as a literal slash ('\') followed by a 't'
28
+ pipes: '|'
29
+ }
30
+
17
31
  # The Config object holding settings to be used in the API client.
18
32
  attr_accessor :config
19
33
 
@@ -113,6 +127,18 @@ module OCI
113
127
  agent
114
128
  end
115
129
 
130
+ def self.build_collection_params(collection, collection_format)
131
+ if collection_format.nil? || !VALID_COLLECTION_FORMATS.has_key?(collection_format.to_sym)
132
+ raise "Invalid collection_format: #{collection_format}. Must be one of: #{VALID_COLLECTION_FORMATS.keys}"
133
+ end
134
+
135
+ if collection_format == :multi
136
+ return collection
137
+ else
138
+ return collection.join(VALID_COLLECTION_FORMATS[collection_format.to_sym])
139
+ end
140
+ end
141
+
116
142
  private
117
143
 
118
144
  def call_api_inner(http_method, path, endpoint, opts, &block)
@@ -145,7 +171,7 @@ module OCI
145
171
  if body.respond_to?(:read) && body.respond_to?(:write)
146
172
  request.body_stream = body
147
173
  else
148
- if %i[post, put, delete].include?(http_method)
174
+ if %i[post, put, delete, patch].include?(http_method)
149
175
  body = build_request_body(header_params, form_params, body)
150
176
  end
151
177
 
@@ -253,23 +279,42 @@ module OCI
253
279
  if query_params.empty?
254
280
  url
255
281
  else
256
- # First divide our query params into ones where the param value is and isn't a hash. The params where the value is a hash
257
- # are, for example, tags we need to handle differently for inclusion in the query string. An example query_params is:
282
+ # First divide our query params into ones where the param value is a simple value (e.g. a string), an array or a hash.
283
+ # The params where the value is a hash are, for example, tags we need to handle differently for inclusion in the query
284
+ # string. We also need to handle array params differently in the query string since the values should appear as separate entries
285
+ # in the query string with the same key (this corresponds to using collectionFormat=multi in Swagger)
286
+ #
287
+ # An example query_params is:
258
288
  #
259
289
  # {
260
290
  # "stuff" => "things",
291
+ # "anArrayType" => ["hello", "world"]
261
292
  # "definedTags" => { "tag1" => ["val1", "val2", "val3"], "tag2" => ["val1"] },
262
293
  # "definedTagsExists" => { "tag3" => true, "tag4" => true }
263
294
  # }
264
295
  #
265
- # So our non_hash_params will be: { "stuff" => "things" }
296
+ # So our simple_params will be: { "stuff" => "things" }
297
+ # And our array_params will be: { "anArrayType" => ["hello", "world"]}
266
298
  # And our hash_params will be: { "definedTags" => { "tag1" => ["val1", "val2", "val3"], "tag2" => ["val1"] }, "definedTagsExists" => { "tag3" => true, "tag4" => true } }
267
- non_hash_params = query_params.select { |k,v| !v.is_a?(Hash) }.to_h
299
+ simple_params = query_params.select { |k,v| !v.is_a?(Hash) && !v.is_a?(Array) }.to_h
300
+ array_params = query_params.select { |k,v| v.is_a?(Array) }.to_h
268
301
  hash_params = query_params.select { |k,v| v.is_a?(Hash) }.to_h
269
302
 
270
303
  # Simple params just go key to value
271
304
  base_query_string = ''
272
- base_query_string << non_hash_params.map{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') unless non_hash_params.empty?
305
+ base_query_string << simple_params.map{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') unless simple_params.empty?
306
+
307
+ # Using the previous comment:
308
+ # k = "anArrayType", v = ["hello", "world"]
309
+ #
310
+ # And we want query string params like #{k}=#{v[0]}&#{k}=#{v[1]}&#{k}=#{v[2]}...
311
+ # So the same key is repeated, but each value is a different value from the array
312
+ array_params.each do |k,v|
313
+ v.each do |query_string_val|
314
+ base_query_string << '&' unless base_query_string.empty?
315
+ base_query_string << "#{k}=#{CGI.escape(query_string_val)}"
316
+ end
317
+ end
273
318
 
274
319
  # Using the previous comment:
275
320
  # k = "definedTags", v = { "tag1" => [...] }
@@ -1,7 +1,10 @@
1
1
  # Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2
2
 
3
3
  module OCI
4
- module Audit
4
+ # The Auth module contains classes to handle different authentication
5
+ # methods, for example using instance principals instead of an API key,
6
+ # against OCI services
7
+ module Auth
5
8
  end
6
9
  end
7
10
 
@@ -13,4 +16,4 @@ require 'oci/auth/url_based_certificate_retriever'
13
16
 
14
17
  require 'oci/auth/signers/security_token_signer'
15
18
  require 'oci/auth/signers/x509_federation_client_based_security_token_signer'
16
- require 'oci/auth/signers/instance_principals_security_token_signer'
19
+ require 'oci/auth/signers/instance_principals_security_token_signer'
@@ -22,7 +22,7 @@ module OCI
22
22
  # it will vend the last requested token if it is not expired).
23
23
  class FederationClient
24
24
  # A supplier which vends a private and public key for signing token requests to Auth Service.
25
- # The public key will be sent as part of the token request and the private key should be used to
25
+ # The public key will be sent as part of the token request and the private key should be used to
26
26
  # sign all requests made with the token vended by this client
27
27
  # @return [OCI::Auth::SessionKeySupplier] A supplier which vends a private and public key for signing token requests to Auth Service
28
28
  attr_reader :session_key_supplier
@@ -122,4 +122,4 @@ module OCI
122
122
  end
123
123
  end
124
124
  end
125
- end
125
+ end
@@ -11,10 +11,10 @@ module OCI
11
11
  api_key = "#{tenancy_id}/fed-x509/#{fingerprint}"
12
12
  private_key = private_key_pem
13
13
 
14
- generic_headers = [:"date", :"(request-target)"]
14
+ generic_headers = %i[date (request-target)]
15
15
  super(api_key, private_key, headers_to_sign_in_all_requests: generic_headers)
16
16
  end
17
17
  end
18
18
  end
19
19
  end
20
- end
20
+ end
@@ -18,8 +18,8 @@ module OCI
18
18
 
19
19
  def token_valid?
20
20
  expiration_epoch_seconds = @jwt[0]['exp']
21
- return expiration_epoch_seconds > Time.now.to_i
21
+ expiration_epoch_seconds > Time.now.to_i
22
22
  end
23
23
  end
24
24
  end
25
- end
25
+ end
@@ -1,13 +1,12 @@
1
1
  # Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2
2
 
3
3
  require 'openssl'
4
- require 'thread'
5
4
 
6
5
  module OCI
7
6
  module Auth
8
7
  # A supplier which can vend a public and private key to be used for signing requests
9
8
  class SessionKeySupplier
10
- PUBLIC_EXPONENT = 65537 # Ruby docs suggest 3, 17 or 65537
9
+ PUBLIC_EXPONENT = 65_537 # Ruby docs suggest 3, 17 or 65537
11
10
  def initialize(key_size: 2048)
12
11
  @key_size = key_size
13
12
  @refresh_lock = Mutex.new
@@ -22,7 +21,7 @@ module OCI
22
21
  private_key = @private_key
23
22
  @refresh_lock.unlock
24
23
 
25
- {'private_key': private_key, 'public_key': private_key.public_key}
24
+ { 'private_key': private_key, 'public_key': private_key.public_key }
26
25
  end
27
26
 
28
27
  # Generates a new public and private key
@@ -34,4 +33,4 @@ module OCI
34
33
  end
35
34
  end
36
35
  end
37
- end
36
+ end
@@ -21,7 +21,7 @@ module OCI
21
21
  # the token:
22
22
  #
23
23
  # * Using the metadata endpoint for the instance (http://169.254.169.254/opc/v1) we can discover the region the instance is in, its leaf certificate and any intermediate certificates (for requesting the token) and the tenancy (as) that is in the leaf certificate.
24
- # * The signer leverages {OCI::Auth::FederationClient} so it can refresh the security token and also get the private key needed to sign requests (via the client's session_key_supplier)
24
+ # * The signer leverages {OCI::Auth::FederationClient} so it can refresh the security token and also get the private key needed to sign requests (via the client's session_key_supplier)
25
25
  class InstancePrincipalsSecurityTokenSigner < OCI::Auth::Signers::X509FederationClientBasedSecurityTokenSigner
26
26
  # The region the instance is in, as returned from the metadata endpoint for the instance (http://169.254.169.254/opc/v1/instance/region)
27
27
  # @return [String] The region for the instance
@@ -41,25 +41,38 @@ module OCI
41
41
  # @param [String] signing_strategy Whether this signer is used for Object Storage requests or not. Acceptable values are {OCI::BaseSigner::STANDARD} and {OCI::BaseSigner::OBJECT_STORAGE}. If not provided, defaults to {OCI::BaseSigner::STANDARD}
42
42
  # @param [Array<String>] headers_to_sign_in_all_requests An array of headers which will be signed in each request. If not provided, defaults to {OCI::BaseSigner::GENERIC_HEADERS}
43
43
  # @param [Array<String>] body_headers_to_sign An array of headers which should be signed on requests with bodies. If not provided, defaults to {OCI::BaseSigner::BODY_HEADERS}
44
- def initialize(federation_endpoint: nil, federation_client_cert_bundle: nil, signing_strategy: OCI::BaseSigner::STANDARD, headers_to_sign_in_all_requests: OCI::BaseSigner::GENERIC_HEADERS, body_headers_to_sign: OCI::BaseSigner::BODY_HEADERS)
45
- @leaf_certificate_retriever = OCI::Auth::UrlBasedCertificateRetriever.new(LEAF_CERTIFICATE_URL, private_key_url: LEAF_CERTIFICATE_PRIVATE_KEY_URL)
46
- @intermediate_certificate_retriever = OCI::Auth::UrlBasedCertificateRetriever.new(INTERMEDIATE_CERTIFICATE_URL)
44
+ def initialize(
45
+ federation_endpoint: nil,
46
+ federation_client_cert_bundle: nil,
47
+ signing_strategy: OCI::BaseSigner::STANDARD,
48
+ headers_to_sign_in_all_requests: OCI::BaseSigner::GENERIC_HEADERS,
49
+ body_headers_to_sign: OCI::BaseSigner::BODY_HEADERS
50
+ )
51
+
52
+ @leaf_certificate_retriever = OCI::Auth::UrlBasedCertificateRetriever.new(
53
+ LEAF_CERTIFICATE_URL, private_key_url: LEAF_CERTIFICATE_PRIVATE_KEY_URL
54
+ )
55
+ @intermediate_certificate_retriever = OCI::Auth::UrlBasedCertificateRetriever.new(
56
+ INTERMEDIATE_CERTIFICATE_URL
57
+ )
47
58
  @session_key_supplier = OCI::Auth::SessionKeySupplier.new
48
- @tenancy_id = OCI::Auth::Util.get_tenancy_id_from_certificate(@leaf_certificate_retriever.certificate)
59
+ @tenancy_id = OCI::Auth::Util.get_tenancy_id_from_certificate(
60
+ @leaf_certificate_retriever.certificate
61
+ )
49
62
 
50
63
  raw_region = Net::HTTP.get(URI(GET_REGION_URL)).strip
51
64
  symbolised_raw_region = raw_region.to_sym
52
- if OCI::Regions::REGION_SHORT_NAMES_TO_LONG_NAMES.has_key?(symbolised_raw_region)
53
- @region = OCI::Regions::REGION_SHORT_NAMES_TO_LONG_NAMES[symbolised_raw_region]
54
- else
55
- @region = raw_region
56
- end
65
+ @region = if OCI::Regions::REGION_SHORT_NAMES_TO_LONG_NAMES.key?(symbolised_raw_region)
66
+ OCI::Regions::REGION_SHORT_NAMES_TO_LONG_NAMES[symbolised_raw_region]
67
+ else
68
+ raw_region
69
+ end
57
70
 
58
- if federation_endpoint
59
- @federation_endpoint = federation_endpoint
60
- else
61
- @federation_endpoint = "#{OCI::Regions.get_service_endpoint(@region, :Auth)}/v1/x509"
62
- end
71
+ @federation_endpoint = if federation_endpoint
72
+ federation_endpoint
73
+ else
74
+ "#{OCI::Regions.get_service_endpoint(@region, :Auth)}/v1/x509"
75
+ end
63
76
 
64
77
  @federation_client = OCI::Auth::FederationClient.new(
65
78
  @federation_endpoint,
@@ -71,7 +84,7 @@ module OCI
71
84
  )
72
85
 
73
86
  super(
74
- @federation_client,
87
+ @federation_client,
75
88
  signing_strategy: signing_strategy,
76
89
  headers_to_sign_in_all_requests: headers_to_sign_in_all_requests,
77
90
  body_headers_to_sign: body_headers_to_sign
@@ -80,4 +93,4 @@ module OCI
80
93
  end
81
94
  end
82
95
  end
83
- end
96
+ end
@@ -16,12 +16,19 @@ module OCI
16
16
  # @param [String] signing_strategy Whether this signer is used for Object Storage requests or not. Acceptable values are {OCI::BaseSigner::STANDARD} and {OCI::BaseSigner::OBJECT_STORAGE}. If not provided, defaults to {OCI::BaseSigner::STANDARD}
17
17
  # @param [Array<String>] headers_to_sign_in_all_requests An array of headers which will be signed in each request. If not provided, defaults to {OCI::BaseSigner::GENERIC_HEADERS}
18
18
  # @param [Array<String>] body_headers_to_sign An array of headers which should be signed on requests with bodies. If not provided, defaults to {OCI::BaseSigner::BODY_HEADERS}
19
- def initialize(security_token, private_key, pass_phrase: nil, signing_strategy: OCI::BaseSigner::STANDARD, headers_to_sign_in_all_requests: OCI::BaseSigner::GENERIC_HEADERS, body_headers_to_sign: OCI::BaseSigner::BODY_HEADERS)
19
+ def initialize(
20
+ security_token,
21
+ private_key,
22
+ pass_phrase: nil,
23
+ signing_strategy: OCI::BaseSigner::STANDARD,
24
+ headers_to_sign_in_all_requests: OCI::BaseSigner::GENERIC_HEADERS,
25
+ body_headers_to_sign: OCI::BaseSigner::BODY_HEADERS
26
+ )
20
27
  super(
21
- "ST$#{security_token}",
22
- private_key,
23
- pass_phrase: pass_phrase,
24
- signing_strategy: signing_strategy,
28
+ "ST$#{security_token}",
29
+ private_key,
30
+ pass_phrase: pass_phrase,
31
+ signing_strategy: signing_strategy,
25
32
  headers_to_sign_in_all_requests: headers_to_sign_in_all_requests,
26
33
  body_headers_to_sign: body_headers_to_sign
27
34
  )
@@ -29,4 +36,4 @@ module OCI
29
36
  end
30
37
  end
31
38
  end
32
- end
39
+ end
@@ -3,14 +3,13 @@
3
3
  require 'oci/base_signer'
4
4
  require 'openssl'
5
5
  require 'securerandom'
6
- require 'thread'
7
6
 
8
7
  require_relative 'security_token_signer'
9
8
 
10
9
  module OCI
11
10
  module Auth
12
11
  module Signers
13
- # A SecurityTokenSigner where the token and private key are sourced from a provided federation_client. The token is retrieved via
12
+ # A SecurityTokenSigner where the token and private key are sourced from a provided federation_client. The token is retrieved via
14
13
  # the client's security_token method, and the private key is retrieved by reading it from the session_key_supplier in the client.
15
14
  class X509FederationClientBasedSecurityTokenSigner < OCI::Auth::Signers::SecurityTokenSigner
16
15
  # Creates a new X509FederationClientBasedSecurityTokenSigner
@@ -19,7 +18,12 @@ module OCI
19
18
  # @param [String] signing_strategy Whether this signer is used for Object Storage requests or not. Acceptable values are {OCI::BaseSigner::STANDARD} and {OCI::BaseSigner::OBJECT_STORAGE}. If not provided, defaults to {OCI::BaseSigner::STANDARD}
20
19
  # @param [Array<String>] headers_to_sign_in_all_requests An array of headers which will be signed in each request. If not provided, defaults to {OCI::BaseSigner::GENERIC_HEADERS}
21
20
  # @param [Array<String>] body_headers_to_sign An array of headers which should be signed on requests with bodies. If not provided, defaults to {OCI::BaseSigner::BODY_HEADERS}
22
- def initialize(federation_client, signing_strategy: OCI::BaseSigner::STANDARD, headers_to_sign_in_all_requests: OCI::BaseSigner::GENERIC_HEADERS, body_headers_to_sign: OCI::BaseSigner::BODY_HEADERS)
21
+ def initialize(
22
+ federation_client,
23
+ signing_strategy: OCI::BaseSigner::STANDARD,
24
+ headers_to_sign_in_all_requests: OCI::BaseSigner::GENERIC_HEADERS,
25
+ body_headers_to_sign: OCI::BaseSigner::BODY_HEADERS
26
+ )
23
27
  @federation_client = federation_client
24
28
  @refresh_lock = Mutex.new
25
29
 
@@ -67,4 +71,4 @@ module OCI
67
71
  end
68
72
  end
69
73
  end
70
- end
74
+ end
@@ -3,7 +3,6 @@
3
3
  require 'net/http'
4
4
  require 'openssl'
5
5
  require 'securerandom'
6
- require 'thread'
7
6
  require 'uri'
8
7
 
9
8
  module OCI
@@ -50,11 +49,11 @@ module OCI
50
49
  pem
51
50
  end
52
51
 
53
- # @return [OpenSSL::X509::Certificate] The certificate as an {OpenSSL::X509::Certificate}. This converts the
52
+ # @return [OpenSSL::X509::Certificate] The certificate as an {OpenSSL::X509::Certificate}. This converts the
54
53
  # PEM-formatted string into a {OpenSSL::X509::Certificate}
55
54
  def certificate
56
55
  cert_pem = certificate_pem
57
- OpenSSL::X509::Certificate.new(cert_pem)
56
+ OpenSSL::X509::Certificate.new(cert_pem)
58
57
  end
59
58
 
60
59
  # @return [String] The private key as a PEM-formatted string
@@ -101,4 +100,4 @@ module OCI
101
100
  end
102
101
  end
103
102
  end
104
- end
103
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module OCI
4
4
  module Auth
5
+ # Contains utility methods to support functionality in the {OCI::Auth} module, for example being able
6
+ # to extract information from certificates and scrubbing certificate information for calls to Auth Service
5
7
  module Util
6
8
  def self.get_tenancy_id_from_certificate(x509_certificate)
7
9
  subject_array = x509_certificate.subject.to_a
@@ -23,10 +25,10 @@ module OCI
23
25
 
24
26
  def self.sanitize_certificate_string(cert_string)
25
27
  cert_string.gsub('-----BEGIN CERTIFICATE-----', '')
26
- .gsub('-----END CERTIFICATE-----', '')
27
- .gsub('-----BEGIN PUBLIC KEY-----', '')
28
- .gsub('-----END PUBLIC KEY-----', '')
29
- .gsub("\n", '')
28
+ .gsub('-----END CERTIFICATE-----', '')
29
+ .gsub('-----BEGIN PUBLIC KEY-----', '')
30
+ .gsub('-----END PUBLIC KEY-----', '')
31
+ .delete("\n")
30
32
  end
31
33
  end
32
34
  end