aserto 0.30.1 → 0.30.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ddb26b2da994a8a4f72162f227590060a990a31d16639994b5cd2e4bd9ce538f
4
- data.tar.gz: e6969585d13f94a6e410d8763647cbc3dca69402969a194db2674239514adeeb
3
+ metadata.gz: f6f6d7ede8c8254ea3a7660948f01f70ec2d59d1328676c6e479bfe4e79a2305
4
+ data.tar.gz: b2314cab25c484a0c7b48254869210f11c386084bdeb2cb0a37b2024dee8716f
5
5
  SHA512:
6
- metadata.gz: c0202011d8ce67f9fc48e361fdbd00b9239e291aa7bc60e5773eed58252dec41fdbac16e28ea25f0ff54d4652a0eee247ec048f59e6df5b1ae1bc5d254638244
7
- data.tar.gz: a2c5e23bcb6e18ee1babb1c13d0e39912c32aa70595c5ce8dae69e24e0f10c6c37e7251f6dad0d5059fbe801dc8bf3d5ddde3ba806c071ae96b52afd1ba84f49
6
+ metadata.gz: 65c36aee8d336be3016bf70ee95bd44d8ddc74d06fc1a7c0f9cc51ddff8f5a65b8282cc1160e2a6d0389be5eafaa7c2ce51fb61ce84bb9d0297cfdb6865bde2c
7
+ data.tar.gz: c27fba66e09a55b63060f93596080f89eb3cdb5ee38eed73ca101ae491528abc7688a2e82879c58d187729d6ee9c3c4108b1e09c35aa7450096e8ed8d5ac7a08
data/README.md CHANGED
@@ -50,7 +50,7 @@ See [Aserto::Directory::V3::Client](https://rubydoc.info/gems/aserto/Aserto/Dire
50
50
  `Aserto::Authorization` is a middleware that allows Ruby applications to use Aserto as the Authorization provider.
51
51
 
52
52
  ### Prerequisites
53
- * [Ruby](https://www.ruby-lang.org/en/downloads/) 2.7 or newer.
53
+ * [Ruby](https://www.ruby-lang.org/en/downloads/) 3.0 or newer.
54
54
  * An [Aserto](https://console.aserto.com) account.
55
55
 
56
56
  ### Configuration
@@ -244,7 +244,7 @@ end
244
244
  Prerequisites:
245
245
 
246
246
  - go >= 1.17 to run mage
247
- - Ruby >= 2.7.0 to run the code
247
+ - Ruby >= 3.0 to run the code
248
248
 
249
249
 
250
250
  Run `bundle install` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.30.1
1
+ 0.30.4
@@ -33,7 +33,7 @@ module Aserto
33
33
  exec_is(request_is(config.decision))
34
34
  end
35
35
 
36
- def check(object_id:, object_type:, relation:)
36
+ def check(object_id: "", object_type: "", relation: "")
37
37
  resource_context_fields = {
38
38
  object_id: object_id,
39
39
  object_type: object_type,
data/lib/aserto/config.rb CHANGED
@@ -40,7 +40,7 @@ module Aserto
40
40
  policy_root: "",
41
41
  cert_path: "",
42
42
  on_unauthorized: lambda do |_env|
43
- return [403, {}, ["Forbidden"]]
43
+ [403, {}, ["Forbidden"]]
44
44
  end
45
45
  }.freeze
46
46
 
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ConfigError < StandardError
4
+ end
@@ -8,6 +8,7 @@ require_relative "writer"
8
8
  require_relative "model"
9
9
  require_relative "importer"
10
10
  require_relative "exporter"
11
+ require_relative "../errors"
11
12
 
12
13
  module Aserto
13
14
  module Directory
@@ -77,7 +78,7 @@ module Aserto
77
78
  end
78
79
 
79
80
  def method_missing(method, *_args)
80
- puts "Cannot call '#{method}': '#{@name.to_s.capitalize}' client is not initialized."
81
+ raise ConfigError, "Cannot call '#{method}': '#{@name.to_s.capitalize}' client is not initialized."
81
82
  end
82
83
 
83
84
  def respond_to_missing?(_name, _include_private)
@@ -10,7 +10,7 @@ module Aserto
10
10
 
11
11
  def initialize(config)
12
12
  @base = {
13
- url: config[:url] || "directory.prod.aserto.com:8443",
13
+ url: config[:url],
14
14
  api_key: config[:api_key],
15
15
  tenant_id: config[:tenant_id],
16
16
  cert_path: config[:cert_path]
@@ -28,6 +28,8 @@ module Aserto
28
28
  class BaseConfig
29
29
  attr_reader :url, :credentials, :interceptors
30
30
 
31
+ DEFAULT_DIRECTORY_URL = "directory.prod.aserto.com:8443"
32
+
31
33
  def initialize(url, credentials, interceptors)
32
34
  @url = url
33
35
  @credentials = credentials
@@ -35,16 +37,21 @@ module Aserto
35
37
  end
36
38
  end
37
39
 
38
- def build(
39
- url: @base[:url],
40
- api_key: @base[:api_key],
41
- tenant_id: @base[:tenant_id],
42
- cert_path: @base[:cert_path]
43
- )
40
+ def build(url: nil, api_key: @base[:api_key], tenant_id: @base[:tenant_id], cert_path: @base[:cert_path])
41
+ return unless valid_config?(@base, { url: url, api_key: api_key, tenant_id: tenant_id })
44
42
 
45
- interceptors = []
46
43
  interceptors = [Interceptors::Headers.new(api_key, tenant_id)] if !api_key.nil? && !tenant_id.nil?
47
- BaseConfig.new(url, load_creds(cert_path), interceptors)
44
+ BaseConfig.new(
45
+ url || @base[:url] || BaseConfig::DEFAULT_DIRECTORY_URL,
46
+ load_creds(cert_path),
47
+ interceptors || []
48
+ )
49
+ end
50
+
51
+ def valid_config?(config, fallback)
52
+ !(config[:url].nil? && fallback[:url].nil?) ||
53
+ ((!config[:api_key].nil? || !fallback[:api_key].nil?) &&
54
+ (!config[:tenant_id].nil? || !fallback[:tenant_id].nil?))
48
55
  end
49
56
 
50
57
  def load_creds(cert_path)
@@ -9,15 +9,21 @@ module Aserto
9
9
  #
10
10
  # @param Array[Hash] data to be imported
11
11
  #
12
+ # op_code = {
13
+ # OPCODE_UNKNOWN = ;
14
+ # OPCODE_SET = 1;
15
+ # OPCODE_DELETE = 2;
16
+ # }
12
17
  # @example
13
18
  # directory.import(
14
19
  # [
15
- # { object: { id: "import-user", type: "user" } },
16
- # { object: { id: "import-group", type: "group" } },
20
+ # { op_code: 1, object: { type: "user", id: "import-user" } },
21
+ # { op_code: 1, object: { type: "group", id: "import-group" } },
17
22
  # {
23
+ # op_code: 1,
18
24
  # relation: {
19
- # object_id: "import-user",
20
25
  # object_type: "user",
26
+ # object_id: "import-user",
21
27
  # relation: "member",
22
28
  # subject_id: "import-group",
23
29
  # subject_type: "group"
@@ -7,8 +7,8 @@ module Aserto
7
7
  #
8
8
  # find an object by id and type
9
9
  #
10
- # @param object_id [String]
11
10
  # @param object_type [String]
11
+ # @param object_id [String]
12
12
  #
13
13
  # @return [Aserto::Directory::Reader::V3::GetObjectResponse]
14
14
  #
@@ -17,11 +17,11 @@ module Aserto
17
17
  # object_type: "user",
18
18
  # object_id: "rick@the-citadel.com"
19
19
  # )
20
- def get_object(object_id:, object_type:)
20
+ def get_object(object_type:, object_id:)
21
21
  reader.get_object(
22
22
  Aserto::Directory::Reader::V3::GetObjectRequest.new(
23
- object_id: object_id,
24
- object_type: object_type
23
+ object_type: object_type,
24
+ object_id: object_id
25
25
  )
26
26
  )
27
27
  end
@@ -227,13 +227,13 @@ module Aserto
227
227
  #
228
228
  # Returns object graph from anchor to subject or object.
229
229
  #
230
- # @param [String] anchor_type <description>
231
- # @param [String] anchor_id <description>
232
- # @param [String] object_type <description>
233
- # @param [String] object_id <description>
234
- # @param [String] relation <description>
235
- # @param [String] subject_type <description>
236
- # @param [String] <description>
230
+ # @param [String] anchor_type
231
+ # @param [String] anchor_id
232
+ # @param [String] object_type
233
+ # @param [String] object_id
234
+ # @param [String] relation
235
+ # @param [String] subject_type
236
+ # @param [String]
237
237
  #
238
238
  # @return [Aserto::Directory::Reader::V3::GetGraphResponse]
239
239
  #
@@ -9,8 +9,8 @@ module Aserto
9
9
  #
10
10
  # Create a new object
11
11
  #
12
- # @param [String] object_id
13
12
  # @param [String] object_type
13
+ # @param [String] object_id
14
14
  # @param [String] display_name
15
15
  # @param [Hash] properties
16
16
  # @param [String] etag
@@ -18,13 +18,13 @@ module Aserto
18
18
  # @return [Aserto::Directory::Writer::V3::SetObjectResponse]
19
19
  #
20
20
  # @example
21
- # client.set_object(object_id: "1234", object_type: "user", properties: { email: "test" })
22
- def set_object(object_id:, object_type:, display_name: "", properties: {}, etag: nil)
21
+ # client.set_object(object_type: "user", object_id: "1234", properties: { email: "test" })
22
+ def set_object(object_type:, object_id:, display_name: "", properties: {}, etag: nil)
23
23
  writer.set_object(
24
24
  Aserto::Directory::Writer::V3::SetObjectRequest.new(
25
25
  object: {
26
- id: object_id,
27
26
  type: object_type,
27
+ id: object_id,
28
28
  display_name: display_name,
29
29
  properties: Google::Protobuf::Struct.from_hash(properties.transform_keys!(&:to_s)),
30
30
  etag: etag
@@ -36,19 +36,19 @@ module Aserto
36
36
  #
37
37
  # Delete an object
38
38
  #
39
- # @param [String] object_id
40
39
  # @param [String] object_type
40
+ # @param [String] object_id
41
41
  # @param [Boolean] with_relations
42
42
  #
43
43
  # @return [ Aserto::Directory::Writer::V3::DeleteObjectResponse]
44
44
  #
45
45
  # @example
46
- # client.delete_object(object_id: "1234", object_type: "user")
47
- def delete_object(object_id:, object_type:, with_relations: false)
46
+ # client.delete_object(object_type: "user", object_id: "1234")
47
+ def delete_object(object_type:, object_id:, with_relations: false)
48
48
  writer.delete_object(
49
49
  Aserto::Directory::Writer::V3::DeleteObjectRequest.new(
50
- object_id: object_id,
51
50
  object_type: object_type,
51
+ object_id: object_id,
52
52
  with_relations: with_relations
53
53
  )
54
54
  )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aserto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.1
4
+ version: 0.30.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aserto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-27 00:00:00.000000000 Z
11
+ date: 2023-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aserto-authorizer
@@ -81,6 +81,7 @@ files:
81
81
  - lib/aserto/authorization.rb
82
82
  - lib/aserto/config.rb
83
83
  - lib/aserto/directory/client.rb
84
+ - lib/aserto/directory/errors.rb
84
85
  - lib/aserto/directory/interceptors/headers.rb
85
86
  - lib/aserto/directory/v2/client.rb
86
87
  - lib/aserto/directory/v2/requests.rb