strongdm 1.0.1 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -7
  3. data/doc/LICENSE.html +1 -11
  4. data/doc/Object.html +1 -356
  5. data/doc/README_md.html +31 -20
  6. data/doc/SDM.html +1 -1
  7. data/doc/SDM/AKS.html +40 -4
  8. data/doc/SDM/AKSBasicAuth.html +40 -4
  9. data/doc/SDM/AKSServiceAccount.html +40 -4
  10. data/doc/SDM/AccountAttachment.html +3 -3
  11. data/doc/SDM/AccountAttachmentCreateResponse.html +3 -3
  12. data/doc/SDM/AccountAttachmentDeleteResponse.html +3 -3
  13. data/doc/SDM/AccountAttachmentGetResponse.html +3 -3
  14. data/doc/SDM/AccountAttachments.html +22 -24
  15. data/doc/SDM/AccountCreateResponse.html +3 -3
  16. data/doc/SDM/AccountDeleteResponse.html +3 -3
  17. data/doc/SDM/AccountGetResponse.html +3 -3
  18. data/doc/SDM/AccountGrant.html +3 -3
  19. data/doc/SDM/AccountGrantCreateResponse.html +3 -3
  20. data/doc/SDM/AccountGrantDeleteResponse.html +3 -3
  21. data/doc/SDM/AccountGrantGetResponse.html +3 -3
  22. data/doc/SDM/AccountGrants.html +24 -24
  23. data/doc/SDM/AccountUpdateResponse.html +3 -3
  24. data/doc/SDM/Accounts.html +30 -30
  25. data/doc/SDM/AlreadyExistsError.html +1 -1
  26. data/doc/SDM/AmazonEKS.html +58 -4
  27. data/doc/SDM/AmazonES.html +22 -4
  28. data/doc/SDM/Athena.html +22 -4
  29. data/doc/SDM/AuroraMysql.html +22 -4
  30. data/doc/SDM/AuroraPostgres.html +22 -4
  31. data/doc/SDM/AuthenticationError.html +1 -1
  32. data/doc/SDM/BadRequestError.html +1 -1
  33. data/doc/SDM/BigQuery.html +22 -4
  34. data/doc/SDM/Cassandra.html +22 -4
  35. data/doc/SDM/Citus.html +409 -0
  36. data/doc/SDM/Client.html +2 -2
  37. data/doc/SDM/Clustrix.html +22 -4
  38. data/doc/SDM/Cockroach.html +22 -4
  39. data/doc/SDM/CreateResponseMetadata.html +1 -1
  40. data/doc/SDM/DB2.html +391 -0
  41. data/doc/SDM/DB2LUW.html +391 -0
  42. data/doc/SDM/DB2i.html +391 -0
  43. data/doc/SDM/DeadlineExceededError.html +1 -1
  44. data/doc/SDM/DeleteResponseMetadata.html +1 -1
  45. data/doc/SDM/Druid.html +22 -4
  46. data/doc/SDM/DynamoDB.html +22 -4
  47. data/doc/SDM/Elastic.html +22 -4
  48. data/doc/SDM/ElasticacheRedis.html +22 -4
  49. data/doc/SDM/Gateway.html +22 -4
  50. data/doc/SDM/GetResponseMetadata.html +1 -1
  51. data/doc/SDM/GoogleGKE.html +40 -4
  52. data/doc/SDM/Greenplum.html +22 -4
  53. data/doc/SDM/HTTPAuth.html +22 -4
  54. data/doc/SDM/HTTPBasicAuth.html +22 -4
  55. data/doc/SDM/HTTPNoAuth.html +22 -4
  56. data/doc/SDM/InternalError.html +1 -1
  57. data/doc/SDM/Kubernetes.html +40 -4
  58. data/doc/SDM/KubernetesBasicAuth.html +40 -4
  59. data/doc/SDM/KubernetesServiceAccount.html +40 -4
  60. data/doc/SDM/Maria.html +22 -4
  61. data/doc/SDM/Memcached.html +22 -4
  62. data/doc/SDM/Memsql.html +22 -4
  63. data/doc/SDM/MongoHost.html +22 -4
  64. data/doc/SDM/MongoLegacyHost.html +22 -4
  65. data/doc/SDM/MongoLegacyReplicaset.html +22 -4
  66. data/doc/SDM/MongoReplicaSet.html +22 -4
  67. data/doc/SDM/Mysql.html +22 -4
  68. data/doc/SDM/NodeCreateResponse.html +3 -3
  69. data/doc/SDM/NodeDeleteResponse.html +3 -3
  70. data/doc/SDM/NodeGetResponse.html +3 -3
  71. data/doc/SDM/NodeUpdateResponse.html +3 -3
  72. data/doc/SDM/Nodes.html +30 -30
  73. data/doc/SDM/NotFoundError.html +1 -1
  74. data/doc/SDM/Oracle.html +22 -4
  75. data/doc/SDM/PermissionError.html +1 -1
  76. data/doc/SDM/Plumbing.html +4355 -3574
  77. data/doc/SDM/Postgres.html +22 -4
  78. data/doc/SDM/Presto.html +22 -4
  79. data/doc/SDM/RDP.html +22 -4
  80. data/doc/SDM/RPCError.html +1 -1
  81. data/doc/SDM/RateLimitError.html +1 -1
  82. data/doc/SDM/RateLimitMetadata.html +1 -1
  83. data/doc/SDM/Redis.html +22 -4
  84. data/doc/SDM/Redshift.html +22 -4
  85. data/doc/SDM/Relay.html +23 -5
  86. data/doc/SDM/ResourceCreateResponse.html +3 -3
  87. data/doc/SDM/ResourceDeleteResponse.html +3 -3
  88. data/doc/SDM/ResourceGetResponse.html +3 -3
  89. data/doc/SDM/ResourceUpdateResponse.html +3 -3
  90. data/doc/SDM/Resources.html +29 -29
  91. data/doc/SDM/Role.html +22 -4
  92. data/doc/SDM/RoleAttachment.html +3 -3
  93. data/doc/SDM/RoleAttachmentCreateResponse.html +3 -3
  94. data/doc/SDM/RoleAttachmentDeleteResponse.html +3 -3
  95. data/doc/SDM/RoleAttachmentGetResponse.html +3 -3
  96. data/doc/SDM/RoleAttachments.html +23 -23
  97. data/doc/SDM/RoleCreateResponse.html +3 -3
  98. data/doc/SDM/RoleDeleteResponse.html +3 -3
  99. data/doc/SDM/RoleGetResponse.html +3 -3
  100. data/doc/SDM/RoleGrant.html +3 -3
  101. data/doc/SDM/RoleGrantCreateResponse.html +3 -3
  102. data/doc/SDM/RoleGrantDeleteResponse.html +3 -3
  103. data/doc/SDM/RoleGrantGetResponse.html +3 -3
  104. data/doc/SDM/RoleGrants.html +23 -23
  105. data/doc/SDM/RoleUpdateResponse.html +3 -3
  106. data/doc/SDM/Roles.html +29 -29
  107. data/doc/SDM/SQLServer.html +22 -4
  108. data/doc/SDM/SSH.html +40 -4
  109. data/doc/SDM/SSHCert.html +373 -0
  110. data/doc/SDM/Service.html +22 -4
  111. data/doc/SDM/Snowflake.html +22 -4
  112. data/doc/SDM/Sybase.html +22 -4
  113. data/doc/SDM/SybaseIQ.html +22 -4
  114. data/doc/SDM/Teradata.html +22 -4
  115. data/doc/SDM/UpdateResponseMetadata.html +1 -1
  116. data/doc/SDM/User.html +22 -4
  117. data/doc/V1.html +31 -6
  118. data/doc/V1/AccountAttachments.html +1 -1
  119. data/doc/V1/AccountAttachments/Service.html +1 -1
  120. data/doc/V1/AccountGrants.html +1 -1
  121. data/doc/V1/AccountGrants/Service.html +2 -2
  122. data/doc/V1/Accounts.html +1 -1
  123. data/doc/V1/Accounts/Service.html +1 -1
  124. data/doc/V1/Nodes.html +1 -1
  125. data/doc/V1/Nodes/Service.html +1 -1
  126. data/doc/V1/Resources.html +1 -1
  127. data/doc/V1/Resources/Service.html +1 -1
  128. data/doc/V1/RoleAttachments.html +1 -1
  129. data/doc/V1/RoleAttachments/Service.html +1 -1
  130. data/doc/V1/RoleGrants.html +1 -1
  131. data/doc/V1/RoleGrants/Service.html +1 -1
  132. data/doc/V1/Roles.html +1 -1
  133. data/doc/V1/Roles/Service.html +1 -1
  134. data/doc/V1/Tags.html +113 -0
  135. data/doc/created.rid +35 -41
  136. data/doc/css/rdoc.css +13 -5
  137. data/doc/examples/Gemfile.html +1 -11
  138. data/doc/index.html +11 -13
  139. data/doc/js/navigation.js.gz +0 -0
  140. data/doc/js/search_index.js +1 -1
  141. data/doc/js/search_index.js.gz +0 -0
  142. data/doc/js/searcher.js.gz +0 -0
  143. data/doc/lib/version.html +3 -13
  144. data/doc/table_of_contents.html +1028 -933
  145. data/lib/grpc/account_attachments_pb.rb +0 -5
  146. data/lib/grpc/account_grants_services_pb.rb +1 -1
  147. data/lib/grpc/accounts_pb.rb +3 -0
  148. data/lib/grpc/drivers_pb.rb +111 -0
  149. data/lib/grpc/nodes_pb.rb +3 -0
  150. data/lib/grpc/options_pb.rb +11 -0
  151. data/lib/grpc/plumbing.rb +2024 -1682
  152. data/lib/grpc/roles_pb.rb +2 -0
  153. data/lib/grpc/spec_pb.rb +0 -1
  154. data/lib/grpc/tags_pb.rb +36 -0
  155. data/lib/models/porcelain.rb +670 -38
  156. data/lib/strongdm.rb +1 -1
  157. data/lib/svc.rb +159 -161
  158. data/lib/version +16 -2
  159. data/lib/version.rb +1 -1
  160. metadata +23 -24
  161. data/examples/Gemfile +0 -3
  162. data/examples/Gemfile.lock +0 -14
  163. data/examples/README.md +0 -5
  164. data/examples/listUsers.rb +0 -21
  165. data/examples/okta-sync/Gemfile +0 -4
  166. data/examples/okta-sync/Gemfile.lock +0 -38
  167. data/examples/okta-sync/matchers.yml +0 -11
  168. data/examples/okta-sync/oktaSync.rb +0 -173
  169. data/examples/panicButton.rb +0 -138
