strongdm 1.0.5 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -6
  3. data/doc/LICENSE.html +1 -11
  4. data/doc/Object.html +1 -356
  5. data/doc/README_md.html +32 -19
  6. data/doc/SDM.html +1 -1
  7. data/doc/SDM/AKS.html +4 -58
  8. data/doc/SDM/AKSBasicAuth.html +3 -3
  9. data/doc/SDM/AKSServiceAccount.html +3 -3
  10. data/doc/SDM/AccountAttachment.html +4 -4
  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 +6 -8
  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 +6 -6
  23. data/doc/SDM/AccountUpdateResponse.html +3 -3
  24. data/doc/SDM/Accounts.html +9 -9
  25. data/doc/SDM/AlreadyExistsError.html +1 -1
  26. data/doc/SDM/AmazonEKS.html +4 -22
  27. data/doc/SDM/AmazonES.html +3 -3
  28. data/doc/SDM/Athena.html +3 -3
  29. data/doc/SDM/AuroraMysql.html +3 -3
  30. data/doc/SDM/AuroraPostgres.html +3 -3
  31. data/doc/SDM/AuthenticationError.html +1 -1
  32. data/doc/SDM/BadRequestError.html +1 -1
  33. data/doc/SDM/BigQuery.html +3 -3
  34. data/doc/SDM/Cassandra.html +3 -3
  35. data/doc/SDM/Citus.html +3 -3
  36. data/doc/SDM/Client.html +8 -8
  37. data/doc/SDM/Clustrix.html +3 -3
  38. data/doc/SDM/Cockroach.html +3 -3
  39. data/doc/SDM/CreateResponseMetadata.html +1 -1
  40. data/doc/SDM/DB2.html +2 -2
  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 +3 -3
  46. data/doc/SDM/DynamoDB.html +3 -3
  47. data/doc/SDM/Elastic.html +3 -3
  48. data/doc/SDM/ElasticacheRedis.html +3 -3
  49. data/doc/SDM/Gateway.html +4 -4
  50. data/doc/SDM/GetResponseMetadata.html +1 -1
  51. data/doc/SDM/GoogleGKE.html +4 -40
  52. data/doc/SDM/Greenplum.html +3 -3
  53. data/doc/SDM/HTTPAuth.html +3 -3
  54. data/doc/SDM/HTTPBasicAuth.html +3 -3
  55. data/doc/SDM/HTTPNoAuth.html +3 -3
  56. data/doc/SDM/InternalError.html +1 -1
  57. data/doc/SDM/Kubernetes.html +4 -58
  58. data/doc/SDM/KubernetesBasicAuth.html +3 -3
  59. data/doc/SDM/KubernetesServiceAccount.html +3 -3
  60. data/doc/SDM/Maria.html +3 -3
  61. data/doc/SDM/Memcached.html +3 -3
  62. data/doc/SDM/Memsql.html +3 -3
  63. data/doc/SDM/MongoHost.html +3 -3
  64. data/doc/SDM/MongoLegacyHost.html +3 -3
  65. data/doc/SDM/MongoLegacyReplicaset.html +3 -3
  66. data/doc/SDM/MongoReplicaSet.html +3 -3
  67. data/doc/SDM/Mysql.html +3 -3
  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 +11 -11
  73. data/doc/SDM/NotFoundError.html +1 -1
  74. data/doc/SDM/Oracle.html +3 -3
  75. data/doc/SDM/PermissionError.html +1 -1
  76. data/doc/SDM/Plumbing.html +562 -556
  77. data/doc/SDM/Postgres.html +3 -3
  78. data/doc/SDM/Presto.html +3 -3
  79. data/doc/SDM/RDP.html +3 -3
  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 +3 -3
  84. data/doc/SDM/Redshift.html +3 -3
  85. data/doc/SDM/Relay.html +4 -4
  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 +7 -7
  91. data/doc/SDM/Role.html +4 -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 +6 -6
  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 +6 -6
  105. data/doc/SDM/RoleUpdateResponse.html +3 -3
  106. data/doc/SDM/Roles.html +7 -7
  107. data/doc/SDM/SQLServer.html +3 -3
  108. data/doc/SDM/SSH.html +3 -3
  109. data/doc/SDM/SSHCert.html +3 -3
  110. data/doc/SDM/Service.html +3 -3
  111. data/doc/SDM/Snowflake.html +3 -3
  112. data/doc/SDM/Sybase.html +3 -3
  113. data/doc/SDM/SybaseIQ.html +3 -3
  114. data/doc/SDM/Teradata.html +3 -3
  115. data/doc/SDM/UpdateResponseMetadata.html +1 -1
  116. data/doc/SDM/User.html +3 -3
  117. data/doc/V1.html +7 -7
  118. data/doc/V1/AccountAttachments.html +1 -1
  119. data/doc/V1/AccountAttachments/Service.html +2 -2
  120. data/doc/V1/AccountGrants.html +1 -1
  121. data/doc/V1/AccountGrants/Service.html +1 -1
  122. data/doc/V1/Accounts.html +1 -1
  123. data/doc/V1/Accounts/Service.html +3 -3
  124. data/doc/V1/Nodes.html +1 -1
  125. data/doc/V1/Nodes/Service.html +5 -5
  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 +1 -1
  135. data/doc/created.rid +35 -43
  136. data/doc/css/rdoc.css +13 -5
  137. data/doc/examples/Gemfile.html +1 -11
  138. data/doc/index.html +4 -14
  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/strongdm_gemspec.html +0 -8
  145. data/doc/table_of_contents.html +161 -186
  146. data/lib/grpc/account_attachments_pb.rb +0 -5
  147. data/lib/grpc/account_attachments_services_pb.rb +1 -1
  148. data/lib/grpc/accounts_services_pb.rb +3 -4
  149. data/lib/grpc/drivers_pb.rb +17 -12
  150. data/lib/grpc/nodes_services_pb.rb +3 -4
  151. data/lib/grpc/plumbing.rb +70 -64
  152. data/lib/models/porcelain.rb +81 -84
  153. data/lib/strongdm.rb +7 -9
  154. data/lib/svc.rb +7 -11
  155. data/lib/version +5 -5
  156. data/lib/version.rb +1 -1
  157. data/strongdm.gemspec +1 -1
  158. metadata +5 -10
  159. data/examples/Gemfile.lock +0 -14
  160. data/examples/README.md +0 -5
  161. data/examples/okta-sync/Gemfile +0 -4
  162. data/examples/okta-sync/Gemfile.lock +0 -38
  163. data/examples/okta-sync/matchers.yml +0 -11
  164. data/examples/okta-sync/oktaSync.rb +0 -173
  165. data/examples/panicButton.rb +0 -138
