onelogin 1.6.0 → 1.7.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 +1 -0
- data/lib/onelogin/api/client.rb +38 -2
- data/lib/onelogin/version.rb +1 -1
- data/onelogin.gemspec +1 -0
- metadata +21 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: db38cae3acb3c8a5810159344a5e088b9e2b52467831e865b625462b470d6340
|
|
4
|
+
data.tar.gz: b40ec7f43940358e3e2014a1075074778afd6d1d4263b3fa1ea2a6b78853e55e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d0e8f95dc8d30b514d1a0427b64364a2389a548057d643bda94a2a58cf6c44dc3bf33240b7d1d660ad5ff8c09595b4e4e1e7f7ad6382a5aa54fd044209219cda
|
|
7
|
+
data.tar.gz: bafb58f70a588457fc592dd397c54069a87245df8d332d56369c36bb6842d3a1fb4e5cfa9250e0b346dc335f288f99a0e6a4fdc3f9fa0960413349155c8647c7
|
|
@@ -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.0', '3.1', '3.2', '3.3']
|
|
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
|
@@ -42,6 +42,7 @@ If you don't have an account you can [sign up for a free developer account here]
|
|
|
42
42
|
|region| Optional: `us` or `eu`. Defaults to `us` |
|
|
43
43
|
|max_results| Optional: Defaults to 1000 |
|
|
44
44
|
|timeout| Optional: Defaults to 60 (requires httparty > 0.16.2) |
|
|
45
|
+
|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
46
|
|
|
46
47
|
```ruby
|
|
47
48
|
require 'onelogin'
|
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,29 @@ module OneLogin
|
|
|
58
60
|
raise ArgumentError, 'client_id & client_secret are required' unless @client_id && @client_secret
|
|
59
61
|
end
|
|
60
62
|
|
|
63
|
+
# Coerce the configured refresh buffer into a non-negative Integer.
|
|
64
|
+
#
|
|
65
|
+
# ENV-backed configs hand this over as a String, and a negative buffer
|
|
66
|
+
# would move the refresh point past the token's real expiry - which is the
|
|
67
|
+
# 401 this buffer exists to prevent - so reject both loudly.
|
|
68
|
+
#
|
|
69
|
+
def normalize_expiration_buffer(value)
|
|
70
|
+
return DEFAULT_TOKEN_EXPIRATION_BUFFER if value.nil?
|
|
71
|
+
|
|
72
|
+
buffer = begin
|
|
73
|
+
Integer(value)
|
|
74
|
+
rescue ArgumentError, TypeError
|
|
75
|
+
nil
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
if buffer.nil? || buffer < 0
|
|
79
|
+
raise ArgumentError, "token_expiration_buffer must be a non-negative integer, got #{value.inspect}"
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
buffer
|
|
83
|
+
end
|
|
84
|
+
private :normalize_expiration_buffer
|
|
85
|
+
|
|
61
86
|
# Clean any previous error registered at the client.
|
|
62
87
|
#
|
|
63
88
|
def clean_error
|
|
@@ -66,15 +91,26 @@ module OneLogin
|
|
|
66
91
|
@error_attribute = nil
|
|
67
92
|
end
|
|
68
93
|
|
|
94
|
+
# Whether the current access token should be considered expired.
|
|
95
|
+
#
|
|
96
|
+
# Treats the token as expired `token_expiration_buffer` seconds early so a
|
|
97
|
+
# token that would lapse while a request is in flight is refreshed first.
|
|
98
|
+
#
|
|
99
|
+
# @return [Boolean] true when there is no expiration recorded or the token
|
|
100
|
+
# is inside the refresh buffer.
|
|
101
|
+
#
|
|
69
102
|
def expired?
|
|
70
|
-
|
|
103
|
+
return true if @expiration.nil?
|
|
104
|
+
Time.now.utc > (@expiration - @token_expiration_buffer)
|
|
71
105
|
end
|
|
72
106
|
|
|
73
107
|
def prepare_token
|
|
74
108
|
if @access_token.nil?
|
|
75
109
|
access_token
|
|
76
110
|
elsif expired?
|
|
77
|
-
|
|
111
|
+
# Fall back to a brand new token if the refresh grant fails, otherwise
|
|
112
|
+
# the stale token is reused and the request comes back 401.
|
|
113
|
+
regenerate_token || access_token
|
|
78
114
|
end
|
|
79
115
|
end
|
|
80
116
|
|
data/lib/onelogin/version.rb
CHANGED
data/onelogin.gemspec
CHANGED
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.7.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
|
|
@@ -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,6 +105,7 @@ 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
110
|
- ".travis.yml"
|
|
96
111
|
- CODE_OF_CONDUCT.md
|
|
@@ -258,7 +273,7 @@ licenses:
|
|
|
258
273
|
- MIT
|
|
259
274
|
metadata:
|
|
260
275
|
allowed_push_host: https://rubygems.org
|
|
261
|
-
post_install_message:
|
|
276
|
+
post_install_message:
|
|
262
277
|
rdoc_options: []
|
|
263
278
|
require_paths:
|
|
264
279
|
- lib
|
|
@@ -273,9 +288,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
273
288
|
- !ruby/object:Gem::Version
|
|
274
289
|
version: '0'
|
|
275
290
|
requirements: []
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
signing_key:
|
|
291
|
+
rubygems_version: 3.2.33
|
|
292
|
+
signing_key:
|
|
279
293
|
specification_version: 4
|
|
280
294
|
summary: OneLogin's Ruby SDK.
|
|
281
295
|
test_files: []
|