strongdm 1.0.3 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -6
- data/doc/LICENSE.html +3 -9
- data/doc/Object.html +1 -356
- data/doc/README_md.html +34 -17
- data/doc/SDM.html +1 -1
- data/doc/SDM/AKS.html +9 -45
- data/doc/SDM/AKSBasicAuth.html +22 -4
- data/doc/SDM/AKSServiceAccount.html +22 -4
- data/doc/SDM/AccountAttachment.html +3 -3
- data/doc/SDM/AccountAttachmentCreateOptions.html +1 -1
- data/doc/SDM/AccountAttachmentCreateResponse.html +3 -3
- data/doc/SDM/AccountAttachmentDeleteResponse.html +3 -3
- data/doc/SDM/AccountAttachmentGetResponse.html +3 -3
- data/doc/SDM/AccountAttachments.html +5 -7
- data/doc/SDM/AccountCreateResponse.html +3 -3
- data/doc/SDM/AccountDeleteResponse.html +3 -3
- data/doc/SDM/AccountGetResponse.html +3 -3
- data/doc/SDM/AccountGrant.html +3 -3
- data/doc/SDM/AccountGrantCreateResponse.html +3 -3
- data/doc/SDM/AccountGrantDeleteResponse.html +3 -3
- data/doc/SDM/AccountGrantGetResponse.html +3 -3
- data/doc/SDM/AccountGrants.html +6 -6
- data/doc/SDM/AccountUpdateResponse.html +3 -3
- data/doc/SDM/Accounts.html +7 -7
- data/doc/SDM/AlreadyExistsError.html +1 -1
- data/doc/SDM/AmazonEKS.html +15 -15
- data/doc/SDM/AmazonES.html +3 -3
- data/doc/SDM/Athena.html +3 -3
- data/doc/SDM/AuroraMysql.html +3 -3
- data/doc/SDM/AuroraPostgres.html +3 -3
- data/doc/SDM/AuthenticationError.html +1 -1
- data/doc/SDM/BadRequestError.html +1 -1
- data/doc/SDM/BigQuery.html +3 -3
- data/doc/SDM/Cassandra.html +3 -3
- data/doc/SDM/Citus.html +409 -0
- data/doc/SDM/Client.html +1 -1
- data/doc/SDM/Clustrix.html +3 -3
- data/doc/SDM/Cockroach.html +3 -3
- data/doc/SDM/CreateResponseMetadata.html +1 -1
- data/doc/SDM/DB2.html +391 -0
- data/doc/SDM/DB2LUW.html +391 -0
- data/doc/SDM/DB2i.html +391 -0
- data/doc/SDM/DeadlineExceededError.html +1 -1
- data/doc/SDM/DeleteResponseMetadata.html +1 -1
- data/doc/SDM/Druid.html +3 -3
- data/doc/SDM/DynamoDB.html +3 -3
- data/doc/SDM/Elastic.html +3 -3
- data/doc/SDM/ElasticacheRedis.html +3 -3
- data/doc/SDM/Gateway.html +22 -4
- data/doc/SDM/GetResponseMetadata.html +1 -1
- data/doc/SDM/GoogleGKE.html +11 -29
- data/doc/SDM/Greenplum.html +3 -3
- data/doc/SDM/HTTPAuth.html +3 -3
- data/doc/SDM/HTTPBasicAuth.html +3 -3
- data/doc/SDM/HTTPNoAuth.html +3 -3
- data/doc/SDM/InternalError.html +1 -1
- data/doc/SDM/Kubernetes.html +9 -45
- data/doc/SDM/KubernetesBasicAuth.html +22 -4
- data/doc/SDM/KubernetesServiceAccount.html +22 -4
- data/doc/SDM/Maria.html +3 -3
- data/doc/SDM/Memcached.html +3 -3
- data/doc/SDM/Memsql.html +3 -3
- data/doc/SDM/MongoHost.html +3 -3
- data/doc/SDM/MongoLegacyHost.html +3 -3
- data/doc/SDM/MongoLegacyReplicaset.html +3 -3
- data/doc/SDM/MongoReplicaSet.html +3 -3
- data/doc/SDM/Mysql.html +3 -3
- data/doc/SDM/NodeCreateResponse.html +3 -3
- data/doc/SDM/NodeDeleteResponse.html +3 -3
- data/doc/SDM/NodeGetResponse.html +3 -3
- data/doc/SDM/NodeUpdateResponse.html +3 -3
- data/doc/SDM/Nodes.html +7 -7
- data/doc/SDM/NotFoundError.html +1 -1
- data/doc/SDM/Oracle.html +3 -3
- data/doc/SDM/PermissionError.html +1 -1
- data/doc/SDM/Plumbing.html +1254 -668
- data/doc/SDM/Postgres.html +3 -3
- data/doc/SDM/Presto.html +3 -3
- data/doc/SDM/RDP.html +3 -3
- data/doc/SDM/RPCError.html +1 -1
- data/doc/SDM/RateLimitError.html +1 -1
- data/doc/SDM/RateLimitMetadata.html +1 -1
- data/doc/SDM/Redis.html +3 -3
- data/doc/SDM/Redshift.html +3 -3
- data/doc/SDM/Relay.html +23 -5
- data/doc/SDM/ResourceCreateResponse.html +3 -3
- data/doc/SDM/ResourceDeleteResponse.html +3 -3
- data/doc/SDM/ResourceGetResponse.html +3 -3
- data/doc/SDM/ResourceUpdateResponse.html +3 -3
- data/doc/SDM/Resources.html +7 -7
- data/doc/SDM/Role.html +22 -4
- data/doc/SDM/RoleAttachment.html +3 -3
- data/doc/SDM/RoleAttachmentCreateResponse.html +3 -3
- data/doc/SDM/RoleAttachmentDeleteResponse.html +3 -3
- data/doc/SDM/RoleAttachmentGetResponse.html +3 -3
- data/doc/SDM/RoleAttachments.html +6 -6
- data/doc/SDM/RoleCreateResponse.html +3 -3
- data/doc/SDM/RoleDeleteResponse.html +3 -3
- data/doc/SDM/RoleGetResponse.html +3 -3
- data/doc/SDM/RoleGrant.html +3 -3
- data/doc/SDM/RoleGrantCreateResponse.html +3 -3
- data/doc/SDM/RoleGrantDeleteResponse.html +3 -3
- data/doc/SDM/RoleGrantGetResponse.html +3 -3
- data/doc/SDM/RoleGrants.html +6 -6
- data/doc/SDM/RoleUpdateResponse.html +3 -3
- data/doc/SDM/Roles.html +7 -7
- data/doc/SDM/SQLServer.html +3 -3
- data/doc/SDM/SSH.html +22 -4
- data/doc/SDM/SSHCert.html +373 -0
- data/doc/SDM/Service.html +22 -4
- data/doc/SDM/Snowflake.html +3 -3
- data/doc/SDM/Sybase.html +3 -3
- data/doc/SDM/SybaseIQ.html +3 -3
- data/doc/SDM/Teradata.html +3 -3
- data/doc/SDM/UpdateResponseMetadata.html +1 -1
- data/doc/SDM/User.html +22 -4
- data/doc/V1.html +21 -6
- data/doc/V1/AccountAttachments.html +1 -1
- data/doc/V1/AccountAttachments/Service.html +1 -1
- data/doc/V1/AccountGrants.html +1 -1
- data/doc/V1/AccountGrants/Service.html +1 -1
- data/doc/V1/Accounts.html +1 -1
- data/doc/V1/Accounts/Service.html +1 -1
- data/doc/V1/Nodes.html +1 -1
- data/doc/V1/Nodes/Service.html +1 -1
- data/doc/V1/Resources.html +1 -1
- data/doc/V1/Resources/Service.html +1 -1
- data/doc/V1/RoleAttachments.html +1 -1
- data/doc/V1/RoleAttachments/Service.html +1 -1
- data/doc/V1/RoleGrants.html +1 -1
- data/doc/V1/RoleGrants/Service.html +1 -1
- data/doc/V1/Roles.html +1 -1
- data/doc/V1/Roles/Service.html +1 -1
- data/doc/V1/Tags.html +1 -1
- data/doc/created.rid +39 -40
- data/doc/css/rdoc.css +5 -13
- data/doc/examples/Gemfile.html +3 -9
- data/doc/examples/Gemfile_lock.html +3 -1
- data/doc/examples/README_md.html +3 -1
- data/doc/examples/okta-sync/Gemfile.html +3 -1
- data/doc/examples/okta-sync/Gemfile_lock.html +3 -1
- data/doc/index.html +11 -11
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search_index.js +1 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js.gz +0 -0
- data/doc/lib/version.html +5 -11
- data/doc/strongdm_gemspec.html +6 -11
- data/doc/table_of_contents.html +452 -362
- data/examples/listUsers.rb +4 -4
- data/lib/grpc/account_attachments_pb.rb +0 -5
- data/lib/grpc/accounts_pb.rb +3 -0
- data/lib/grpc/drivers_pb.rb +65 -9
- data/lib/grpc/nodes_pb.rb +3 -0
- data/lib/grpc/options_pb.rb +2 -0
- data/lib/grpc/plumbing.rb +453 -245
- data/lib/grpc/roles_pb.rb +2 -0
- data/lib/grpc/spec_pb.rb +0 -1
- data/lib/models/porcelain.rb +5428 -41
- data/lib/svc.rb +0 -2
- data/lib/version +16 -2
- data/lib/version.rb +5 -5
- metadata +7 -9
- data/examples/Gemfile.lock +0 -14
- data/examples/README.md +0 -5
- data/examples/okta-sync/Gemfile +0 -4
- data/examples/okta-sync/Gemfile.lock +0 -38
- data/examples/okta-sync/matchers.yml +0 -11
- data/examples/okta-sync/oktaSync.rb +0 -173
- data/examples/panicButton.rb +0 -138
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99051b697a4ed19fb4cc796c12fc1a64bf97ebd1197a42877db6e517410d38eb
|
4
|
+
data.tar.gz: f6a84cd8cc08be3d146aeb2ab71674da4b673af3d25b3826ce38620167c289fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e3d8dda1dc999250b46c84df8868f6d796138d041f1135159951153a324f0bffde08a8883135d3652928b705d4087ee5ffff24398ee51dc6367b2a1dbf308d3
|
7
|
+
data.tar.gz: 716ef680d072f922eb27e4b6fd51df415c6f5d51ac9680d88900225593d276c20dcbe9cd8b00c47bfb932b49561f0bfab243787ababa0dd578532effc95ca224
|
data/README.md
CHANGED
@@ -1,23 +1,28 @@
|
|
1
1
|
# strongDM SDK for Ruby
|
2
2
|
|
3
|
-
|
3
|
+
This is the official [strongDM](https://www.strongdm.com/) SDK for the Ruby programming language.
|
4
4
|
|
5
|
-
|
5
|
+
Learn more with our [📚strongDM API docs](https://www.strongdm.com/docs/api/) or [📓browse the SDK reference](https://www.rubydoc.info/gems/strongdm).
|
6
6
|
|
7
|
-
|
7
|
+
|
8
|
+
## Installation
|
8
9
|
|
9
10
|
```bash
|
10
11
|
$ gem install strongdm
|
11
12
|
```
|
12
13
|
|
13
|
-
|
14
|
+
## Authentication
|
15
|
+
|
16
|
+
If you don't already have them you will need to generate a set of API keys, instructions are here: [API Credentials](https://www.strongdm.com/docs/admin-guide/api-credentials/)
|
14
17
|
|
18
|
+
Add the keys as environment variables; the SDK will need to access these keys for every request.
|
15
19
|
```bash
|
16
20
|
$ export SDM_API_ACCESS_KEY=<YOUR ACCESS KEY>
|
17
21
|
$ export SDM_API_SECRET_KEY=<YOUR SECRET KEY>
|
18
22
|
```
|
19
23
|
|
20
|
-
|
24
|
+
## List Users
|
25
|
+
The following code lists all registered users:
|
21
26
|
|
22
27
|
```ruby
|
23
28
|
require "strongdm"
|
@@ -27,4 +32,21 @@ users = client.accounts.list('')
|
|
27
32
|
users.each do |user|
|
28
33
|
p user
|
29
34
|
end
|
30
|
-
```
|
35
|
+
```
|
36
|
+
|
37
|
+
## Useful Links
|
38
|
+
|
39
|
+
* Documentation: [strongdm gem](https://www.rubydoc.info/gems/strongdm)
|
40
|
+
* Examples: [GitHub - strongdm/strongdm-sdk-ruby-examples](https://github.com/strongdm/strongdm-sdk-ruby-examples)
|
41
|
+
1. [Managing Resources](https://github.com/strongdm/strongdm-sdk-ruby-examples/tree/master/1_managing_resources)
|
42
|
+
2. [Managing Accounts](https://github.com/strongdm/strongdm-sdk-ruby-examples/tree/master/2_managing_accounts)
|
43
|
+
3. [Managing Roles](https://github.com/strongdm/strongdm-sdk-ruby-examples/tree/master/3_managing_roles)
|
44
|
+
4. [Managing Gateways](https://github.com/strongdm/strongdm-sdk-ruby-examples/tree/master/4_managing_gateways)
|
45
|
+
|
46
|
+
## License
|
47
|
+
|
48
|
+
[Apache 2](https://github.com/strongdm/strongdm-sdk-ruby/blob/master/LICENSE)
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
Currently, we are not accepting pull requests directly to this repository, but our users are some of the most resourceful and ambitious folks out there. So, if you have something to contribute, find a bug, or just want to give us some feedback, please email <support@strongdm.com>.
|
data/doc/LICENSE.html
CHANGED
@@ -69,16 +69,10 @@
|
|
69
69
|
|
70
70
|
<li><a href="./examples/Gemfile.html">Gemfile</a>
|
71
71
|
|
72
|
-
<li><a href="./examples/Gemfile_lock.html">Gemfile.lock</a>
|
73
|
-
|
74
|
-
<li><a href="./examples/README_md.html">README</a>
|
75
|
-
|
76
|
-
<li><a href="./examples/okta-sync/Gemfile.html">Gemfile</a>
|
77
|
-
|
78
|
-
<li><a href="./examples/okta-sync/Gemfile_lock.html">Gemfile.lock</a>
|
79
|
-
|
80
72
|
<li><a href="./lib/version.html">version</a>
|
81
73
|
|
74
|
+
<li><a href="./strongdm_gemspec.html">strongdm.gemspec</a>
|
75
|
+
|
82
76
|
</ul>
|
83
77
|
</div>
|
84
78
|
|
@@ -195,7 +189,7 @@ identification within third-party archives.</pre>
|
|
195
189
|
|
196
190
|
<footer id="validator-badges" role="contentinfo">
|
197
191
|
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
198
|
-
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.
|
192
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.1.2.
|
199
193
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
200
194
|
</footer>
|
201
195
|
|
data/doc/Object.html
CHANGED
@@ -69,19 +69,7 @@
|
|
69
69
|
|
70
70
|
|
71
71
|
|
72
|
-
<!-- Method Quickref -->
|
73
|
-
<div id="method-list-section" class="nav-section">
|
74
|
-
<h3>Methods</h3>
|
75
|
-
|
76
|
-
<ul class="link-list" role="directory">
|
77
|
-
|
78
|
-
<li ><a href="#method-i-main">#main</a>
|
79
|
-
|
80
|
-
<li ><a href="#method-i-okta_sync">#okta_sync</a>
|
81
72
|
|
82
|
-
</ul>
|
83
|
-
</div>
|
84
|
-
|
85
73
|
</div>
|
86
74
|
</nav>
|
87
75
|
|
@@ -122,26 +110,6 @@
|
|
122
110
|
<dd>
|
123
111
|
|
124
112
|
|
125
|
-
<dt id="OKTA_CLIENT_ORGURL">OKTA_CLIENT_ORGURL
|
126
|
-
|
127
|
-
<dd>
|
128
|
-
|
129
|
-
|
130
|
-
<dt id="OKTA_CLIENT_TOKEN">OKTA_CLIENT_TOKEN
|
131
|
-
|
132
|
-
<dd>
|
133
|
-
|
134
|
-
|
135
|
-
<dt id="SDM_API_ACCESS_KEY">SDM_API_ACCESS_KEY
|
136
|
-
|
137
|
-
<dd>
|
138
|
-
|
139
|
-
|
140
|
-
<dt id="SDM_API_SECRET_KEY">SDM_API_SECRET_KEY
|
141
|
-
|
142
|
-
<dd>
|
143
|
-
|
144
|
-
|
145
113
|
</dl>
|
146
114
|
</section>
|
147
115
|
|
@@ -149,329 +117,6 @@
|
|
149
117
|
|
150
118
|
|
151
119
|
|
152
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
153
|
-
<header>
|
154
|
-
<h3>Public Instance Methods</h3>
|
155
|
-
</header>
|
156
|
-
|
157
|
-
|
158
|
-
<div id="method-i-main" class="method-detail ">
|
159
|
-
|
160
|
-
<div class="method-heading">
|
161
|
-
<span class="method-name">main</span><span
|
162
|
-
class="method-args">()</span>
|
163
|
-
|
164
|
-
<span class="method-click-advice">click to toggle source</span>
|
165
|
-
|
166
|
-
</div>
|
167
|
-
|
168
|
-
|
169
|
-
<div class="method-description">
|
170
|
-
|
171
|
-
<p>panicButton.rb suspends all users except for one admin, in the fake use case of a critical break in or something usage: ruby panicButton.rb adminuser@email.com to revert back to pre-panic state: ruby panicButton.rb revert</p>
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
<div class="method-source-code" id="main-source">
|
177
|
-
<pre><span class="ruby-comment"># File examples/panicButton.rb, line 25</span>
|
178
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">main</span>
|
179
|
-
<span class="ruby-identifier">access_key</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-string">"SDM_API_ACCESS_KEY"</span>]
|
180
|
-
<span class="ruby-identifier">secret_key</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-string">"SDM_API_SECRET_KEY"</span>]
|
181
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">access_key</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">secret_key</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span>
|
182
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"SDM_API_ACCESS_KEY and SDM_API_SECRET_KEY must be provided"</span>
|
183
|
-
<span class="ruby-keyword">return</span>
|
184
|
-
<span class="ruby-keyword">end</span>
|
185
|
-
<span class="ruby-identifier">client</span> = <span class="ruby-constant">SDM</span><span class="ruby-operator">::</span><span class="ruby-constant">Client</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">access_key</span>, <span class="ruby-identifier">secret_key</span>)
|
186
|
-
|
187
|
-
<span class="ruby-keyword">if</span> <span class="ruby-constant">ARGV</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-keyword">and</span> <span class="ruby-constant">ARGV</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-string">"revert"</span>
|
188
|
-
<span class="ruby-identifier">state_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">"state.json"</span>)
|
189
|
-
<span class="ruby-identifier">state</span> = <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">state_file</span>)
|
190
|
-
|
191
|
-
<span class="ruby-identifier">reinstated_count</span> = <span class="ruby-value">0</span>
|
192
|
-
|
193
|
-
<span class="ruby-identifier">users</span> = <span class="ruby-identifier">client</span>.<span class="ruby-identifier">accounts</span>.<span class="ruby-identifier">list</span>(<span class="ruby-string">""</span>)
|
194
|
-
<span class="ruby-identifier">users</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">user</span><span class="ruby-operator">|</span>
|
195
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">user</span>.<span class="ruby-identifier">suspended</span>
|
196
|
-
<span class="ruby-identifier">reinstated_count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
197
|
-
<span class="ruby-identifier">user</span>.<span class="ruby-identifier">suspended</span> = <span class="ruby-keyword">false</span>
|
198
|
-
<span class="ruby-identifier">client</span>.<span class="ruby-identifier">accounts</span>.<span class="ruby-identifier">update</span>(<span class="ruby-identifier">user</span>)
|
199
|
-
<span class="ruby-keyword">end</span>
|
200
|
-
}
|
201
|
-
<span class="ruby-identifier">state</span>[<span class="ruby-string">"attachments"</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">attachment</span><span class="ruby-operator">|</span>
|
202
|
-
<span class="ruby-keyword">begin</span>
|
203
|
-
<span class="ruby-identifier">a</span> = <span class="ruby-constant">SDM</span><span class="ruby-operator">::</span><span class="ruby-constant">AccountAttachment</span>.<span class="ruby-identifier">new</span>()
|
204
|
-
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">account_id</span> = <span class="ruby-identifier">attachment</span>[<span class="ruby-string">"account_id"</span>]
|
205
|
-
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">role_id</span> = <span class="ruby-identifier">attachment</span>[<span class="ruby-string">"role_id"</span>]
|
206
|
-
<span class="ruby-identifier">client</span>.<span class="ruby-identifier">account_attachments</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">a</span>)
|
207
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">SDM</span><span class="ruby-operator">::</span><span class="ruby-constant">AlreadyExistsError</span>
|
208
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">ex</span>
|
209
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"skipping creation of attachment due to error: "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">ex</span>.<span class="ruby-identifier">to_s</span>
|
210
|
-
<span class="ruby-keyword">end</span>
|
211
|
-
}
|
212
|
-
<span class="ruby-identifier">state</span>[<span class="ruby-string">"grants"</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">attachment</span><span class="ruby-operator">|</span>
|
213
|
-
<span class="ruby-keyword">begin</span>
|
214
|
-
<span class="ruby-identifier">g</span> = <span class="ruby-constant">SDM</span><span class="ruby-operator">::</span><span class="ruby-constant">AccountGrant</span>.<span class="ruby-identifier">new</span>()
|
215
|
-
<span class="ruby-identifier">g</span>.<span class="ruby-identifier">account_id</span> = <span class="ruby-identifier">attachment</span>[<span class="ruby-string">"account_id"</span>]
|
216
|
-
<span class="ruby-identifier">g</span>.<span class="ruby-identifier">resource_id</span> = <span class="ruby-identifier">attachment</span>[<span class="ruby-string">"resource_id"</span>]
|
217
|
-
<span class="ruby-identifier">client</span>.<span class="ruby-identifier">account_grants</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">g</span>)
|
218
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">SDM</span><span class="ruby-operator">::</span><span class="ruby-constant">AlreadyExistsError</span>
|
219
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">ex</span>
|
220
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"skipping creation of grant due to error: "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">ex</span>.<span class="ruby-identifier">to_s</span>
|
221
|
-
<span class="ruby-keyword">end</span>
|
222
|
-
}
|
223
|
-
|
224
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"reinstated "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">reinstated_count</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-string">" users"</span>
|
225
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"recreated "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">state</span>[<span class="ruby-string">"attachments"</span>].<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-string">" account attachments"</span>
|
226
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"recreated "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">state</span>[<span class="ruby-string">"grants"</span>].<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-string">" account grants"</span>
|
227
|
-
|
228
|
-
<span class="ruby-keyword">return</span>
|
229
|
-
<span class="ruby-keyword">end</span>
|
230
|
-
|
231
|
-
<span class="ruby-identifier">admin_email</span> = <span class="ruby-string">""</span>
|
232
|
-
<span class="ruby-keyword">if</span> <span class="ruby-constant">ARGV</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
233
|
-
<span class="ruby-identifier">admin_email</span> = <span class="ruby-constant">ARGV</span>[<span class="ruby-value">0</span>]
|
234
|
-
<span class="ruby-keyword">else</span>
|
235
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"please provide an admin email to preserve"</span>
|
236
|
-
<span class="ruby-keyword">return</span> <span class="ruby-value">1</span>
|
237
|
-
<span class="ruby-keyword">end</span>
|
238
|
-
|
239
|
-
<span class="ruby-identifier">admin_user_id</span> = <span class="ruby-string">""</span>
|
240
|
-
<span class="ruby-identifier">users</span> = <span class="ruby-identifier">client</span>.<span class="ruby-identifier">accounts</span>.<span class="ruby-identifier">list</span>(<span class="ruby-string">"email:?"</span>, <span class="ruby-identifier">admin_email</span>)
|
241
|
-
<span class="ruby-identifier">users</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">user</span><span class="ruby-operator">|</span>
|
242
|
-
<span class="ruby-identifier">admin_user_id</span> = <span class="ruby-identifier">user</span>.<span class="ruby-identifier">id</span>
|
243
|
-
}
|
244
|
-
|
245
|
-
<span class="ruby-identifier">account_attachments</span> = <span class="ruby-identifier">client</span>.<span class="ruby-identifier">account_attachments</span>.<span class="ruby-identifier">list</span>(<span class="ruby-string">""</span>)
|
246
|
-
<span class="ruby-identifier">account_grants</span> = <span class="ruby-identifier">client</span>.<span class="ruby-identifier">account_grants</span>.<span class="ruby-identifier">list</span>(<span class="ruby-string">""</span>)
|
247
|
-
|
248
|
-
<span class="ruby-identifier">state</span> = {
|
249
|
-
<span class="ruby-value">'attachments':</span> <span class="ruby-identifier">account_attachments</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span>
|
250
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">account_id</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">admin_user_id</span>
|
251
|
-
<span class="ruby-identifier">out</span> = {
|
252
|
-
<span class="ruby-value">'account_id':</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">account_id</span>,
|
253
|
-
<span class="ruby-value">'role_id':</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">role_id</span>,
|
254
|
-
}
|
255
|
-
<span class="ruby-keyword">end</span>
|
256
|
-
}.<span class="ruby-identifier">reject</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> },
|
257
|
-
<span class="ruby-value">'grants':</span> <span class="ruby-identifier">account_grants</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span>
|
258
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">account_id</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">admin_user_id</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">valid_until</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span>
|
259
|
-
<span class="ruby-identifier">out</span> = {
|
260
|
-
<span class="ruby-value">'account_id':</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">account_id</span>,
|
261
|
-
<span class="ruby-value">'resource_id':</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">resource_id</span>,
|
262
|
-
}
|
263
|
-
<span class="ruby-keyword">end</span>
|
264
|
-
}.<span class="ruby-identifier">reject</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> },
|
265
|
-
}
|
266
|
-
|
267
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"storing "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">state</span>[<span class="ruby-value">:attachments</span>].<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-string">" account attachments in state"</span>
|
268
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"storing "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">state</span>[<span class="ruby-value">:grants</span>].<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-string">" account grants in state"</span>
|
269
|
-
|
270
|
-
<span class="ruby-identifier">state_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">"state.json"</span>, <span class="ruby-string">"w"</span>)
|
271
|
-
<span class="ruby-identifier">state_file</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">state</span>.<span class="ruby-identifier">to_json</span>)
|
272
|
-
|
273
|
-
<span class="ruby-identifier">suspended_count</span> = <span class="ruby-value">0</span>
|
274
|
-
<span class="ruby-identifier">users</span> = <span class="ruby-identifier">client</span>.<span class="ruby-identifier">accounts</span>.<span class="ruby-identifier">list</span>(<span class="ruby-string">""</span>)
|
275
|
-
<span class="ruby-identifier">users</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">user</span><span class="ruby-operator">|</span>
|
276
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">user</span>.<span class="ruby-identifier">instance_of?</span> <span class="ruby-constant">SDM</span><span class="ruby-operator">::</span><span class="ruby-constant">User</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">user</span>.<span class="ruby-identifier">email</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">admin_email</span>
|
277
|
-
<span class="ruby-keyword">next</span>
|
278
|
-
<span class="ruby-keyword">end</span>
|
279
|
-
<span class="ruby-identifier">user</span>.<span class="ruby-identifier">suspended</span> = <span class="ruby-keyword">true</span>
|
280
|
-
<span class="ruby-keyword">begin</span>
|
281
|
-
<span class="ruby-identifier">client</span>.<span class="ruby-identifier">accounts</span>.<span class="ruby-identifier">update</span>(<span class="ruby-identifier">user</span>)
|
282
|
-
<span class="ruby-identifier">suspended_count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
283
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">ex</span>
|
284
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"skipping user "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">user</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">+</span> <span class="ruby-string">" on account of error: "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">ex</span>.<span class="ruby-identifier">to_s</span>
|
285
|
-
<span class="ruby-keyword">end</span>
|
286
|
-
}
|
287
|
-
|
288
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"suspended "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">suspended_count</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-string">" users"</span>
|
289
|
-
<span class="ruby-keyword">end</span></pre>
|
290
|
-
</div>
|
291
|
-
|
292
|
-
</div>
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
</div>
|
298
|
-
|
299
|
-
|
300
|
-
<div id="method-i-okta_sync" class="method-detail ">
|
301
|
-
|
302
|
-
<div class="method-heading">
|
303
|
-
<span class="method-name">okta_sync</span><span
|
304
|
-
class="method-args">()</span>
|
305
|
-
|
306
|
-
<span class="method-click-advice">click to toggle source</span>
|
307
|
-
|
308
|
-
</div>
|
309
|
-
|
310
|
-
|
311
|
-
<div class="method-description">
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
<div class="method-source-code" id="okta_sync-source">
|
319
|
-
<pre><span class="ruby-comment"># File examples/okta-sync/oktaSync.rb, line 25</span>
|
320
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">okta_sync</span>
|
321
|
-
<span class="ruby-keyword">if</span> <span class="ruby-constant">SDM_API_ACCESS_KEY</span> <span class="ruby-operator">==</span> <span class="ruby-string">""</span> <span class="ruby-operator">||</span> <span class="ruby-constant">SDM_API_SECRET_KEY</span> <span class="ruby-operator">==</span> <span class="ruby-string">""</span> <span class="ruby-operator">||</span> <span class="ruby-constant">OKTA_CLIENT_TOKEN</span> <span class="ruby-operator">==</span> <span class="ruby-string">""</span> <span class="ruby-operator">||</span> <span class="ruby-constant">OKTA_CLIENT_ORGURL</span> <span class="ruby-operator">==</span> <span class="ruby-string">""</span>
|
322
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"SDM_API_ACCESS_KEY, SDM_API_SECRET_KEY, OKTA_CLIENT_TOKEN, and OKTA_CLIENT_ORGURL must be set"</span>
|
323
|
-
<span class="ruby-identifier">exit</span>
|
324
|
-
<span class="ruby-keyword">end</span>
|
325
|
-
|
326
|
-
<span class="ruby-identifier">report</span> = {
|
327
|
-
<span class="ruby-value">:start</span> <span class="ruby-operator">=></span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>,
|
328
|
-
|
329
|
-
<span class="ruby-value">:oktaUsersCount</span> <span class="ruby-operator">=></span> <span class="ruby-value">0</span>,
|
330
|
-
<span class="ruby-value">:oktaUsers</span> <span class="ruby-operator">=></span> [],
|
331
|
-
|
332
|
-
<span class="ruby-value">:sdmUsersCount</span> <span class="ruby-operator">=></span> <span class="ruby-value">0</span>,
|
333
|
-
<span class="ruby-value">:sdmUsers</span> <span class="ruby-operator">=></span> [],
|
334
|
-
|
335
|
-
<span class="ruby-value">:bothUsersCount</span> <span class="ruby-operator">=></span> <span class="ruby-value">0</span>,
|
336
|
-
|
337
|
-
<span class="ruby-value">:sdmResourcesCount</span> <span class="ruby-operator">=></span> <span class="ruby-value">0</span>,
|
338
|
-
<span class="ruby-value">:sdmResources</span> <span class="ruby-operator">=></span> {},
|
339
|
-
|
340
|
-
<span class="ruby-value">:permissionsGranted</span> <span class="ruby-operator">=></span> <span class="ruby-value">0</span>,
|
341
|
-
<span class="ruby-value">:permissionsRevoked</span> <span class="ruby-operator">=></span> <span class="ruby-value">0</span>,
|
342
|
-
<span class="ruby-value">:grants</span> <span class="ruby-operator">=></span> [],
|
343
|
-
<span class="ruby-value">:revocations</span> <span class="ruby-operator">=></span> [],
|
344
|
-
|
345
|
-
<span class="ruby-value">:matchers</span> <span class="ruby-operator">=></span> {},
|
346
|
-
}
|
347
|
-
|
348
|
-
<span class="ruby-identifier">plan</span> = <span class="ruby-keyword">false</span>
|
349
|
-
<span class="ruby-identifier">verbose</span> = <span class="ruby-keyword">false</span>
|
350
|
-
<span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
|
351
|
-
<span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-string">"Usage oktaSync.rb [options]"</span>
|
352
|
-
<span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-p"</span>, <span class="ruby-string">"--plan"</span>, <span class="ruby-string">"calculate changes but do not apply them"</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
|
353
|
-
<span class="ruby-identifier">plan</span> = <span class="ruby-identifier">p</span>
|
354
|
-
<span class="ruby-keyword">end</span>
|
355
|
-
<span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-v"</span>, <span class="ruby-string">"--verbose"</span>, <span class="ruby-string">"print detailed report"</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
356
|
-
<span class="ruby-identifier">verbose</span> = <span class="ruby-identifier">v</span>
|
357
|
-
<span class="ruby-keyword">end</span>
|
358
|
-
<span class="ruby-keyword">end</span>.<span class="ruby-identifier">parse!</span>
|
359
|
-
|
360
|
-
<span class="ruby-identifier">client</span> = <span class="ruby-constant">SDM</span><span class="ruby-operator">::</span><span class="ruby-constant">Client</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">SDM_API_ACCESS_KEY</span>, <span class="ruby-constant">SDM_API_SECRET_KEY</span>)
|
361
|
-
<span class="ruby-identifier">okta_client</span> = <span class="ruby-constant">Oktakit</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">token:</span> <span class="ruby-constant">OKTA_CLIENT_TOKEN</span>, <span class="ruby-value">api_endpoint:</span> <span class="ruby-constant">OKTA_CLIENT_ORGURL</span> <span class="ruby-operator">+</span> <span class="ruby-string">"/api/v1"</span>)
|
362
|
-
<span class="ruby-identifier">matchers</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">"matchers.yml"</span>))
|
363
|
-
<span class="ruby-identifier">report</span>[<span class="ruby-value">:matchers</span>] = <span class="ruby-identifier">matchers</span>
|
364
|
-
|
365
|
-
<span class="ruby-identifier">all_users</span> = <span class="ruby-identifier">okta_client</span>.<span class="ruby-identifier">list_users</span>({
|
366
|
-
<span class="ruby-value">'query':</span> {
|
367
|
-
<span class="ruby-value">'search':</span> <span class="ruby-string">"profile.department eq \"Engineering\" and (status eq \"ACTIVE\")"</span>,
|
368
|
-
},
|
369
|
-
})
|
370
|
-
|
371
|
-
<span class="ruby-identifier">okta_users</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>()
|
372
|
-
<span class="ruby-identifier">all_users</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">u</span><span class="ruby-operator">|</span>
|
373
|
-
<span class="ruby-identifier">groups</span> = <span class="ruby-identifier">okta_client</span>.<span class="ruby-identifier">get_member_groups</span>(<span class="ruby-identifier">u</span>.<span class="ruby-identifier">id</span>)
|
374
|
-
<span class="ruby-identifier">group_names</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>()
|
375
|
-
<span class="ruby-identifier">groups</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">ug</span><span class="ruby-operator">|</span>
|
376
|
-
<span class="ruby-identifier">group_names</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">ug</span>.<span class="ruby-identifier">profile</span>.<span class="ruby-identifier">name</span>)
|
377
|
-
}
|
378
|
-
<span class="ruby-identifier">okta_users</span>.<span class="ruby-identifier">push</span>({ <span class="ruby-value">:login</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">u</span>.<span class="ruby-identifier">profile</span>.<span class="ruby-identifier">login</span>, <span class="ruby-value">:first_name</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">u</span>.<span class="ruby-identifier">profile</span>.<span class="ruby-identifier">firstName</span>, <span class="ruby-value">:last_name</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">u</span>.<span class="ruby-identifier">profile</span>.<span class="ruby-constant">LastName</span>, <span class="ruby-value">:groups</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">group_names</span> })
|
379
|
-
}
|
380
|
-
<span class="ruby-identifier">report</span>[<span class="ruby-value">:oktaUsers</span>] = <span class="ruby-identifier">okta_users</span>
|
381
|
-
<span class="ruby-identifier">report</span>[<span class="ruby-value">:oktaUsersCount</span>] = <span class="ruby-identifier">okta_users</span>.<span class="ruby-identifier">size</span>
|
382
|
-
|
383
|
-
<span class="ruby-identifier">accounts</span> = <span class="ruby-identifier">client</span>.<span class="ruby-identifier">accounts</span>.<span class="ruby-identifier">list</span>(<span class="ruby-string">"type:user"</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">a</span>.<span class="ruby-identifier">email</span>, <span class="ruby-identifier">a</span>] }.<span class="ruby-identifier">to_h</span>
|
384
|
-
<span class="ruby-identifier">report</span>[<span class="ruby-value">:sdmUsers</span>] = <span class="ruby-identifier">accounts</span>
|
385
|
-
<span class="ruby-identifier">report</span>[<span class="ruby-value">:sdmUsersCount</span>] = <span class="ruby-identifier">accounts</span>.<span class="ruby-identifier">size</span>
|
386
|
-
<span class="ruby-identifier">grants</span> = <span class="ruby-identifier">client</span>.<span class="ruby-identifier">account_grants</span>.<span class="ruby-identifier">list</span>(<span class="ruby-string">""</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">ag</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ag</span> }
|
387
|
-
|
388
|
-
<span class="ruby-identifier">current</span> = {}
|
389
|
-
<span class="ruby-identifier">grants</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">g</span><span class="ruby-operator">|</span>
|
390
|
-
<span class="ruby-identifier">current</span>[<span class="ruby-identifier">g</span>.<span class="ruby-identifier">account_id</span>] = [] <span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-identifier">current</span>[<span class="ruby-identifier">g</span>.<span class="ruby-identifier">account_id</span>]
|
391
|
-
<span class="ruby-identifier">current</span>[<span class="ruby-identifier">g</span>.<span class="ruby-identifier">account_id</span>].<span class="ruby-identifier">push</span>({ <span class="ruby-value">:resource_id</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">g</span>.<span class="ruby-identifier">resource_id</span>, <span class="ruby-value">:id</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">g</span>.<span class="ruby-identifier">id</span> })
|
392
|
-
}
|
393
|
-
|
394
|
-
<span class="ruby-identifier">desired</span> = {}
|
395
|
-
<span class="ruby-identifier">overlapping</span> = <span class="ruby-value">0</span>
|
396
|
-
<span class="ruby-identifier">matchers</span>[<span class="ruby-string">"groups"</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">group</span><span class="ruby-operator">|</span>
|
397
|
-
<span class="ruby-identifier">group</span>[<span class="ruby-string">"resources"</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">resourceQuery</span><span class="ruby-operator">|</span>
|
398
|
-
<span class="ruby-identifier">client</span>.<span class="ruby-identifier">resources</span>.<span class="ruby-identifier">list</span>(<span class="ruby-identifier">resourceQuery</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">res</span><span class="ruby-operator">|</span>
|
399
|
-
<span class="ruby-identifier">report</span>[<span class="ruby-value">:sdmResources</span>][<span class="ruby-identifier">res</span>.<span class="ruby-identifier">id</span>] = <span class="ruby-identifier">res</span>
|
400
|
-
<span class="ruby-identifier">okta_users</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">u</span><span class="ruby-operator">|</span>
|
401
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">u</span>[<span class="ruby-value">:groups</span>].<span class="ruby-identifier">include?</span> <span class="ruby-identifier">group</span>[<span class="ruby-string">"name"</span>]
|
402
|
-
<span class="ruby-identifier">account</span> = <span class="ruby-identifier">accounts</span>[<span class="ruby-identifier">u</span>[<span class="ruby-value">:login</span>]]
|
403
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">account</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
404
|
-
<span class="ruby-identifier">overlapping</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
405
|
-
<span class="ruby-identifier">desired</span>[<span class="ruby-identifier">account</span>.<span class="ruby-identifier">id</span>] = [] <span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-identifier">desired</span>[<span class="ruby-identifier">account</span>.<span class="ruby-identifier">id</span>]
|
406
|
-
<span class="ruby-identifier">desired</span>[<span class="ruby-identifier">account</span>.<span class="ruby-identifier">id</span>].<span class="ruby-identifier">push</span>(<span class="ruby-identifier">res</span>.<span class="ruby-identifier">id</span>)
|
407
|
-
<span class="ruby-keyword">end</span>
|
408
|
-
<span class="ruby-keyword">end</span>
|
409
|
-
}
|
410
|
-
}
|
411
|
-
}
|
412
|
-
}
|
413
|
-
<span class="ruby-identifier">report</span>[<span class="ruby-value">:bothUsersCount</span>] = <span class="ruby-identifier">overlapping</span>
|
414
|
-
<span class="ruby-identifier">report</span>[<span class="ruby-value">:sdmResourcesCount</span>] = <span class="ruby-identifier">report</span>[<span class="ruby-value">:sdmResources</span>].<span class="ruby-identifier">size</span>
|
415
|
-
|
416
|
-
<span class="ruby-identifier">revocations</span> = <span class="ruby-value">0</span>
|
417
|
-
<span class="ruby-identifier">current</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">aid</span>, <span class="ruby-identifier">curRes</span><span class="ruby-operator">|</span>
|
418
|
-
<span class="ruby-identifier">desRes</span> = <span class="ruby-identifier">desired</span>[<span class="ruby-identifier">aid</span>]
|
419
|
-
<span class="ruby-identifier">desRes</span> = [] <span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-identifier">desired</span>[<span class="ruby-identifier">aid</span>]
|
420
|
-
<span class="ruby-identifier">curRes</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
|
421
|
-
<span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span>(<span class="ruby-identifier">desRes</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">r</span>[<span class="ruby-value">:resource_id</span>])
|
422
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">plan</span>
|
423
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"Plan: revoke %s from user %s\n"</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">r</span>[<span class="ruby-value">:resource_id</span>], <span class="ruby-identifier">aid</span>]
|
424
|
-
<span class="ruby-keyword">else</span>
|
425
|
-
<span class="ruby-identifier">client</span>.<span class="ruby-identifier">account_grants</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">r</span>[<span class="ruby-value">:id</span>])
|
426
|
-
<span class="ruby-keyword">end</span>
|
427
|
-
<span class="ruby-identifier">report</span>[<span class="ruby-value">:revocations</span>].<span class="ruby-identifier">push</span>(<span class="ruby-identifier">r</span>[<span class="ruby-value">:id</span>])
|
428
|
-
<span class="ruby-identifier">revocations</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
429
|
-
<span class="ruby-keyword">end</span>
|
430
|
-
}
|
431
|
-
}
|
432
|
-
<span class="ruby-identifier">report</span>[<span class="ruby-value">:permissionsRevoked</span>] = <span class="ruby-identifier">revocations</span>
|
433
|
-
|
434
|
-
<span class="ruby-identifier">grants</span> = <span class="ruby-value">0</span>
|
435
|
-
<span class="ruby-identifier">desired</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">aid</span>, <span class="ruby-identifier">desRes</span><span class="ruby-operator">|</span>
|
436
|
-
<span class="ruby-identifier">curRes</span> = <span class="ruby-identifier">current</span>[<span class="ruby-identifier">aid</span>]
|
437
|
-
<span class="ruby-identifier">curRes</span> = [] <span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-identifier">current</span>[<span class="ruby-identifier">aid</span>]
|
438
|
-
<span class="ruby-identifier">desRes</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
|
439
|
-
<span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span>(<span class="ruby-identifier">curRes</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">c</span>[<span class="ruby-value">:resource_id</span>] }.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">r</span>)
|
440
|
-
<span class="ruby-identifier">ag</span> = <span class="ruby-constant">SDM</span><span class="ruby-operator">::</span><span class="ruby-constant">AccountGrant</span>.<span class="ruby-identifier">new</span>()
|
441
|
-
<span class="ruby-identifier">ag</span>.<span class="ruby-identifier">account_id</span> = <span class="ruby-identifier">aid</span>
|
442
|
-
<span class="ruby-identifier">ag</span>.<span class="ruby-identifier">resource_id</span> = <span class="ruby-identifier">r</span>
|
443
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">plan</span>
|
444
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"Plan: grant %s to user %s\n"</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">r</span>, <span class="ruby-identifier">aid</span>]
|
445
|
-
<span class="ruby-keyword">else</span>
|
446
|
-
<span class="ruby-identifier">client</span>.<span class="ruby-identifier">account_grants</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">ag</span>)
|
447
|
-
<span class="ruby-keyword">end</span>
|
448
|
-
<span class="ruby-identifier">report</span>[<span class="ruby-value">:grants</span>].<span class="ruby-identifier">push</span>(<span class="ruby-identifier">ag</span>)
|
449
|
-
<span class="ruby-identifier">grants</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
450
|
-
<span class="ruby-keyword">end</span>
|
451
|
-
}
|
452
|
-
}
|
453
|
-
<span class="ruby-identifier">report</span>[<span class="ruby-value">:permissionsGranted</span>] = <span class="ruby-identifier">grants</span>
|
454
|
-
|
455
|
-
<span class="ruby-identifier">report</span>[<span class="ruby-value">:complete</span>] = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
456
|
-
|
457
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
|
458
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">report</span>.<span class="ruby-identifier">to_json</span>
|
459
|
-
<span class="ruby-keyword">else</span>
|
460
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-string">"%d Okta users, %d strongDM users, %d overlapping users, %d grants, %d revocations"</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">okta_users</span>.<span class="ruby-identifier">size</span>, <span class="ruby-identifier">accounts</span>.<span class="ruby-identifier">size</span>, <span class="ruby-identifier">overlapping</span>, <span class="ruby-identifier">grants</span>, <span class="ruby-identifier">revocations</span>]
|
461
|
-
<span class="ruby-keyword">end</span>
|
462
|
-
<span class="ruby-keyword">end</span></pre>
|
463
|
-
</div>
|
464
|
-
|
465
|
-
</div>
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
</div>
|
471
|
-
|
472
|
-
|
473
|
-
</section>
|
474
|
-
|
475
120
|
</section>
|
476
121
|
|
477
122
|
</main>
|
@@ -479,7 +124,7 @@
|
|
479
124
|
|
480
125
|
<footer id="validator-badges" role="contentinfo">
|
481
126
|
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
482
|
-
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.
|
127
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.1.2.
|
483
128
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
484
129
|
</footer>
|
485
130
|
|