@@ -1,3 +1,17 @@
1
+ # Copyright 2020 StrongDM Inc
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
1
15
  module SDM
2
- VERSION = "1.0.1"
3
- end
16
+ VERSION = "1.0.8"
17
+ end
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  module SDM
16
- VERSION = "1.0.1"
16
+ VERSION = "1.0.8"
17
17
  end
metadata CHANGED
@@ -1,73 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strongdm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - strongDM Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-23 00:00:00.000000000 Z
11
+ date: 2020-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.27.0
20
- - - "~>"
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 1.27.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: 1.27.0
30
- - - "~>"
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.27.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: grpc-tools
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: 1.27.0
40
- - - "~>"
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: 1.27.0
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ">="
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
49
  version: 1.27.0
50
- - - "~>"
50
+ - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: 1.27.0
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: openssl
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - ">="
57
+ - - "~>"
58
58
  - !ruby/object:Gem::Version
59
59
  version: 2.1.2
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: 2.1.2
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: 2.1.2
70
- - - "~>"
70
+ - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: 2.1.2
73
73
  description: strongDM Ruby Library for automating interactions with strongDM.
@@ -114,10 +114,14 @@ files:
114
114
  - doc/SDM/BadRequestError.html
115
115
  - doc/SDM/BigQuery.html
116
116
  - doc/SDM/Cassandra.html
