simpleokta 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3c2978f423bda98ad6abb1b38ad0188bf6cb0e04f079fb3c7490b70eaa648ae5
4
+ data.tar.gz: 2b11a74d15293784ee2bd5553e7624363c6961b1c2a450a87490679409134f0e
5
+ SHA512:
6
+ metadata.gz: daf4875930536168a954a3b6a3b5f2a30f6e04cf30950310a72e8526da295b6b551a35d92d039ef74a7233ac438baca71881d50e95abe785cc1cdfcb8f2a89ee
7
+ data.tar.gz: 7957d372c06ce456f84c9adb8eb71bae67592b881749e2311fd62ce0d3d0cca791aa8e1e6fd9b3f9b324b587f966f808262428c84dc34a616c4c708148ee7c69
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ config/simpleokta.yml
10
+ .env
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
14
+ vendor/bundle
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.3
6
+ before_install: gem install bundler -v 2.1.4
@@ -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 bradenrshipley@gmail.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 [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in simpleokta.gemspec
6
+ gemspec
7
+
8
+ gem 'breakers'
9
+ gem 'config'
10
+ gem 'dotenv'
11
+ gem 'faraday', '~> 0.7.4'
12
+ gem 'http'
13
+ gem 'rake', '~> 12.0'
14
+ gem 'rest-client'
15
+ gem 'rspec', '~> 3.0'
16
+ gem 'vcr'
17
+ gem 'webmock'
18
+ gem 'yard'
data/Gemfile.lock ADDED
@@ -0,0 +1,136 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ simpleokta (0.1.5)
5
+ http
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ breakers (0.4.0)
13
+ faraday (>= 0.7.4, < 0.18)
14
+ multi_json (~> 1.0)
15
+ concurrent-ruby (1.1.8)
16
+ config (3.0.0)
17
+ deep_merge (~> 1.2, >= 1.2.1)
18
+ dry-validation (~> 1.0, >= 1.0.0)
19
+ crack (0.4.5)
20
+ rexml
21
+ deep_merge (1.2.1)
22
+ diff-lcs (1.4.4)
23
+ domain_name (0.5.20190701)
24
+ unf (>= 0.0.5, < 1.0.0)
25
+ dotenv (2.7.6)
26
+ dry-configurable (0.12.1)
27
+ concurrent-ruby (~> 1.0)
28
+ dry-core (~> 0.5, >= 0.5.0)
29
+ dry-container (0.7.2)
30
+ concurrent-ruby (~> 1.0)
31
+ dry-configurable (~> 0.1, >= 0.1.3)
32
+ dry-core (0.5.0)
33
+ concurrent-ruby (~> 1.0)
34
+ dry-equalizer (0.3.0)
35
+ dry-inflector (0.2.0)
36
+ dry-initializer (3.0.4)
37
+ dry-logic (1.1.0)
38
+ concurrent-ruby (~> 1.0)
39
+ dry-core (~> 0.5, >= 0.5)
40
+ dry-schema (1.6.1)
41
+ concurrent-ruby (~> 1.0)
42
+ dry-configurable (~> 0.8, >= 0.8.3)
43
+ dry-core (~> 0.5, >= 0.5)
44
+ dry-initializer (~> 3.0)
45
+ dry-logic (~> 1.0)
46
+ dry-types (~> 1.5)
47
+ dry-types (1.5.1)
48
+ concurrent-ruby (~> 1.0)
49
+ dry-container (~> 0.3)
50
+ dry-core (~> 0.5, >= 0.5)
51
+ dry-inflector (~> 0.1, >= 0.1.2)
52
+ dry-logic (~> 1.0, >= 1.0.2)
53
+ dry-validation (1.6.0)
54
+ concurrent-ruby (~> 1.0)
55
+ dry-container (~> 0.7, >= 0.7.1)
56
+ dry-core (~> 0.4)
57
+ dry-equalizer (~> 0.2)
58
+ dry-initializer (~> 3.0)
59
+ dry-schema (~> 1.5, >= 1.5.2)
60
+ faraday (0.7.6)
61
+ addressable (~> 2.2)
62
+ multipart-post (~> 1.1)
63
+ rack (~> 1.1)
64
+ ffi (1.15.1)
65
+ ffi-compiler (1.0.1)
66
+ ffi (>= 1.0.0)
67
+ rake
68
+ hashdiff (1.0.1)
69
+ http (4.4.1)
70
+ addressable (~> 2.3)
71
+ http-cookie (~> 1.0)
72
+ http-form_data (~> 2.2)
73
+ http-parser (~> 1.2.0)
74
+ http-accept (1.7.0)
75
+ http-cookie (1.0.3)
76
+ domain_name (~> 0.5)
77
+ http-form_data (2.3.0)
78
+ http-parser (1.2.3)
79
+ ffi-compiler (>= 1.0, < 2.0)
80
+ mime-types (3.3.1)
81
+ mime-types-data (~> 3.2015)
82
+ mime-types-data (3.2021.0225)
83
+ multi_json (1.15.0)
84
+ multipart-post (1.2.0)
85
+ netrc (0.11.0)
86
+ public_suffix (4.0.6)
87
+ rack (1.6.13)
88
+ rake (12.3.3)
89
+ rest-client (2.1.0)
90
+ http-accept (>= 1.7.0, < 2.0)
91
+ http-cookie (>= 1.0.2, < 2.0)
92
+ mime-types (>= 1.16, < 4.0)
93
+ netrc (~> 0.8)
94
+ rexml (3.2.4)
95
+ rspec (3.10.0)
96
+ rspec-core (~> 3.10.0)
97
+ rspec-expectations (~> 3.10.0)
98
+ rspec-mocks (~> 3.10.0)
99
+ rspec-core (3.10.1)
100
+ rspec-support (~> 3.10.0)
101
+ rspec-expectations (3.10.1)
102
+ diff-lcs (>= 1.2.0, < 2.0)
103
+ rspec-support (~> 3.10.0)
104
+ rspec-mocks (3.10.2)
105
+ diff-lcs (>= 1.2.0, < 2.0)
106
+ rspec-support (~> 3.10.0)
107
+ rspec-support (3.10.2)
108
+ unf (0.1.4)
109
+ unf_ext
110
+ unf_ext (0.0.7.7)
111
+ vcr (6.0.0)
112
+ webmock (3.12.0)
113
+ addressable (>= 2.3.6)
114
+ crack (>= 0.3.2)
115
+ hashdiff (>= 0.4.0, < 2.0.0)
116
+ yard (0.9.26)
117
+
118
+ PLATFORMS
119
+ ruby
120
+
121
+ DEPENDENCIES
122
+ breakers
123
+ config
124
+ dotenv
125
+ faraday (~> 0.7.4)
126
+ http
127
+ rake (~> 12.0)
128
+ rest-client
129
+ rspec (~> 3.0)
130
+ simpleokta!
131
+ vcr
132
+ webmock
133
+ yard
134
+
135
+ BUNDLED WITH
136
+ 2.2.13
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Braden Shipley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Simpleokta
2
+
3
+ This gem provides easy access to multiple common Okta API calls. Please see the [documentation on rubydoc](https://www.rubydoc.info/github/bradenshipley/simpleokta/main) for more information on what methods are available.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'simpleokta'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install simpleokta
20
+
21
+ ## Usage
22
+
23
+ Pass in the `api_token` and `base_api_url` of your okta instance as a hash into the `Client` initializer.
24
+
25
+ ```ruby
26
+ config = {
27
+ :api_token => "API_TOKEN HERE",
28
+ :base_api_url => "URL HERE." #EX: 'https://dev-123456.okta.com'
29
+ }
30
+ @okta_util = Simpleokta::Client.new(config)
31
+ ```
32
+
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bradenshipley/simpleokta. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/bradenshipley/simpleokta/blob/master/CODE_OF_CONDUCT.md).
43
+
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
48
+
49
+ ## Code of Conduct
50
+
51
+ Everyone interacting in the Simpleokta project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/simpleokta/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'dotenv'
6
+ require 'dotenv/tasks'
7
+
8
+ RSpec::Core::RakeTask.new(:spec)
9
+ Dotenv.load('.env')
10
+
11
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'simpleokta'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/simpleokta.rb ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simpleokta/version'
4
+ require 'simpleokta/client'
5
+ require 'faraday'
6
+
7
+ # @author Braden Shipley
8
+ module Simpleokta
9
+ def self.new(*args)
10
+ Simpleokta::Client.new(*args)
11
+ end
12
+ end
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Simpleokta
4
+ class Client
5
+ module Apps
6
+ # APP METHODS
7
+
8
+ # Returns a list of all applications in the okta instance.
9
+ # @return [Array<Application Object>]
10
+ # @see https://developer.okta.com/docs/reference/api/apps/#application-object Application Object
11
+ def apps
12
+ response = call_with_token('get', Constants::APP_API_BASE_PATH)
13
+ JSON.parse(response.body)
14
+ end
15
+
16
+ # Return a specific application in the okta instance.
17
+ # @param app_id [String] the unique id of the application
18
+ # @return [Hash<Application Object>]
19
+ # @see https://developer.okta.com/docs/reference/api/apps/#application-object Application Object
20
+ def app(app_id)
21
+ response = call_with_token('get', "#{Constants::APP_API_BASE_PATH}/#{app_id}")
22
+ JSON.parse(response.body)
23
+ end
24
+
25
+ # Returns all users currently assigned to the application
26
+ # @param app_id [String] the unique id of the application
27
+ # @return [Array<User Object>]
28
+ # @see https://developer.okta.com/docs/reference/api/apps/#application-user-object User Object
29
+ def users_assigned_to_application(app_id)
30
+ response = call_with_token('get', "#{Constants::APP_API_BASE_PATH}/#{app_id}/users")
31
+ JSON.parse(response.body)
32
+ end
33
+
34
+ # Creates an application in Okta.
35
+ # @param app_data [Hash] The hash of data you want the application to contain.
36
+ # @see https://developer.okta.com/docs/reference/api/apps/#add-application Add application data.
37
+ # @example
38
+ # Creating a Basic Auth App
39
+ # app_data = {
40
+ # "name": "template_basic_auth",
41
+ # "label": "Sample Basic Auth App",
42
+ # "signOnMode": "BASIC_AUTH",
43
+ # "settings": {
44
+ # "app": {
45
+ # "url": "https://example.com/login.html",
46
+ # "authURL": "https://example.com/auth.html"
47
+ # }
48
+ # }
49
+ # }
50
+ # @return [Hash<Application Object>]
51
+ # @see https://developer.okta.com/docs/reference/api/apps/#application-object Application Object
52
+ def create_app(app_data)
53
+ response = call_with_token('post', Constants::APP_API_BASE_PATH, app_data)
54
+ JSON.parse(response.body)
55
+ end
56
+
57
+ # Update an application
58
+ # @param app_id [String] the unique id of the application
59
+ # @param app_data [Hash] The hash of data you want the application to contain.
60
+ # Pass in all required fields, anything you leave out will be removed from the application on update.
61
+ # @return [Hash<Application Object>] The updated app
62
+ # @see https://developer.okta.com/docs/reference/api/apps/#update-application Update Application
63
+ # @see https://developer.okta.com/docs/reference/api/apps/#application-object Application Object
64
+ def update_app(app_id, app_data)
65
+ response = call_with_token('put', "#{Constants::APP_API_BASE_PATH}/#{app_id}", app_data)
66
+ JSON.parse(response.body)
67
+ end
68
+
69
+ # Delete an application by id
70
+ # @param app_id [String] the unique id of the application
71
+ # @return 204 No Content
72
+ def delete_app(app_id)
73
+ response = call_with_token('delete', "#{Constants::APP_API_BASE_PATH}/#{app_id}")
74
+ response
75
+ end
76
+
77
+ # Activate an application by id
78
+ # @param app_id [String] the unique id of the application
79
+ # @see https://developer.okta.com/docs/reference/api/apps/#activate-application Activate Application
80
+ # @return {}
81
+ def activate_app(app_id)
82
+ response = call_with_token('post', "#{Constants::APP_API_BASE_PATH}/#{app_id}/lifecycle/activate")
83
+ "Application with id: #{app_id} activated"
84
+ end
85
+
86
+ # Deactivate an application by id
87
+ # @param app_id [String] the unique id of the application
88
+ # @see https://developer.okta.com/docs/reference/api/apps/#deactivate-application Deactivate Application
89
+ # @return {}
90
+ def deactivate_app(app_id)
91
+ response = call_with_token('post', "#{Constants::APP_API_BASE_PATH}/#{app_id}/lifecycle/deactivate")
92
+ "Application with id: #{app_id} deactivated"
93
+ end
94
+ end
95
+ end
96
+ end