@@ -90,19 +90,17 @@ module SDM
90
90
 
91
91
  # API authentication token (read-only).
92
92
  attr_reader :api_access_key
93
- # AccountAttachments assign an account to a role.
93
+ # AccountAttachments assign an account to a role or composite role.
94
94
  attr_reader :account_attachments
95
95
  # AccountGrants assign a resource directly to an account, giving the account the permission to connect to that resource.
96
96
  attr_reader :account_grants
97
- # Accounts are users that have access to strongDM.
98
- # There are two types of accounts:
99
- # 1. **Regular users:** humans who are authenticated through username and password or SSO
100
- # 2. **Service users:** machines that are authneticated using a service token
97
+ # Accounts are users that have access to strongDM. There are two types of accounts:
98
+ # 1. **Users:** humans who are authenticated through username and password or SSO.
99
+ # 2. **Service Accounts:** machines that are authenticated using a service token.
101
100
  attr_reader :accounts
102
- # Nodes make up the strongDM network, and allow your users to connect securely to your resources.
103
- # There are two types of nodes:
104
- # 1. **Relay:** creates connectivity to your datasources, while maintaining the egress-only nature of your firewall
105
- # 1. **Gateways:** a relay that also listens for connections from strongDM clients
101
+ # Nodes make up the strongDM network, and allow your users to connect securely to your resources. There are two types of nodes:
102
+ # - **Gateways** are the entry points into network. They listen for connection from the strongDM client, and provide access to databases and servers.
103
+ # - **Relays** are used to extend the strongDM network into segmented subnets. They provide access to databases and servers but do not listen for incoming connections.
106
104
  attr_reader :nodes
107
105
 
108
106
  attr_reader :resources
data/lib/svc.rb CHANGED
@@ -24,7 +24,7 @@ Dir[File.join(__dir__, "grpc", "*.rb")].each { |file| require file }
24
24
  Dir[File.join(__dir__, "models", "*.rb")].each { |file| require file }
25
25
 
26
26
  module SDM
27
- # AccountAttachments assign an account to a role.
27
+ # AccountAttachments assign an account to a role or composite role.
28
28
  class AccountAttachments
29
29
  def initialize(host, insecure, parent)
30
30
  begin