117
+ - doc/SDM/Citus.html
117
118
  - doc/SDM/Client.html
118
119
  - doc/SDM/Clustrix.html
119
120
  - doc/SDM/Cockroach.html
120
121
  - doc/SDM/CreateResponseMetadata.html
122
+ - doc/SDM/DB2.html
123
+ - doc/SDM/DB2LUW.html
124
+ - doc/SDM/DB2i.html
121
125
  - doc/SDM/DeadlineExceededError.html
122
126
  - doc/SDM/DeleteResponseMetadata.html
123
127
  - doc/SDM/Druid.html
@@ -184,6 +188,7 @@ files:
184
188
  - doc/SDM/Roles.html
185
189
  - doc/SDM/SQLServer.html
186
190
  - doc/SDM/SSH.html
191
+ - doc/SDM/SSHCert.html
187
192
  - doc/SDM/Service.html
188
193
  - doc/SDM/Snowflake.html
189
194
  - doc/SDM/Sybase.html
@@ -208,6 +213,7 @@ files:
208
213
  - doc/V1/RoleGrants/Service.html
209
214
  - doc/V1/Roles.html
210
215
  - doc/V1/Roles/Service.html
216
+ - doc/V1/Tags.html
211
217
  - doc/created.rid
212
218
  - doc/css/fonts.css
