okta-terraform-generator 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: be1b5bad3e26a996c3b4dfcd6d2bc1f50b272f9b2bf8f7c4e9e2b6999693fc92
4
+ data.tar.gz: 7745ad91a8734e6c66afc17537231caecc0422935cfd47944af0224f47e34161
5
+ SHA512:
6
+ metadata.gz: aacb28e2014b333edfa5a6be4342bc11aa6919241fca6a19ff722f50cabeabf63936d362b98a468680ccc4bba9ae3e278ac225d0f83a0f99c9660d4cc8da91db
7
+ data.tar.gz: 6a82e0741eea6ad0c14ae7bb0ab7025e70cd0d434a714478ca76826a1e1559af635f9fd33fc550c9071119438370d7fb3f9bfca8e915923e966ce8302963b7cf
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,10 @@
1
+ Metrics/AbcSize:
2
+ Max: 20
3
+ Metrics/BlockLength:
4
+ Max: 81
5
+ Metrics/LineLength:
6
+ Max: 152
7
+ Naming/FileName:
8
+ Enabled: false
9
+ Style/Documentation:
10
+ Enabled: false
@@ -0,0 +1,35 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+
6
+ cache:
7
+ - bundler
8
+
9
+ notifications:
10
+ email:
11
+ on_success: change
12
+ on_failure: always
13
+
14
+ branches:
15
+ only:
16
+ - master
17
+ - "/^v\\d+\\.\\d+\\.\\d+$/"
18
+
19
+ before_install: gem install bundler -v 1.16.1
20
+
21
+ install:
22
+ - bundle install
23
+
24
+ script:
25
+ - bundle exec rubocop
26
+ - bundle exec rake spec
27
+
28
+ deploy:
29
+ provider: rubygems
30
+ api_key:
31
+ secure: ce//9TbWkYgG93n5qWg1qcTxHeEg/AsW9j5B0gA0BUWkfkfEJODWHiMPPeMhS5v3VZas6CGy44VTWBmSSWsDNxj/wk1evLxnhPhE5JNrBwzqB259zcP3vhm3rk9XlBSC/zcKXJvj7GQF15Qhh/pM8Qr0MXSvYHN0/eHGy+26FImnrR8HaDyDG6EUivvUPZcv7XsffuEGdNqMWM99HWxbuCX3j1QVwx62ZYYTqs5I+kGrW3S3oAlC76yoqyDOR4yDQWVDGdE8k8hJ6xKzSah7W5s+Ywjw7QnpqoSANj2HfN79XJfhS6kt21QPr0+Qa2CRzcBuM1aEQx+J34kf1t8jDMWkIsnnyVBHxxgTxuA+Seem1kj6ZGtaVR9hrLtsTe0zJhprSTCl7aEFw91JnqmO1dKLTXAQJ5h2B1GvEjR8Ajhhf1PYBkiSFD1jwL5pJS4VirwSo6HhHIysK6swqZ/HgtzmCf4oTZsXeF8Ue/YOHpOJVsi0S+BkZx+FoELzuRq5QIWwnMcmbyzV+jAtsLjAbmNhpz0bhwo91uaJOYWlRXOOd2GVOMgLzHbIvJJmF7NNLAu1u+9+MLc88RjksoZvMsgbHfHaOThUATuYr65xfCCSTm9lNfizLdIxBRU5SU8tsgmQxQabu/L98lsPv4d88J7ZCEIfqztLoK//FAPxOIQ=
32
+ gem: okta-terraform-generator
33
+ on:
34
+ tags: true
35
+ repo: schubergphilis/okta-terraform-generator
@@ -0,0 +1,9 @@
1
+ # okta-terraform-generator CHANGELOG
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
6
+
7
+ ## 0.1.0 (2018-06-13)
8
+
9
+ First release.
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at shoekstra@schubergphilis.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'guard-rspec', require: false
5
+ gem 'pry', require: false
6
+ gem 'terminal-notifier-guard', require: false
7
+ end
8
+
9
+ group :test do
10
+ gem 'bundler', '~> 1.16'
11
+ gem 'multi_json'
12
+ gem 'rake', '~> 10.0'
13
+ gem 'rspec', '~> 3.0'
14
+ gem 'rspec-command'
15
+ gem 'rubocop'
16
+ gem 'vcr'
17
+ gem 'webmock'
18
+ end
19
+
20
+ gemspec
@@ -0,0 +1,132 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ okta-terraform-generator (0.1.0)
5
+ facets (~> 3.1)
6
+ mixlib-cli (~> 1.7)
7
+ octokit (~> 4.0)
8
+ oktakit (~> 0.2.0)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ addressable (2.5.2)
14
+ public_suffix (>= 2.0.2, < 4.0)
15
+ ast (2.4.0)
16
+ coderay (1.1.2)
17
+ crack (0.4.3)
18
+ safe_yaml (~> 1.0.0)
19
+ diff-lcs (1.3)
20
+ facets (3.1.0)
21
+ faraday (0.15.0)
22
+ multipart-post (>= 1.2, < 3)
23
+ ffi (1.9.23)
24
+ formatador (0.2.5)
25
+ guard (2.14.2)
26
+ formatador (>= 0.2.4)
27
+ listen (>= 2.7, < 4.0)
28
+ lumberjack (>= 1.0.12, < 2.0)
29
+ nenv (~> 0.1)
30
+ notiffany (~> 0.0)
31
+ pry (>= 0.9.12)
32
+ shellany (~> 0.0)
33
+ thor (>= 0.18.1)
34
+ guard-compat (1.2.1)
35
+ guard-rspec (4.7.3)
36
+ guard (~> 2.1)
37
+ guard-compat (~> 1.1)
38
+ rspec (>= 2.99.0, < 4.0)
39
+ hashdiff (0.3.7)
40
+ listen (3.1.5)
41
+ rb-fsevent (~> 0.9, >= 0.9.4)
42
+ rb-inotify (~> 0.9, >= 0.9.7)
43
+ ruby_dep (~> 1.2)
44
+ lumberjack (1.0.13)
45
+ method_source (0.9.0)
46
+ mixlib-cli (1.7.0)
47
+ mixlib-shellout (2.3.2)
48
+ multi_json (1.13.1)
49
+ multipart-post (2.0.0)
50
+ nenv (0.3.0)
51
+ notiffany (0.1.1)
52
+ nenv (~> 0.1)
53
+ shellany (~> 0.0)
54
+ octokit (4.9.0)
55
+ sawyer (~> 0.8.0, >= 0.5.3)
56
+ oktakit (0.2.0)
57
+ sawyer (~> 0.8.1)
58
+ parallel (1.12.1)
59
+ parser (2.5.1.0)
60
+ ast (~> 2.4.0)
61
+ powerpack (0.1.1)
62
+ pry (0.11.3)
63
+ coderay (~> 1.1.0)
64
+ method_source (~> 0.9.0)
65
+ public_suffix (3.0.2)
66
+ rainbow (3.0.0)
67
+ rake (10.5.0)
68
+ rb-fsevent (0.10.3)
69
+ rb-inotify (0.9.10)
70
+ ffi (>= 0.5.0, < 2)
71
+ rspec (3.7.0)
72
+ rspec-core (~> 3.7.0)
73
+ rspec-expectations (~> 3.7.0)
74
+ rspec-mocks (~> 3.7.0)
75
+ rspec-command (1.0.3)
76
+ mixlib-shellout (~> 2.0)
77
+ rspec (~> 3.2)
78
+ rspec-its (~> 1.2)
79
+ rspec-core (3.7.1)
80
+ rspec-support (~> 3.7.0)
81
+ rspec-expectations (3.7.0)
82
+ diff-lcs (>= 1.2.0, < 2.0)
83
+ rspec-support (~> 3.7.0)
84
+ rspec-its (1.2.0)
85
+ rspec-core (>= 3.0.0)
86
+ rspec-expectations (>= 3.0.0)
87
+ rspec-mocks (3.7.0)
88
+ diff-lcs (>= 1.2.0, < 2.0)
89
+ rspec-support (~> 3.7.0)
90
+ rspec-support (3.7.1)
91
+ rubocop (0.55.0)
92
+ parallel (~> 1.10)
93
+ parser (>= 2.5)
94
+ powerpack (~> 0.1)
95
+ rainbow (>= 2.2.2, < 4.0)
96
+ ruby-progressbar (~> 1.7)
97
+ unicode-display_width (~> 1.0, >= 1.0.1)
98
+ ruby-progressbar (1.9.0)
99
+ ruby_dep (1.5.0)
100
+ safe_yaml (1.0.4)
101
+ sawyer (0.8.1)
102
+ addressable (>= 2.3.5, < 2.6)
103
+ faraday (~> 0.8, < 1.0)
104
+ shellany (0.0.1)
105
+ terminal-notifier-guard (1.7.0)
106
+ thor (0.20.0)
107
+ unicode-display_width (1.3.2)
108
+ vcr (4.0.0)
109
+ webmock (3.4.1)
110
+ addressable (>= 2.3.6)
111
+ crack (>= 0.3.2)
112
+ hashdiff
113
+
114
+ PLATFORMS
115
+ ruby
116
+
117
+ DEPENDENCIES
118
+ bundler (~> 1.16)
119
+ guard-rspec
120
+ multi_json
121
+ okta-terraform-generator!
122
+ pry
123
+ rake (~> 10.0)
124
+ rspec (~> 3.0)
125
+ rspec-command
126
+ rubocop
127
+ terminal-notifier-guard
128
+ vcr
129
+ webmock
130
+
131
+ BUNDLED WITH
132
+ 1.16.1
@@ -0,0 +1,9 @@
1
+ guard 'rspec', cmd: 'bundle exec rspec' do
2
+ require 'guard/rspec/dsl'
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ rspec = dsl.rspec
6
+ watch(rspec.spec_helper) { rspec.spec_dir }
7
+ watch(rspec.spec_files)
8
+ watch(%r{^lib/**/.+\.rb$}) { rspec.spec_dir }
9
+ end
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,52 @@
1
+ # okta-terraform-generator
2
+
3
+ A command line helper to generate [Terraform](https://www.terraform.io/) files based on data found in an [Okta](https://www.okta.com/) tenant.
4
+
5
+ ## Installation
6
+
7
+ This gem installs a `okta-terraform-generator` bin, to install it:
8
+
9
+ ```
10
+ gem install okta-terraform-generator
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ The installed bin writes a file matching the name of the generator used in the current working directory (e.g. `github_membership.tf` when using the `github_membership` generator), so you'll want to be in the directory containing your Terraform plans when running `okta-terraform-generator`.
16
+
17
+ Running `okta-terraform-generator` will print available generators, running `okta-terraform-generator GENERATOR_NAME` will print generator specific usage.
18
+
19
+ ## Contributing
20
+
21
+ We welcome contributed improvements and bug fixes via the usual work flow:
22
+
23
+ 1. Fork this repository
24
+ 1. Create your feature branch (`git checkout -b my-new-feature`)
25
+ 1. Commit your changes (`git commit -am 'Add some feature'`)
26
+ 1. Push to the branch (`git push origin my-new-feature`)
27
+ 1. Create a new pull request
28
+
29
+ ## License & Authors
30
+
31
+ * Author: Stephen Hoekstra (shoekstra@schubergphilis.com)
32
+
33
+ ```
34
+ Copyright 2018 Stephen Hoekstra <shoekstra@schubergphilis.com>
35
+ Copyright 2018 Schuberg Philis
36
+
37
+ Licensed under the Apache License, Version 2.0 (the "License");
38
+ you may not use this file except in compliance with the License.
39
+ You may obtain a copy of the License at
40
+
41
+ http://www.apache.org/licenses/LICENSE-2.0
42
+
43
+ Unless required by applicable law or agreed to in writing, software
44
+ distributed under the License is distributed on an "AS IS" BASIS,
45
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46
+ See the License for the specific language governing permissions and
47
+ limitations under the License.
48
+ ```
49
+
50
+ ## Code of Conduct
51
+
52
+ Everyone interacting in the this project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/schubergphilis/okta-terraform-generator/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ ENV['OKTA_TEST_USER_GROUP'] = 'github_users'
5
+ ENV['OKTA_TEST_ADMIN_GROUP'] = 'github_admins'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task default: :spec
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'okta-terraform-generator/cli'
4
+
5
+ generator = OktaTerraformGenerator::CLI.new.load_generator
6
+ generator.run
@@ -0,0 +1,20 @@
1
+ #
2
+ # Copyright 2018 Stephen Hoekstra <shoekstra@schubergphilis.com>
3
+ # Copyright 2018 Schuberg Philis
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ module OktaTerraformGenerator
19
+ VERSION = '0.1.0'.freeze
20
+ end
@@ -0,0 +1,80 @@
1
+ #
2
+ # Copyright 2018 Stephen Hoekstra <shoekstra@schubergphilis.com>
3
+ # Copyright 2018 Schuberg Philis
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'facets/string'
19
+ require 'mixlib/cli'
20
+ require 'okta-terraform-generator/helper'
21
+ require 'oktakit'
22
+ require 'oktakit/client/extended_groups'
23
+
24
+ Dir[File.dirname(__FILE__) + '/cli/*.rb'].each { |file| require file }
25
+
26
+ module OktaTerraformGenerator
27
+ class CLI
28
+ include Mixlib::CLI
29
+ include OktaTerraformGenerator::Helper
30
+
31
+ banner 'Usage: okta-terraform-generator [--version] GENERATOR (options)'
32
+
33
+ def load_generator
34
+ if ARGV.empty?
35
+ print_usage
36
+ print_generators
37
+ exit 1
38
+ end
39
+
40
+ if ARGV.any? { |arg| arg.casecmp('--version').zero? }
41
+ puts "okta-terraform-generator v#{OktaTerraformGenerator::VERSION}"
42
+ exit 0
43
+ end
44
+
45
+ Object.const_get("OktaTerraformGenerator::CLI::#{generator_class}").new
46
+ end
47
+
48
+ private
49
+
50
+ def generator_class
51
+ generator_name.capitalize.camelcase
52
+ end
53
+
54
+ def generator_name
55
+ validate_generator
56
+ end
57
+
58
+ def print_generators
59
+ puts "\nThe following resource generators are available:\n"
60
+ valid_generators.each do |valid_generator|
61
+ puts " * #{valid_generator}"
62
+ end
63
+ puts ''
64
+ end
65
+
66
+ def valid_generators
67
+ Dir[File.dirname(__FILE__) + '/cli/*.rb'].map { |file| File.basename(file, '.rb') }.sort
68
+ end
69
+
70
+ def validate_generator
71
+ generator = ARGV[0]
72
+ return generator if valid_generators.include? generator
73
+
74
+ puts 'Invalid generator passed as first argument!'
75
+ print_usage
76
+ print_generators
77
+ exit 1
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,144 @@
1
+ #
2
+ # Copyright 2018 Stephen Hoekstra <shoekstra@schubergphilis.com>
3
+ # Copyright 2018 Schuberg Philis
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'octokit'
19
+ require 'okta-terraform-generator/cli'
20
+
21
+ module OktaTerraformGenerator
22
+ class CLI
23
+ class GithubMembership < OktaTerraformGenerator::CLI
24
+ include Mixlib::CLI
25
+
26
+ banner "Usage: okta-terraform-generator github_membership (options)\n\nOptions:"
27
+
28
+ option :github_token,
29
+ short: '-h GITHUB_TOKEN',
30
+ long: '--github-token GITHUB_TOKEN',
31
+ default: ENV['GITHUB_TOKEN'],
32
+ description: 'Specifies the GitHub API token',
33
+ required: true
34
+
35
+ option :okta_admin_group,
36
+ short: '-a OKTA_GITHUB_ADMIN_GROUP',
37
+ long: '--okta-github-admin-group OKTA_GITHUB_ADMIN_GROUP',
38
+ default: ENV['OKTA_GITHUB_ADMIN_GROUP'],
39
+ description: 'Specifies the Okta group containing GitHub admin users',
40
+ required: true
41
+
42
+ option :okta_endpoint,
43
+ short: '-e OKTA_ENDPOINT',
44
+ long: '--okta-endpoint OKTA_ENDPOINT',
45
+ default: ENV['OKTA_ENDPOINT'],
46
+ description: 'Specifies the Okta API endpoint (e.g. https://myorg.okta.com/api/v1)',
47
+ required: true
48
+
49
+ option :okta_group,
50
+ short: '-g OKTA_GITHUB_USER_GROUP',
51
+ long: '--okta-github-user-group OKTA_GITHUB_USER_GROUP',
52
+ default: ENV['OKTA_GITHUB_USER_GROUP'],
53
+ description: 'Specifies the Okta group containing GitHub users (can be a comma separated list)',
54
+ proc: proc { |okta_group| okta_group.split('.').map(&:strip) },
55
+ required: true
56
+
57
+ option :okta_token,
58
+ short: '-t OKTA_TOKEN',
59
+ long: '--okta-token OKTA_TOKEN',
60
+ default: ENV['OKTA_TOKEN'],
61
+ description: 'Specifies the Okta API token',
62
+ required: true
63
+
64
+ def run(argv = ARGV.dup)
65
+ if argv.size == 1
66
+ print_usage
67
+ exit 1
68
+ end
69
+
70
+ setup(argv)
71
+ generate
72
+ end
73
+
74
+ private
75
+
76
+ def setup(argv)
77
+ parse_options(argv)
78
+ end
79
+
80
+ def github_client
81
+ @github_client ||= Octokit::Client.new(access_token: config[:github_token])
82
+ end
83
+
84
+ def okta_client
85
+ @okta_client ||= Oktakit::Client.new(token: config[:okta_token], api_endpoint: config[:okta_endpoint])
86
+ end
87
+
88
+ def admins
89
+ @admin_group_id ||= okta_client.group_id(config[:okta_admin_group])
90
+ @admins ||= list_group_github_handles(@admin_group_id).map { |u| u.profile.login.downcase.split('@').shift }.sort
91
+ end
92
+
93
+ def github_handle(handle)
94
+ github_client.user(handle).login
95
+ rescue Octokit::NotFound
96
+ false
97
+ end
98
+
99
+ def list_group_github_handles(group_id)
100
+ okta_client.list_active_group_members(group_id).select { |user| user.profile.key?(:githubHandle) && !user.profile.githubHandle.empty? }
101
+ end
102
+
103
+ def user_or_admin(login)
104
+ admins.include?(login) ? 'admin' : 'member'
105
+ end
106
+
107
+ def add_login_and_github_handle(login_and_github_handle)
108
+ login, handle = login_and_github_handle(login_and_github_handle)
109
+
110
+ return unless (github_handle = github_handle(handle))
111
+ return if resource_name_exists? login
112
+
113
+ add_to_resource_hash(login.to_s => {
114
+ 'username' => github_handle,
115
+ 'role' => user_or_admin(login)
116
+ })
117
+ end
118
+
119
+ def login_and_github_handle(login_and_github_handle)
120
+ # login = Okta login
121
+ # handle = GitHub handle
122
+ login, handle = login_and_github_handle
123
+ login = login.split('@').shift
124
+ [login, handle]
125
+ end
126
+
127
+ def logins_and_github_handles(okta_group, group_id)
128
+ puts "Looking for active users in Okta group \"#{okta_group}\" (with group id: #{group_id}) and the \"githubHandle\" profile attribute set ... "
129
+ list_group_github_handles(group_id).map { |u| [u.profile.login.downcase, u.profile.githubHandle.downcase] }
130
+ end
131
+
132
+ def generate
133
+ config[:okta_group].each do |okta_group|
134
+ group_id = okta_client.group_id(okta_group)
135
+ logins_and_github_handles(okta_group, group_id).sort_by { |x, _y| x }.each do |login_and_github_handle|
136
+ add_login_and_github_handle(login_and_github_handle)
137
+ end
138
+ end
139
+
140
+ write_tf_file('github_membership.tf', resources)
141
+ end
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,51 @@
1
+ #
2
+ # Copyright 2018 Stephen Hoekstra <shoekstra@schubergphilis.com>
3
+ # Copyright 2018 Schuberg Philis
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'fileutils'
19
+ require 'json'
20
+ require 'pp'
21
+
22
+ module OktaTerraformGenerator
23
+ module Helper
24
+ def add_to_resource_hash(resource_config)
25
+ resources['resource'][resource].merge!(resource_config)
26
+ end
27
+
28
+ def print_usage
29
+ puts opt_parser
30
+ end
31
+
32
+ def resource_name_exists?(resource_name)
33
+ resources['resource'][resource].key? resource_name
34
+ end
35
+
36
+ def resource
37
+ @resource ||= cli_arguments.shift
38
+ end
39
+
40
+ def resources
41
+ @resources ||= { 'resource' => { resource => {} } }
42
+ end
43
+
44
+ def write_tf_file(tf_file, content)
45
+ File.open(tf_file, 'w') do |f|
46
+ f.write(JSON.pretty_generate(content) + "\n")
47
+ puts "\nWrote generated JSON to #{tf_file}"
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # Copyright 2018 Stephen Hoekstra <shoekstra@schubergphilis.com>
3
+ # Copyright 2018 Schuberg Philis
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'oktakit/client/groups'
19
+
20
+ module Oktakit
21
+ class Client
22
+ module ExtendedGroups
23
+ include Oktakit::Client::Groups
24
+
25
+ def list_active_group_members(group_id)
26
+ list_group_members(group_id).shift.select do |user|
27
+ user.status == 'ACTIVE'
28
+ end
29
+ end
30
+
31
+ def groups
32
+ @groups ||= list_groups.first
33
+ end
34
+
35
+ def group_id(group_name)
36
+ groups.select { |group| group[:type] == 'OKTA_GROUP' && group[:profile][:name] =~ /^#{group_name}$/i }.shift.id
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ module Oktakit
43
+ class Client
44
+ include ExtendedGroups
45
+ end
46
+ end
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'okta-terraform-generator'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'okta-terraform-generator'
7
+ spec.version = OktaTerraformGenerator::VERSION
8
+ spec.authors = ['Stephen Hoekstra']
9
+ spec.email = ['shoekstra@schubergphilis.com']
10
+
11
+ spec.description = 'This gem installs helper scripts to generate Terraform plans based on user or group data from Okta.'
12
+ spec.summary = 'Helpers to generate Terraform plans using data from Okta'
13
+ spec.homepage = 'https://github.com/schubergphilis/okta-terraform-generator'
14
+ spec.license = 'Apache-2.0'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = 'bin'
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_dependency 'facets', '~> 3.1'
24
+ spec.add_dependency 'mixlib-cli', '~> 1.7'
25
+ spec.add_dependency 'octokit', '~> 4.0'
26
+ spec.add_dependency 'oktakit', '~> 0.2.0'
27
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: okta-terraform-generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stephen Hoekstra
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-06-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: facets
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mixlib-cli
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: octokit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: oktakit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.0
69
+ description: This gem installs helper scripts to generate Terraform plans based on
70
+ user or group data from Okta.
71
+ email:
72
+ - shoekstra@schubergphilis.com
73
+ executables:
74
+ - okta-terraform-generator
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".rubocop.yml"
81
+ - ".travis.yml"
82
+ - CHANGELOG.md
83
+ - CODE_OF_CONDUCT.md
84
+ - Gemfile
85
+ - Gemfile.lock
86
+ - Guardfile
87
+ - LICENSE
88
+ - README.md
89
+ - Rakefile
90
+ - bin/okta-terraform-generator
91
+ - lib/okta-terraform-generator.rb
92
+ - lib/okta-terraform-generator/cli.rb
93
+ - lib/okta-terraform-generator/cli/github_membership.rb
94
+ - lib/okta-terraform-generator/helper.rb
95
+ - lib/oktakit/client/extended_groups.rb
96
+ - okta-terraform-generator.gemspec
97
+ homepage: https://github.com/schubergphilis/okta-terraform-generator
98
+ licenses:
99
+ - Apache-2.0
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.7.7
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Helpers to generate Terraform plans using data from Okta
121
+ test_files: []