@@ -43,13 +43,11 @@ module SDM
43
43
  # Create registers a new AccountAttachment.
44
44
  def create(
45
45
  account_attachment,
46
- options: nil,
47
46
  deadline: nil
48
47
  )
49
48
  req = V1::AccountAttachmentCreateRequest.new()
50
49
 
51
50
  req.account_attachment = Plumbing::convert_account_attachment_to_plumbing(account_attachment)
52
- req.options = Plumbing::convert_account_attachment_create_options_to_plumbing(options)
53
51
  tries = 0
54
52
  plumbing_response = nil
55
53
  loop do
@@ -312,10 +310,9 @@ module SDM
312
310
  end
313
311
  end
314
312
 
315
- # Accounts are users that have access to strongDM.
316
- # There are two types of accounts:
317
- # 1. **Regular users:** humans who are authenticated through username and password or SSO
318
- # 2. **Service users:** machines that are authneticated using a service token
313
+ # Accounts are users that have access to strongDM. There are two types of accounts:
314
+ # 1. **Users:** humans who are authenticated through username and password or SSO.
315
+ # 2. **Service Accounts:** machines that are authenticated using a service token.
319
316
  class Accounts
320
317
  def initialize(host, insecure, parent)
321
318
  begin
@@ -489,10 +486,9 @@ module SDM
489
486
  end
490
487
  end
491
488
 
492
- # Nodes make up the strongDM network, and allow your users to connect securely to your resources.
493
- # There are two types of nodes:
494
- # 1. **Relay:** creates connectivity to your datasources, while maintaining the egress-only nature of your firewall
495
- # 1. **Gateways:** a relay that also listens for connections from strongDM clients
489
+ # Nodes make up the strongDM network, and allow your users to connect securely to your resources. There are two types of nodes:
490
+ # - **Gateways** are the entry points into network. They listen for connection from the strongDM client, and provide access to databases and servers.
491
+ # - **Relays** are used to extend the strongDM network into segmented subnets. They provide access to databases and servers but do not listen for incoming connections.
496
492
  class Nodes
497
493
  def initialize(host, insecure, parent)
498
494
  begin
@@ -1,17 +1,17 @@
1
1
  # Copyright 2020 StrongDM Inc
2
- #
2
+ #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at
6
- #
6
+ #
7
7
  # http://www.apache.org/licenses/LICENSE-2.0
8
- #
8
+ #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- #
14
+ #
15
15
  module SDM
16
- VERSION = "1.0.5"
16
+ VERSION = "1.0.12"
17
17
  end
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  module SDM
16
- VERSION = "1.0.5"
16
+ VERSION = "1.0.12"
17
17
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["strongDM Team"]
9
9
  s.email = ["sdk-feedback@strongdm.com"]
10
- s.homepage = "http://rubygems.org/gems/strongdm"
10
+ s.homepage = "https://github.com/strongdm/strongdm-sdk-ruby"
11
11
  s.summary = "strongDM SDK for the Ruby programming language."
12
12
  s.description = "strongDM Ruby Library for automating interactions with strongDM."