213
219
  - doc/css/rdoc.css
@@ -260,15 +266,6 @@ files:
260
266
  - doc/lib/version.html
261
267
  - doc/strongdm_gemspec.html
262
268
  - doc/table_of_contents.html
263
- - examples/Gemfile
264
- - examples/Gemfile.lock
265
- - examples/README.md
266
- - examples/listUsers.rb
267
- - examples/okta-sync/Gemfile
268
- - examples/okta-sync/Gemfile.lock
269
- - examples/okta-sync/matchers.yml
270
- - examples/okta-sync/oktaSync.rb
271
- - examples/panicButton.rb
272
269
  - lib/errors/errors.rb
273
270
  - lib/grpc/account_attachments_pb.rb
274
271
  - lib/grpc/account_attachments_services_pb.rb
@@ -291,6 +288,7 @@ files:
291
288
  - lib/grpc/roles_pb.rb
292
289
  - lib/grpc/roles_services_pb.rb
293
290
  - lib/grpc/spec_pb.rb
291
+ - lib/grpc/tags_pb.rb
294
292
  - lib/models/porcelain.rb
295
293
  - lib/strongdm.rb
296
294
  - lib/svc.rb
@@ -316,7 +314,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
314
  - !ruby/object:Gem::Version
317
315
  version: 1.3.6
318
316
  requirements: []
319
- rubygems_version: 3.0.3
317
+ rubyforge_project:
318
+ rubygems_version: 2.7.6
320
319
  signing_key:
321
320
  specification_version: 4
