onelogin 1.6.0 → 1.8.0
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 +5 -5
- data/.github/workflows/test.yml +25 -0
- data/.gitignore +1 -0
- data/README.md +47 -5
- data/examples/Gemfile.lock +15 -11
- data/examples/events-to-csv.rb +5 -4
- data/lib/onelogin/api/apiexception.rb +3 -0
- data/lib/onelogin/api/client.rb +68 -3
- data/lib/onelogin/api/cursor.rb +5 -2
- data/lib/onelogin/version.rb +1 -1
- data/onelogin.gemspec +3 -2
- metadata +24 -116
- data/.travis.yml +0 -6
- data/examples/rails-custom-login-page/.gitignore +0 -45
- data/examples/rails-custom-login-page/.ruby-version +0 -1
- data/examples/rails-custom-login-page/Gemfile +0 -57
- data/examples/rails-custom-login-page/Gemfile.lock +0 -212
- data/examples/rails-custom-login-page/README.md +0 -137
- data/examples/rails-custom-login-page/Rakefile +0 -6
- data/examples/rails-custom-login-page/app/assets/config/manifest.js +0 -3
- data/examples/rails-custom-login-page/app/assets/images/.keep +0 -0
- data/examples/rails-custom-login-page/app/assets/javascripts/application.js +0 -18
- data/examples/rails-custom-login-page/app/assets/javascripts/cable.js +0 -13
- data/examples/rails-custom-login-page/app/assets/javascripts/channels/.keep +0 -0
- data/examples/rails-custom-login-page/app/assets/javascripts/dashboard.coffee +0 -3
- data/examples/rails-custom-login-page/app/assets/javascripts/home.coffee +0 -3
- data/examples/rails-custom-login-page/app/assets/javascripts/sessions.coffee +0 -3
- data/examples/rails-custom-login-page/app/assets/stylesheets/application.css +0 -15
- data/examples/rails-custom-login-page/app/assets/stylesheets/dashboard.scss +0 -3
- data/examples/rails-custom-login-page/app/assets/stylesheets/home.scss +0 -3
- data/examples/rails-custom-login-page/app/assets/stylesheets/sessions.scss +0 -3
- data/examples/rails-custom-login-page/app/channels/application_cable/channel.rb +0 -4
- data/examples/rails-custom-login-page/app/channels/application_cable/connection.rb +0 -4
- data/examples/rails-custom-login-page/app/controllers/application_controller.rb +0 -23
- data/examples/rails-custom-login-page/app/controllers/concerns/.keep +0 -0
- data/examples/rails-custom-login-page/app/controllers/dashboard_controller.rb +0 -10
- data/examples/rails-custom-login-page/app/controllers/home_controller.rb +0 -5
- data/examples/rails-custom-login-page/app/controllers/sessions_controller.rb +0 -46
- data/examples/rails-custom-login-page/app/controllers/users_controller.rb +0 -120
- data/examples/rails-custom-login-page/app/helpers/application_helper.rb +0 -2
- data/examples/rails-custom-login-page/app/helpers/dashboard_helper.rb +0 -28
- data/examples/rails-custom-login-page/app/helpers/home_helper.rb +0 -2
- data/examples/rails-custom-login-page/app/helpers/sessions_helper.rb +0 -87
- data/examples/rails-custom-login-page/app/helpers/users_helper.rb +0 -3
- data/examples/rails-custom-login-page/app/jobs/application_job.rb +0 -2
- data/examples/rails-custom-login-page/app/mailers/application_mailer.rb +0 -4
- data/examples/rails-custom-login-page/app/models/application_record.rb +0 -3
- data/examples/rails-custom-login-page/app/models/concerns/.keep +0 -0
- data/examples/rails-custom-login-page/app/views/dashboard/index.html.erb +0 -43
- data/examples/rails-custom-login-page/app/views/home/index.html.erb +0 -272
- data/examples/rails-custom-login-page/app/views/layouts/application.html.erb +0 -31
- data/examples/rails-custom-login-page/app/views/layouts/mailer.html.erb +0 -13
- data/examples/rails-custom-login-page/app/views/layouts/mailer.text.erb +0 -1
- data/examples/rails-custom-login-page/app/views/users/_form.html.erb +0 -1
- data/examples/rails-custom-login-page/app/views/users/_user.json.jbuilder +0 -2
- data/examples/rails-custom-login-page/app/views/users/edit.html.erb +0 -33
- data/examples/rails-custom-login-page/app/views/users/index.html.erb +0 -33
- data/examples/rails-custom-login-page/app/views/users/index.json.jbuilder +0 -1
- data/examples/rails-custom-login-page/app/views/users/new.html.erb +0 -60
- data/examples/rails-custom-login-page/app/views/users/onboard.html.erb +0 -54
- data/examples/rails-custom-login-page/app/views/users/show.html.erb +0 -17
- data/examples/rails-custom-login-page/app/views/users/show.json.jbuilder +0 -1
- data/examples/rails-custom-login-page/bin/bundle +0 -3
- data/examples/rails-custom-login-page/bin/rails +0 -9
- data/examples/rails-custom-login-page/bin/rake +0 -9
- data/examples/rails-custom-login-page/bin/setup +0 -38
- data/examples/rails-custom-login-page/bin/spring +0 -17
- data/examples/rails-custom-login-page/bin/update +0 -29
- data/examples/rails-custom-login-page/bin/yarn +0 -11
- data/examples/rails-custom-login-page/config/application.rb +0 -18
- data/examples/rails-custom-login-page/config/boot.rb +0 -3
- data/examples/rails-custom-login-page/config/cable.yml +0 -10
- data/examples/rails-custom-login-page/config/database.yml +0 -25
- data/examples/rails-custom-login-page/config/environment.rb +0 -5
- data/examples/rails-custom-login-page/config/environments/development.rb +0 -54
- data/examples/rails-custom-login-page/config/environments/production.rb +0 -91
- data/examples/rails-custom-login-page/config/environments/test.rb +0 -42
- data/examples/rails-custom-login-page/config/initializers/application_controller_renderer.rb +0 -8
- data/examples/rails-custom-login-page/config/initializers/assets.rb +0 -14
- data/examples/rails-custom-login-page/config/initializers/backtrace_silencers.rb +0 -7
- data/examples/rails-custom-login-page/config/initializers/cookies_serializer.rb +0 -5
- data/examples/rails-custom-login-page/config/initializers/filter_parameter_logging.rb +0 -4
- data/examples/rails-custom-login-page/config/initializers/inflections.rb +0 -16
- data/examples/rails-custom-login-page/config/initializers/mime_types.rb +0 -4
- data/examples/rails-custom-login-page/config/initializers/onelogin.rb +0 -6
- data/examples/rails-custom-login-page/config/initializers/wrap_parameters.rb +0 -14
- data/examples/rails-custom-login-page/config/locales/en.yml +0 -33
- data/examples/rails-custom-login-page/config/puma.rb +0 -56
- data/examples/rails-custom-login-page/config/routes.rb +0 -23
- data/examples/rails-custom-login-page/config/secrets.yml.sample +0 -38
- data/examples/rails-custom-login-page/config/spring.rb +0 -6
- data/examples/rails-custom-login-page/config.ru +0 -5
- data/examples/rails-custom-login-page/db/seeds.rb +0 -7
- data/examples/rails-custom-login-page/lib/assets/.keep +0 -0
- data/examples/rails-custom-login-page/lib/tasks/.keep +0 -0
- data/examples/rails-custom-login-page/package.json +0 -5
- data/examples/rails-custom-login-page/public/404.html +0 -67
- data/examples/rails-custom-login-page/public/422.html +0 -67
- data/examples/rails-custom-login-page/public/500.html +0 -66
- data/examples/rails-custom-login-page/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/rails-custom-login-page/public/apple-touch-icon.png +0 -0
- data/examples/rails-custom-login-page/public/favicon.ico +0 -0
- data/examples/rails-custom-login-page/public/robots.txt +0 -1
- data/examples/rails-custom-login-page/test/application_system_test_case.rb +0 -5
- data/examples/rails-custom-login-page/test/controllers/.keep +0 -0
- data/examples/rails-custom-login-page/test/controllers/dashboard_controller_test.rb +0 -9
- data/examples/rails-custom-login-page/test/controllers/home_controller_test.rb +0 -9
- data/examples/rails-custom-login-page/test/controllers/sessions_controller_test.rb +0 -7
- data/examples/rails-custom-login-page/test/controllers/users_controller_test.rb +0 -48
- data/examples/rails-custom-login-page/test/fixtures/.keep +0 -0
- data/examples/rails-custom-login-page/test/fixtures/files/.keep +0 -0
- data/examples/rails-custom-login-page/test/helpers/.keep +0 -0
- data/examples/rails-custom-login-page/test/integration/.keep +0 -0
- data/examples/rails-custom-login-page/test/mailers/.keep +0 -0
- data/examples/rails-custom-login-page/test/models/.keep +0 -0
- data/examples/rails-custom-login-page/test/system/.keep +0 -0
- data/examples/rails-custom-login-page/test/test_helper.rb +0 -9
- data/examples/rails-custom-login-page/vendor/.keep +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 341fedcf1ef3faf8e076b127ad2b7379c48fe04957396d850d3468a01a27b369
|
|
4
|
+
data.tar.gz: ca91b881e24411ff62d8d91b37e6226d5f879c8f245eaced58c44d84194ff892
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6d0a9ac12d1bb6fc17434ff5503f0fe311ad9b48603f430244423c19c6b9e130e434e2892f4d3308dcfa4c1dc966a5557ba6537d7a733567dd5f42e3a6db8b49
|
|
7
|
+
data.tar.gz: c95b20d2915d751098950bc1bda5b0356bbc1d9bb4fad76f3c94bf4a8134705bbb3c745b1b4518e849cb0c1994ca2c3a0a3f7584c8eab051dd1344f4dee995c4
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
rspec:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
|
|
9
|
+
strategy:
|
|
10
|
+
fail-fast: false
|
|
11
|
+
matrix:
|
|
12
|
+
ruby: ['3.2', '3.3', '3.4']
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
|
19
|
+
uses: ruby/setup-ruby@v1
|
|
20
|
+
with:
|
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
|
22
|
+
bundler-cache: true
|
|
23
|
+
|
|
24
|
+
- name: Run specs
|
|
25
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
This SDK will let you execute all the API methods, version/1, described
|
|
4
4
|
at https://developers.onelogin.com/api-docs/1/getting-started/dev-overview.
|
|
5
5
|
|
|
6
|
-
The toolkit is hosted on
|
|
6
|
+
The toolkit is hosted on GitHub. You can download it from:
|
|
7
7
|
* Lastest release: https://github.com/onelogin/onelogin-ruby-sdk/releases/latest
|
|
8
|
-
*
|
|
8
|
+
* Main repo: https://github.com/onelogin/onelogin-ruby-sdk/tree/main
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Support
|
|
12
|
+
|
|
13
|
+
OneLogin by One Identity open source projects are supported through [OneLogin GitHub issues](https://github.com/onelogin/onelogin-ruby-sdk/issues). This includes all scripts, plugins, SDKs, modules, code snippets or other solutions. For assistance with any OneLogin by One Identity GitHub project, please raise a new Issue on the [OneLogin GitHub issues](https://github.com/onelogin/onelogin-ruby-sdk/issues) page. Requests for assistance made through official One Identity Support will be referred back to GitHub where those requests can benefit all users.
|
|
14
|
+
|
|
9
15
|
|
|
10
16
|
|
|
11
17
|
## Installation
|
|
@@ -27,7 +33,17 @@ Or install it yourself as:
|
|
|
27
33
|
|
|
28
34
|
### Dependencies
|
|
29
35
|
|
|
36
|
+
* Ruby >= 3.2
|
|
30
37
|
* httparty
|
|
38
|
+
* nokogiri
|
|
39
|
+
|
|
40
|
+
Ruby 3.2 is the lowest version on which `nokogiri` resolves to a release with
|
|
41
|
+
no known security advisories — below it, the newest installable `nokogiri` is
|
|
42
|
+
still affected by a critical one.
|
|
43
|
+
|
|
44
|
+
On an older Ruby, `bundle install` resolves to the most recent release that
|
|
45
|
+
still supports it rather than failing, so existing builds keep working. You
|
|
46
|
+
just stop receiving updates until you upgrade Ruby.
|
|
31
47
|
|
|
32
48
|
## Getting started
|
|
33
49
|
|
|
@@ -42,6 +58,7 @@ If you don't have an account you can [sign up for a free developer account here]
|
|
|
42
58
|
|region| Optional: `us` or `eu`. Defaults to `us` |
|
|
43
59
|
|max_results| Optional: Defaults to 1000 |
|
|
44
60
|
|timeout| Optional: Defaults to 60 (requires httparty > 0.16.2) |
|
|
61
|
+
|token_expiration_buffer| Optional: Non-negative number of seconds before token expiration to trigger a refresh. Set to `0` to disable. Defaults to 30 |
|
|
45
62
|
|
|
46
63
|
```ruby
|
|
47
64
|
require 'onelogin'
|
|
@@ -166,17 +183,42 @@ query_parameters = {
|
|
|
166
183
|
}
|
|
167
184
|
users_filtered2 = client.get_users(query_parameters)
|
|
168
185
|
|
|
169
|
-
# Get Users with
|
|
186
|
+
# Get Users with a page size of 3.
|
|
187
|
+
#
|
|
188
|
+
# `limit` is the API's page size, not a cap on the total. To stop after a
|
|
189
|
+
# fixed number of results use `take`, or set `max_results` on the client.
|
|
170
190
|
query_parameters = {
|
|
171
191
|
limit: 3
|
|
172
192
|
}
|
|
173
|
-
|
|
193
|
+
users_paged_by_three = client.get_users(query_parameters)
|
|
194
|
+
|
|
195
|
+
# Stop after 3 users regardless of page size
|
|
196
|
+
first_three = client.get_users.take(3)
|
|
174
197
|
|
|
175
198
|
# Only return the firstname and email fields for each user
|
|
176
199
|
client.get_users(fields: 'email,firstname').each do |user|
|
|
177
200
|
puts "#{user.firstname} - #{user.email}"
|
|
178
201
|
end
|
|
179
202
|
|
|
203
|
+
# Sort server-side with the sort parameter. Prefix with - to reverse.
|
|
204
|
+
# Sorting happens in the API, so you do not need to fetch every user and
|
|
205
|
+
# sort client-side.
|
|
206
|
+
query_parameters = {
|
|
207
|
+
sort: '+id'
|
|
208
|
+
}
|
|
209
|
+
users_sorted = client.get_users(query_parameters)
|
|
210
|
+
|
|
211
|
+
# Ten least recently active users.
|
|
212
|
+
#
|
|
213
|
+
# `sort` is applied by the API. `limit` sets the page size so the request
|
|
214
|
+
# itself only fetches ten rows, and `take` stops the cursor after ten so it
|
|
215
|
+
# does not page any further.
|
|
216
|
+
#
|
|
217
|
+
# Use both: `limit` alone does not cap the total, because the cursor keeps
|
|
218
|
+
# following pages until they run out or `max_results` is reached, and `take`
|
|
219
|
+
# alone still transfers a full default-sized page and discards the extra.
|
|
220
|
+
least_recently_active = client.get_users(sort: '+last_login', limit: 10).take(10)
|
|
221
|
+
|
|
180
222
|
# Get User by id
|
|
181
223
|
user = client.get_user(users_filtered.first.id)
|
|
182
224
|
user_mfa = client.get_user(users_filtered2.first.id)
|
|
@@ -514,4 +556,4 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
|
514
556
|
|
|
515
557
|
## Code of Conduct
|
|
516
558
|
|
|
517
|
-
Everyone interacting in the OneLogin Ruby Sdk project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/onelogin/onelogin-ruby-sdk/blob/
|
|
559
|
+
Everyone interacting in the OneLogin Ruby Sdk project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/onelogin/onelogin-ruby-sdk/blob/main/CODE_OF_CONDUCT.md).
|
data/examples/Gemfile.lock
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
GEM
|
|
2
2
|
remote: https://rubygems.org/
|
|
3
3
|
specs:
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
bigdecimal (4.1.2)
|
|
5
|
+
csv (3.3.6)
|
|
6
|
+
httparty (0.24.2)
|
|
7
|
+
csv
|
|
8
|
+
mini_mime (>= 1.0.0)
|
|
6
9
|
multi_xml (>= 0.5.2)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
onelogin (1.
|
|
10
|
+
mini_mime (1.1.5)
|
|
11
|
+
mini_portile2 (2.8.9)
|
|
12
|
+
multi_xml (0.9.1)
|
|
13
|
+
bigdecimal (>= 3.1, < 5)
|
|
14
|
+
nokogiri (1.19.4)
|
|
15
|
+
mini_portile2 (~> 2.8.2)
|
|
16
|
+
racc (~> 1.4)
|
|
17
|
+
onelogin (1.7.0)
|
|
15
18
|
httparty (>= 0.13.7)
|
|
16
19
|
nokogiri (>= 1.6.3.1)
|
|
20
|
+
racc (1.8.1)
|
|
17
21
|
|
|
18
22
|
PLATFORMS
|
|
19
23
|
ruby
|
|
@@ -22,4 +26,4 @@ DEPENDENCIES
|
|
|
22
26
|
onelogin
|
|
23
27
|
|
|
24
28
|
BUNDLED WITH
|
|
25
|
-
2.
|
|
29
|
+
2.6.9
|
data/examples/events-to-csv.rb
CHANGED
|
@@ -52,11 +52,15 @@ OptionParser.new do |opts|
|
|
|
52
52
|
end
|
|
53
53
|
end.parse!
|
|
54
54
|
|
|
55
|
+
counter = 0
|
|
56
|
+
limit = options[:limit] || 1000
|
|
57
|
+
|
|
55
58
|
# Fetch the events
|
|
56
59
|
client = OneLogin::Api::Client.new(
|
|
57
60
|
client_id: 'ONELOGIN_CLIENT_ID_GOES_HERE',
|
|
58
61
|
client_secret: 'ONELOGIN_CLIENT_SECRET_GOES_HERE',
|
|
59
|
-
region: 'us'
|
|
62
|
+
region: 'us',
|
|
63
|
+
max_results: limit
|
|
60
64
|
)
|
|
61
65
|
|
|
62
66
|
attribute_names = ['id', 'created_at', 'account_id', 'user_id', 'user_name', 'event_type_id',
|
|
@@ -66,9 +70,6 @@ attribute_names = ['id', 'created_at', 'account_id', 'user_id', 'user_name', 'ev
|
|
|
66
70
|
'operation_name', 'directory_sync_run_id', 'directory_id', 'resolution', 'client_id',
|
|
67
71
|
'resource_type_id', 'error_description', 'risk_score', 'risk_reasons', 'risk_cookie_id', 'browser_fingerprint']
|
|
68
72
|
|
|
69
|
-
counter = 0
|
|
70
|
-
limit = options[:limit] || 1000
|
|
71
|
-
|
|
72
73
|
# We remove limit from options parsed to the api as we want to fetch
|
|
73
74
|
# the max number of records possible and then use the cursor that is
|
|
74
75
|
# built into the ruby sdk to limit the results
|
data/lib/onelogin/api/client.rb
CHANGED
|
@@ -26,6 +26,7 @@ module OneLogin
|
|
|
26
26
|
Nokogiri::XML::ParseOptions::NONET
|
|
27
27
|
|
|
28
28
|
DEFAULT_USER_AGENT = "onelogin-ruby-sdk v#{OneLogin::VERSION}".freeze
|
|
29
|
+
DEFAULT_TOKEN_EXPIRATION_BUFFER = 30 # seconds
|
|
29
30
|
|
|
30
31
|
# Create a new instance of the Client.
|
|
31
32
|
#
|
|
@@ -38,6 +39,7 @@ module OneLogin
|
|
|
38
39
|
@client_secret = options[:client_secret]
|
|
39
40
|
@region = options[:region] || 'us'
|
|
40
41
|
@max_results = options[:max_results] || 1000
|
|
42
|
+
@token_expiration_buffer = normalize_expiration_buffer(options[:token_expiration_buffer])
|
|
41
43
|
|
|
42
44
|
if options[:timeout] and defined? self.class.default_timeout
|
|
43
45
|
self.class.default_timeout options[:timeout]
|
|
@@ -58,6 +60,51 @@ module OneLogin
|
|
|
58
60
|
raise ArgumentError, 'client_id & client_secret are required' unless @client_id && @client_secret
|
|
59
61
|
end
|
|
60
62
|
|
|
63
|
+
# Normalize caller-supplied parameter hashes to string keys.
|
|
64
|
+
#
|
|
65
|
+
# The README and examples use symbol keys, but the required-parameter
|
|
66
|
+
# checks below look them up as strings. `to_json` already serializes both
|
|
67
|
+
# forms identically, so only the validation ever disagreed.
|
|
68
|
+
#
|
|
69
|
+
# Anything that isn't a Hash becomes an empty one so the required-parameter
|
|
70
|
+
# guards still fire and report the missing attribute, rather than blowing
|
|
71
|
+
# up on has_key? and surfacing as a generic 500.
|
|
72
|
+
#
|
|
73
|
+
# An already-string-keyed hash is returned untouched, so existing callers
|
|
74
|
+
# keep the exact object they passed - including Hash subclasses with their
|
|
75
|
+
# own to_json.
|
|
76
|
+
#
|
|
77
|
+
def stringify_param_keys(params)
|
|
78
|
+
return {} unless params.is_a?(Hash)
|
|
79
|
+
return params if params.keys.all? { |key| key.is_a?(String) }
|
|
80
|
+
|
|
81
|
+
params.each_with_object({}) { |(key, value), out| out[key.to_s] = value }
|
|
82
|
+
end
|
|
83
|
+
private :stringify_param_keys
|
|
84
|
+
|
|
85
|
+
# Coerce the configured refresh buffer into a non-negative Integer.
|
|
86
|
+
#
|
|
87
|
+
# ENV-backed configs hand this over as a String, and a negative buffer
|
|
88
|
+
# would move the refresh point past the token's real expiry - which is the
|
|
89
|
+
# 401 this buffer exists to prevent - so reject both loudly.
|
|
90
|
+
#
|
|
91
|
+
def normalize_expiration_buffer(value)
|
|
92
|
+
return DEFAULT_TOKEN_EXPIRATION_BUFFER if value.nil?
|
|
93
|
+
|
|
94
|
+
buffer = begin
|
|
95
|
+
Integer(value)
|
|
96
|
+
rescue ArgumentError, TypeError
|
|
97
|
+
nil
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
if buffer.nil? || buffer < 0
|
|
101
|
+
raise ArgumentError, "token_expiration_buffer must be a non-negative integer, got #{value.inspect}"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
buffer
|
|
105
|
+
end
|
|
106
|
+
private :normalize_expiration_buffer
|
|
107
|
+
|
|
61
108
|
# Clean any previous error registered at the client.
|
|
62
109
|
#
|
|
63
110
|
def clean_error
|
|
@@ -66,15 +113,26 @@ module OneLogin
|
|
|
66
113
|
@error_attribute = nil
|
|
67
114
|
end
|
|
68
115
|
|
|
116
|
+
# Whether the current access token should be considered expired.
|
|
117
|
+
#
|
|
118
|
+
# Treats the token as expired `token_expiration_buffer` seconds early so a
|
|
119
|
+
# token that would lapse while a request is in flight is refreshed first.
|
|
120
|
+
#
|
|
121
|
+
# @return [Boolean] true when there is no expiration recorded or the token
|
|
122
|
+
# is inside the refresh buffer.
|
|
123
|
+
#
|
|
69
124
|
def expired?
|
|
70
|
-
|
|
125
|
+
return true if @expiration.nil?
|
|
126
|
+
Time.now.utc > (@expiration - @token_expiration_buffer)
|
|
71
127
|
end
|
|
72
128
|
|
|
73
129
|
def prepare_token
|
|
74
130
|
if @access_token.nil?
|
|
75
131
|
access_token
|
|
76
132
|
elsif expired?
|
|
77
|
-
|
|
133
|
+
# Fall back to a brand new token if the refresh grant fails, otherwise
|
|
134
|
+
# the stale token is reused and the request comes back 401.
|
|
135
|
+
regenerate_token || access_token
|
|
78
136
|
end
|
|
79
137
|
end
|
|
80
138
|
|
|
@@ -1105,6 +1163,8 @@ module OneLogin
|
|
|
1105
1163
|
begin
|
|
1106
1164
|
url = url_for(SESSION_LOGIN_TOKEN_URL)
|
|
1107
1165
|
|
|
1166
|
+
query_params = stringify_param_keys(query_params)
|
|
1167
|
+
|
|
1108
1168
|
if query_params.nil? || !query_params.has_key?('username_or_email') || !query_params.has_key?('password') || !query_params.has_key?('subdomain')
|
|
1109
1169
|
raise "username_or_email, password and subdomain are required parameters"
|
|
1110
1170
|
end
|
|
@@ -1330,7 +1390,12 @@ module OneLogin
|
|
|
1330
1390
|
begin
|
|
1331
1391
|
url = url_for(CREATE_APP_URL)
|
|
1332
1392
|
|
|
1333
|
-
|
|
1393
|
+
app_params = stringify_param_keys(app_params)
|
|
1394
|
+
|
|
1395
|
+
# Was `unless has_key? || value.empty?`, which is true in every case,
|
|
1396
|
+
# so the check never fired and an app could be created with no
|
|
1397
|
+
# connector_id at all.
|
|
1398
|
+
if !app_params.has_key?('connector_id') || app_params['connector_id'].to_s.empty?
|
|
1334
1399
|
@error = '400'
|
|
1335
1400
|
@error_description = "connector_id is required"
|
|
1336
1401
|
@error_attribute = "connector_id"
|
data/lib/onelogin/api/cursor.rb
CHANGED
|
@@ -64,8 +64,11 @@ class Cursor
|
|
|
64
64
|
|
|
65
65
|
json = response.parsed_response
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
# HTTParty picks its parser from Content-Type, so a gateway or proxy error
|
|
68
|
+
# page comes back as a String and every has_key? below would blow up with a
|
|
69
|
+
# NoMethodError instead of a usable ApiException.
|
|
70
|
+
if json.nil? || !json.is_a?(Hash)
|
|
71
|
+
raise OneLogin::Api::ApiException.new("Response could not be parsed", response.code)
|
|
69
72
|
elsif !json.has_key?(@container) && json.has_key?('status') && json["status"]["error"] == true
|
|
70
73
|
raise OneLogin::Api::ApiException.new(extract_error_message_from_response(response), json["status"]["code"])
|
|
71
74
|
elsif !json.has_key?(@container) && json.has_key?('statusCode')
|
data/lib/onelogin/version.rb
CHANGED
data/onelogin.gemspec
CHANGED
|
@@ -34,12 +34,13 @@ Gem::Specification.new do |spec|
|
|
|
34
34
|
spec.bindir = "exe"
|
|
35
35
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
36
36
|
spec.require_paths = ["lib"]
|
|
37
|
-
spec.required_ruby_version = '>=
|
|
37
|
+
spec.required_ruby_version = '>= 3.2'
|
|
38
38
|
|
|
39
39
|
spec.add_runtime_dependency('httparty', '>=0.13.7')
|
|
40
40
|
spec.add_runtime_dependency('nokogiri', '>=1.6.3.1')
|
|
41
41
|
|
|
42
42
|
spec.add_development_dependency "bundler"
|
|
43
|
-
spec.add_development_dependency "rake", "~>
|
|
43
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
44
44
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
45
|
+
spec.add_development_dependency "webmock", "~> 3.0"
|
|
45
46
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: onelogin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- OneLogin
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-08-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: httparty
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
61
|
+
version: '13.0'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
68
|
+
version: '13.0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rspec
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -80,6 +80,20 @@ dependencies:
|
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '3.0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: webmock
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '3.0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '3.0'
|
|
83
97
|
description: OneLogin's Ruby SDK. Use this API client to interact with OneLogin's
|
|
84
98
|
platform
|
|
85
99
|
email:
|
|
@@ -91,8 +105,8 @@ extra_rdoc_files:
|
|
|
91
105
|
- README.md
|
|
92
106
|
files:
|
|
93
107
|
- ".github/workflows/git-secrets-public.yml"
|
|
108
|
+
- ".github/workflows/test.yml"
|
|
94
109
|
- ".gitignore"
|
|
95
|
-
- ".travis.yml"
|
|
96
110
|
- CODE_OF_CONDUCT.md
|
|
97
111
|
- Gemfile
|
|
98
112
|
- LICENSE
|
|
@@ -110,111 +124,6 @@ files:
|
|
|
110
124
|
- examples/get-all-login-events-of-last-day-to-csv.rb
|
|
111
125
|
- examples/last-app-user-login-to-csv.rb
|
|
112
126
|
- examples/list-users.rb
|
|
113
|
-
- examples/rails-custom-login-page/.gitignore
|
|
114
|
-
- examples/rails-custom-login-page/.ruby-version
|
|
115
|
-
- examples/rails-custom-login-page/Gemfile
|
|
116
|
-
- examples/rails-custom-login-page/Gemfile.lock
|
|
117
|
-
- examples/rails-custom-login-page/README.md
|
|
118
|
-
- examples/rails-custom-login-page/Rakefile
|
|
119
|
-
- examples/rails-custom-login-page/app/assets/config/manifest.js
|
|
120
|
-
- examples/rails-custom-login-page/app/assets/images/.keep
|
|
121
|
-
- examples/rails-custom-login-page/app/assets/javascripts/application.js
|
|
122
|
-
- examples/rails-custom-login-page/app/assets/javascripts/cable.js
|
|
123
|
-
- examples/rails-custom-login-page/app/assets/javascripts/channels/.keep
|
|
124
|
-
- examples/rails-custom-login-page/app/assets/javascripts/dashboard.coffee
|
|
125
|
-
- examples/rails-custom-login-page/app/assets/javascripts/home.coffee
|
|
126
|
-
- examples/rails-custom-login-page/app/assets/javascripts/sessions.coffee
|
|
127
|
-
- examples/rails-custom-login-page/app/assets/stylesheets/application.css
|
|
128
|
-
- examples/rails-custom-login-page/app/assets/stylesheets/dashboard.scss
|
|
129
|
-
- examples/rails-custom-login-page/app/assets/stylesheets/home.scss
|
|
130
|
-
- examples/rails-custom-login-page/app/assets/stylesheets/sessions.scss
|
|
131
|
-
- examples/rails-custom-login-page/app/channels/application_cable/channel.rb
|
|
132
|
-
- examples/rails-custom-login-page/app/channels/application_cable/connection.rb
|
|
133
|
-
- examples/rails-custom-login-page/app/controllers/application_controller.rb
|
|
134
|
-
- examples/rails-custom-login-page/app/controllers/concerns/.keep
|
|
135
|
-
- examples/rails-custom-login-page/app/controllers/dashboard_controller.rb
|
|
136
|
-
- examples/rails-custom-login-page/app/controllers/home_controller.rb
|
|
137
|
-
- examples/rails-custom-login-page/app/controllers/sessions_controller.rb
|
|
138
|
-
- examples/rails-custom-login-page/app/controllers/users_controller.rb
|
|
139
|
-
- examples/rails-custom-login-page/app/helpers/application_helper.rb
|
|
140
|
-
- examples/rails-custom-login-page/app/helpers/dashboard_helper.rb
|
|
141
|
-
- examples/rails-custom-login-page/app/helpers/home_helper.rb
|
|
142
|
-
- examples/rails-custom-login-page/app/helpers/sessions_helper.rb
|
|
143
|
-
- examples/rails-custom-login-page/app/helpers/users_helper.rb
|
|
144
|
-
- examples/rails-custom-login-page/app/jobs/application_job.rb
|
|
145
|
-
- examples/rails-custom-login-page/app/mailers/application_mailer.rb
|
|
146
|
-
- examples/rails-custom-login-page/app/models/application_record.rb
|
|
147
|
-
- examples/rails-custom-login-page/app/models/concerns/.keep
|
|
148
|
-
- examples/rails-custom-login-page/app/views/dashboard/index.html.erb
|
|
149
|
-
- examples/rails-custom-login-page/app/views/home/index.html.erb
|
|
150
|
-
- examples/rails-custom-login-page/app/views/layouts/application.html.erb
|
|
151
|
-
- examples/rails-custom-login-page/app/views/layouts/mailer.html.erb
|
|
152
|
-
- examples/rails-custom-login-page/app/views/layouts/mailer.text.erb
|
|
153
|
-
- examples/rails-custom-login-page/app/views/users/_form.html.erb
|
|
154
|
-
- examples/rails-custom-login-page/app/views/users/_user.json.jbuilder
|
|
155
|
-
- examples/rails-custom-login-page/app/views/users/edit.html.erb
|
|
156
|
-
- examples/rails-custom-login-page/app/views/users/index.html.erb
|
|
157
|
-
- examples/rails-custom-login-page/app/views/users/index.json.jbuilder
|
|
158
|
-
- examples/rails-custom-login-page/app/views/users/new.html.erb
|
|
159
|
-
- examples/rails-custom-login-page/app/views/users/onboard.html.erb
|
|
160
|
-
- examples/rails-custom-login-page/app/views/users/show.html.erb
|
|
161
|
-
- examples/rails-custom-login-page/app/views/users/show.json.jbuilder
|
|
162
|
-
- examples/rails-custom-login-page/bin/bundle
|
|
163
|
-
- examples/rails-custom-login-page/bin/rails
|
|
164
|
-
- examples/rails-custom-login-page/bin/rake
|
|
165
|
-
- examples/rails-custom-login-page/bin/setup
|
|
166
|
-
- examples/rails-custom-login-page/bin/spring
|
|
167
|
-
- examples/rails-custom-login-page/bin/update
|
|
168
|
-
- examples/rails-custom-login-page/bin/yarn
|
|
169
|
-
- examples/rails-custom-login-page/config.ru
|
|
170
|
-
- examples/rails-custom-login-page/config/application.rb
|
|
171
|
-
- examples/rails-custom-login-page/config/boot.rb
|
|
172
|
-
- examples/rails-custom-login-page/config/cable.yml
|
|
173
|
-
- examples/rails-custom-login-page/config/database.yml
|
|
174
|
-
- examples/rails-custom-login-page/config/environment.rb
|
|
175
|
-
- examples/rails-custom-login-page/config/environments/development.rb
|
|
176
|
-
- examples/rails-custom-login-page/config/environments/production.rb
|
|
177
|
-
- examples/rails-custom-login-page/config/environments/test.rb
|
|
178
|
-
- examples/rails-custom-login-page/config/initializers/application_controller_renderer.rb
|
|
179
|
-
- examples/rails-custom-login-page/config/initializers/assets.rb
|
|
180
|
-
- examples/rails-custom-login-page/config/initializers/backtrace_silencers.rb
|
|
181
|
-
- examples/rails-custom-login-page/config/initializers/cookies_serializer.rb
|
|
182
|
-
- examples/rails-custom-login-page/config/initializers/filter_parameter_logging.rb
|
|
183
|
-
- examples/rails-custom-login-page/config/initializers/inflections.rb
|
|
184
|
-
- examples/rails-custom-login-page/config/initializers/mime_types.rb
|
|
185
|
-
- examples/rails-custom-login-page/config/initializers/onelogin.rb
|
|
186
|
-
- examples/rails-custom-login-page/config/initializers/wrap_parameters.rb
|
|
187
|
-
- examples/rails-custom-login-page/config/locales/en.yml
|
|
188
|
-
- examples/rails-custom-login-page/config/puma.rb
|
|
189
|
-
- examples/rails-custom-login-page/config/routes.rb
|
|
190
|
-
- examples/rails-custom-login-page/config/secrets.yml.sample
|
|
191
|
-
- examples/rails-custom-login-page/config/spring.rb
|
|
192
|
-
- examples/rails-custom-login-page/db/seeds.rb
|
|
193
|
-
- examples/rails-custom-login-page/lib/assets/.keep
|
|
194
|
-
- examples/rails-custom-login-page/lib/tasks/.keep
|
|
195
|
-
- examples/rails-custom-login-page/package.json
|
|
196
|
-
- examples/rails-custom-login-page/public/404.html
|
|
197
|
-
- examples/rails-custom-login-page/public/422.html
|
|
198
|
-
- examples/rails-custom-login-page/public/500.html
|
|
199
|
-
- examples/rails-custom-login-page/public/apple-touch-icon-precomposed.png
|
|
200
|
-
- examples/rails-custom-login-page/public/apple-touch-icon.png
|
|
201
|
-
- examples/rails-custom-login-page/public/favicon.ico
|
|
202
|
-
- examples/rails-custom-login-page/public/robots.txt
|
|
203
|
-
- examples/rails-custom-login-page/test/application_system_test_case.rb
|
|
204
|
-
- examples/rails-custom-login-page/test/controllers/.keep
|
|
205
|
-
- examples/rails-custom-login-page/test/controllers/dashboard_controller_test.rb
|
|
206
|
-
- examples/rails-custom-login-page/test/controllers/home_controller_test.rb
|
|
207
|
-
- examples/rails-custom-login-page/test/controllers/sessions_controller_test.rb
|
|
208
|
-
- examples/rails-custom-login-page/test/controllers/users_controller_test.rb
|
|
209
|
-
- examples/rails-custom-login-page/test/fixtures/.keep
|
|
210
|
-
- examples/rails-custom-login-page/test/fixtures/files/.keep
|
|
211
|
-
- examples/rails-custom-login-page/test/helpers/.keep
|
|
212
|
-
- examples/rails-custom-login-page/test/integration/.keep
|
|
213
|
-
- examples/rails-custom-login-page/test/mailers/.keep
|
|
214
|
-
- examples/rails-custom-login-page/test/models/.keep
|
|
215
|
-
- examples/rails-custom-login-page/test/system/.keep
|
|
216
|
-
- examples/rails-custom-login-page/test/test_helper.rb
|
|
217
|
-
- examples/rails-custom-login-page/vendor/.keep
|
|
218
127
|
- lib/onelogin.rb
|
|
219
128
|
- lib/onelogin/api.rb
|
|
220
129
|
- lib/onelogin/api/apiexception.rb
|
|
@@ -258,7 +167,7 @@ licenses:
|
|
|
258
167
|
- MIT
|
|
259
168
|
metadata:
|
|
260
169
|
allowed_push_host: https://rubygems.org
|
|
261
|
-
post_install_message:
|
|
170
|
+
post_install_message:
|
|
262
171
|
rdoc_options: []
|
|
263
172
|
require_paths:
|
|
264
173
|
- lib
|
|
@@ -266,16 +175,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
266
175
|
requirements:
|
|
267
176
|
- - ">="
|
|
268
177
|
- !ruby/object:Gem::Version
|
|
269
|
-
version:
|
|
178
|
+
version: '3.2'
|
|
270
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
180
|
requirements:
|
|
272
181
|
- - ">="
|
|
273
182
|
- !ruby/object:Gem::Version
|
|
274
183
|
version: '0'
|
|
275
184
|
requirements: []
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
signing_key:
|
|
185
|
+
rubygems_version: 3.2.33
|
|
186
|
+
signing_key:
|
|
279
187
|
specification_version: 4
|
|
280
188
|
summary: OneLogin's Ruby SDK.
|
|
281
189
|
test_files: []
|
data/.travis.yml
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
*.rbc
|
|
2
|
-
capybara-*.html
|
|
3
|
-
.rspec
|
|
4
|
-
/log
|
|
5
|
-
/tmp
|
|
6
|
-
/db/*.sqlite3
|
|
7
|
-
/db/*.sqlite3-journal
|
|
8
|
-
/public/system
|
|
9
|
-
/coverage/
|
|
10
|
-
/spec/tmp
|
|
11
|
-
*.orig
|
|
12
|
-
rerun.txt
|
|
13
|
-
pickle-email-*.html
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# TODO Comment out this rule if you are OK with secrets being uploaded to the repo
|
|
17
|
-
config/initializers/secret_token.rb
|
|
18
|
-
|
|
19
|
-
# Only include if you have production secrets in this file, which is no longer a Rails default
|
|
20
|
-
config/secrets.yml
|
|
21
|
-
|
|
22
|
-
# dotenv
|
|
23
|
-
# TODO Comment out this rule if environment variables can be committed
|
|
24
|
-
.env
|
|
25
|
-
|
|
26
|
-
## Environment normalization:
|
|
27
|
-
/.bundle
|
|
28
|
-
/vendor/bundle
|
|
29
|
-
|
|
30
|
-
# these should all be checked in to normalize the environment:
|
|
31
|
-
Gemfile.lock, .ruby-version, .ruby-gemset
|
|
32
|
-
|
|
33
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
34
|
-
.rvmrc
|
|
35
|
-
|
|
36
|
-
# if using bower-rails ignore default bower_components path bower.json files
|
|
37
|
-
/vendor/assets/bower_components
|
|
38
|
-
*.bowerrc
|
|
39
|
-
bower.json
|
|
40
|
-
|
|
41
|
-
# Ignore pow environment settings
|
|
42
|
-
.powenv
|
|
43
|
-
|
|
44
|
-
# Ignore Byebug command history file.
|
|
45
|
-
.byebug_history
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2.2.5
|