13
13
  s.licenses = ["Apache-2.0"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strongdm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.12
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-06-09 00:00:00.000000000 Z
11
+ date: 2020-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc
@@ -120,6 +120,8 @@ files:
120
120
  - doc/SDM/Cockroach.html
121
121
  - doc/SDM/CreateResponseMetadata.html
122
122
  - doc/SDM/DB2.html
123
+ - doc/SDM/DB2LUW.html
124
+ - doc/SDM/DB2i.html
123
125
  - doc/SDM/DeadlineExceededError.html
124
126
  - doc/SDM/DeleteResponseMetadata.html
125
127
  - doc/SDM/Druid.html
@@ -265,14 +267,7 @@ files:
265
267
  - doc/strongdm_gemspec.html
266
268
  - doc/table_of_contents.html
267
269
  - examples/Gemfile
268
- - examples/Gemfile.lock
269
- - examples/README.md
270
270
  - examples/listUsers.rb
271
- - examples/okta-sync/Gemfile
272
- - examples/okta-sync/Gemfile.lock
273
- - examples/okta-sync/matchers.yml
274
- - examples/okta-sync/oktaSync.rb
275
- - examples/panicButton.rb
276
271
  - lib/errors/errors.rb
277
272
  - lib/grpc/account_attachments_pb.rb
278
273
  - lib/grpc/account_attachments_services_pb.rb
@@ -302,7 +297,7 @@ files:
302
297
  - lib/version
303
298
  - lib/version.rb
304
299
  - strongdm.gemspec
305
- homepage: http://rubygems.org/gems/strongdm
300
+ homepage: https://github.com/strongdm/strongdm-sdk-ruby
306
301
  licenses:
307
302
  - Apache-2.0
308
303
  metadata: {}
@@ -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,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
@@ -1,138 +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
- require "OpenSSL"
17
- require "JSON"
18
-
19
- # panicButton.rb suspends all users except for one admin,
20
- # in the fake use case of a critical break in or something
21
- # usage:
22
- # ruby panicButton.rb adminuser@email.com
23
- # to revert back to pre-panic state:
24
- # ruby panicButton.rb revert
25
- def main
26
- access_key = ENV["SDM_API_ACCESS_KEY"]
27
- secret_key = ENV["SDM_API_SECRET_KEY"]
28
- if access_key == nil or secret_key == nil
29
- puts "SDM_API_ACCESS_KEY and SDM_API_SECRET_KEY must be provided"
30
- return
31
- end
32
- client = SDM::Client.new(access_key, secret_key)
33
-
34
- if ARGV.size == 1 and ARGV[0] == "revert"
35
- state_file = File.open("state.json")
36
- state = JSON.load(state_file)
37
-
38
- reinstated_count = 0
39
-
40
- users = client.accounts.list("")
41
- users.each { |user|
42
- if user.suspended
43
- reinstated_count += 1
44
- user.suspended = false
45
- client.accounts.update(user)
46
- end
47
- }
48
- state["attachments"].each { |attachment|
49
- begin
50
- a = SDM::AccountAttachment.new()
51
- a.account_id = attachment["account_id"]
52
- a.role_id = attachment["role_id"]
53
- client.account_attachments.create(a)
54
- rescue SDM::AlreadyExistsError
55
- rescue => ex
56
- puts "skipping creation of attachment due to error: " + ex.to_s
57
- end
58
- }
59
- state["grants"].each { |attachment|
60
- begin
61
- g = SDM::AccountGrant.new()
62
- g.account_id = attachment["account_id"]
63
- g.resource_id = attachment["resource_id"]
64
- client.account_grants.create(g)
65
- rescue SDM::AlreadyExistsError
66
- rescue => ex
67
- puts "skipping creation of grant due to error: " + ex.to_s
68
- end
69
- }
70
-
71
- puts "reinstated " + reinstated_count.to_s + " users"
72
- puts "recreated " + state["attachments"].size.to_s + " account attachments"
73
- puts "recreated " + state["grants"].size.to_s + " account grants"
74
-
75
- return
76
- end
77
-
78
- admin_email = ""
79
- if ARGV.size == 1
80
- admin_email = ARGV[0]
81
- else
82
- puts "please provide an admin email to preserve"
83
- return 1
84
- end
85
-
86
- admin_user_id = ""
87
- users = client.accounts.list("email:?", admin_email)
88
- users.each { |user|
89
- admin_user_id = user.id
90
- }
91
-
92
- account_attachments = client.account_attachments.list("")
93
- account_grants = client.account_grants.list("")
94
-
95
- state = {
96
- 'attachments': account_attachments.map { |x|
97
- if x.account_id != admin_user_id
98
- out = {
99
- 'account_id': x.account_id,
100
- 'role_id': x.role_id,
101
- }
102
- end
103
- }.reject { |x| x == nil },
104
- 'grants': account_grants.map { |x|
105
- if x.account_id != admin_user_id and x.valid_until == nil
106
- out = {
107
- 'account_id': x.account_id,
108
- 'resource_id': x.resource_id,
109
- }
110
- end
111
- }.reject { |x| x == nil },
112
- }
113
-
114
- puts "storing " + state[:attachments].size.to_s + " account attachments in state"
115
- puts "storing " + state[:grants].size.to_s + " account grants in state"
116
-
117
- state_file = File.open("state.json", "w")
118
- state_file.write(state.to_json)
119
-
120
- suspended_count = 0
121
- users = client.accounts.list("")
122
- users.each { |user|
123
- if user.instance_of? SDM::User and user.email == admin_email
124
- next
125
- end
126
- user.suspended = true
127
- begin
128
- client.accounts.update(user)
129
- suspended_count += 1
130
- rescue StandardError => ex
131
- puts "skipping user " + user.id + " on account of error: " + ex.to_s
132
- end
133
- }
134
-
135
- puts "suspended " + suspended_count.to_s + " users"
136
- end
137
-
138
- main()