322
321
  summary: strongDM SDK for the Ruby programming language.
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "strongdm"
@@ -1,14 +0,0 @@
1
- GEM
2
- specs:
3
- ipaddr (1.2.2)
4
- openssl (2.1.2)
5
- ipaddr
6
-
7
- PLATFORMS
8
- ruby
9
-
10
- DEPENDENCIES
11
- openssl
12
-
13
- BUNDLED WITH
14
- 1.17.2
@@ -1,5 +0,0 @@
1
- Prior to running examples, run:
2
-
3
- ```ShellSession
4
- $ bundler install
5
- ```
@@ -1,21 +0,0 @@
1
- # Copyright 2020 StrongDM Inc
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- require "strongdm"
16
-
17
- client = SDM::Client.new(ENV["SDM_API_ACCESS_KEY"], ENV["SDM_API_SECRET_KEY"])
18
- users = client.accounts.list("")
19
- users.each { |user|
20
- p user
21
- }
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "strongdm"
4
- gem "oktakit"
@@ -1,38 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- addressable (2.7.0)
5
- public_suffix (>= 2.0.2, < 5.0)
6
- faraday (1.0.0)
7
- multipart-post (>= 1.2, < 3)
8
- google-protobuf (3.11.4)
9
- googleapis-common-protos-types (1.0.4)
10
- google-protobuf (~> 3.0)
11
- grpc (1.27.0)
12
- google-protobuf (~> 3.11)
13
- googleapis-common-protos-types (~> 1.0)
14
- grpc-tools (1.27.0)
15
- ipaddr (1.2.2)
16
- multipart-post (2.1.1)
17
- oktakit (0.2.0)
18
- sawyer (~> 0.8.1)
19
- openssl (2.1.2)
20
- ipaddr
21
- public_suffix (4.0.3)
22
- sawyer (0.8.2)
23
- addressable (>= 2.3.5)
24
- faraday (> 0.8, < 2.0)
25
- strongdm (1.0.0)
26
- grpc (~> 1.27.0, >= 1.27.0)
27
- grpc-tools (~> 1.27.0, >= 1.27.0)
28
- openssl (~> 2.1.2, >= 2.1.2)
29
-
30
- PLATFORMS
31
- ruby
32
-
33
- DEPENDENCIES
34
- oktakit
35
- strongdm
36
-
37
- BUNDLED WITH
38
- 1.17.2
@@ -1,11 +0,0 @@
1
- ---
2
- groups:
3
- -
4
- name: db/mongo
5
- resources:
6
- - type:mongo name:don*
7
- - type:ssh name:dev*
8
- -
9
- name: app/web
10
- resources:
11
- - type:ssh name:dev-web*
@@ -1,173 +0,0 @@
1
- # Copyright 2020 StrongDM Inc
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- require "yaml"
16
- require "strongdm"
17
- require "oktakit"
18
- require "optparse"
19
-
20
- SDM_API_ACCESS_KEY = ENV.fetch("SDM_API_ACCESS_KEY", "")
21
- SDM_API_SECRET_KEY = ENV.fetch("SDM_API_SECRET_KEY", "")
22
- OKTA_CLIENT_TOKEN = ENV.fetch("OKTA_CLIENT_TOKEN", "")
23
- OKTA_CLIENT_ORGURL = ENV.fetch("OKTA_CLIENT_ORGURL", "")
24
-
25
- def okta_sync
26
- if SDM_API_ACCESS_KEY == "" || SDM_API_SECRET_KEY == "" || OKTA_CLIENT_TOKEN == "" || OKTA_CLIENT_ORGURL == ""
27
- puts "SDM_API_ACCESS_KEY, SDM_API_SECRET_KEY, OKTA_CLIENT_TOKEN, and OKTA_CLIENT_ORGURL must be set"
28
- exit
29
- end
30
-
31
- report = {
32
- :start => Time.now,
33
-
34
- :oktaUsersCount => 0,
35
- :oktaUsers => [],
36
-
37
- :sdmUsersCount => 0,
38
- :sdmUsers => [],
39
-
40
- :bothUsersCount => 0,
41
-
42
- :sdmResourcesCount => 0,
43
- :sdmResources => {},
44
-
45
- :permissionsGranted => 0,
46
- :permissionsRevoked => 0,
47
- :grants => [],
48
- :revocations => [],
49
-
50
- :matchers => {},
51
- }
52
-
53
- plan = false
54
- verbose = false
55
- OptionParser.new do |opts|
56
- opts.banner = "Usage oktaSync.rb [options]"
57
- opts.on("-p", "--plan", "calculate changes but do not apply them") do |p|
58
- plan = p
59
- end
60
- opts.on("-v", "--verbose", "print detailed report") do |v|
61
- verbose = v
62
- end
63
- end.parse!
64
-
65
- client = SDM::Client.new(SDM_API_ACCESS_KEY, SDM_API_SECRET_KEY)
66
- okta_client = Oktakit.new(token: OKTA_CLIENT_TOKEN, api_endpoint: OKTA_CLIENT_ORGURL + "/api/v1")
67
- matchers = YAML.load(File.read("matchers.yml"))
68
- report[:matchers] = matchers
69
-
70
- all_users = okta_client.list_users({
71
- 'query': {
72
- 'search': "profile.department eq \"Engineering\" and (status eq \"ACTIVE\")",
73
- },
74
- })
75
-
76
- okta_users = Array.new()
77
- all_users[0].each { |u|
78
- groups = okta_client.get_member_groups(u.id)
79
- group_names = Array.new()
80
- groups[0].each { |ug|
81
- group_names.push(ug.profile.name)
82
- }
83
- okta_users.push({ :login => u.profile.login, :first_name => u.profile.firstName, :last_name => u.profile.LastName, :groups => group_names })
84
- }
85
- report[:oktaUsers] = okta_users
86
- report[:oktaUsersCount] = okta_users.size
87
-
88
- accounts = client.accounts.list("type:user").map { |a| [a.email, a] }.to_h
89
- report[:sdmUsers] = accounts
90
- report[:sdmUsersCount] = accounts.size
91
- grants = client.account_grants.list("").map { |ag| ag }
92
-
93
- current = {}
94
- grants.each { |g|
95
- current[g.account_id] = [] if not current[g.account_id]
96
- current[g.account_id].push({ :resource_id => g.resource_id, :id => g.id })
97
- }
98
-
99
- desired = {}
100
- overlapping = 0
101
- matchers["groups"].each { |group|
102
- group["resources"].each { |resourceQuery|
103
- client.resources.list(resourceQuery).each { |res|
104
- report[:sdmResources][res.id] = res
105
- okta_users.each { |u|
106
- if u[:groups].include? group["name"]
107
- account = accounts[u[:login]]
108
- if account != nil
109
- overlapping += 1
110
- desired[account.id] = [] if not desired[account.id]
111
- desired[account.id].push(res.id)
112
- end
113
- end
114
- }
115
- }
116
- }
117
- }
118
- report[:bothUsersCount] = overlapping
119
- report[:sdmResourcesCount] = report[:sdmResources].size
120
-
121
- revocations = 0
122
- current.each { |aid, curRes|
123
- desRes = desired[aid]
124
- desRes = [] if not desired[aid]
125
- curRes.each { |r|
126
- if not(desRes.include? r[:resource_id])
127
- if plan
128
- puts "Plan: revoke %s from user %s\n" % [r[:resource_id], aid]
129
- else
130
- client.account_grants.delete(r[:id])
131
- end
132
- report[:revocations].push(r[:id])
133
- revocations += 1
134
- end
135
- }
136
- }
137
- report[:permissionsRevoked] = revocations
138
-
139
- grants = 0
140
- desired.each { |aid, desRes|
141
- curRes = current[aid]
142
- curRes = [] if not current[aid]
143
- desRes.each { |r|
144
- if not(curRes.map { |c| c[:resource_id] }.include? r)
145
- ag = SDM::AccountGrant.new()
146
- ag.account_id = aid
147
- ag.resource_id = r
148
- if plan
149
- puts "Plan: grant %s to user %s\n" % [r, aid]
150
- else
151
- client.account_grants.create(ag)
152
- end
153
- report[:grants].push(ag)
154
- grants += 1
155
- end
156
- }
157
- }
158
- report[:permissionsGranted] = grants
159
-
160
- report[:complete] = Time.now
161
-
162
- if verbose
163
- puts report.to_json
164
- else
165
- puts "%d Okta users, %d strongDM users, %d overlapping users, %d grants, %d revocations" % [okta_users.size, accounts.size, overlapping, grants, revocations]
166
- end
167
- end
168
-
169
- begin
170
- okta_sync
171
- rescue StandardError => ex
172
- puts "cannot synchronize with okta: " + ex.to_s
173
- end