oauth2 2.0.5 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +4 -2
- data/lib/oauth2/access_token.rb +21 -12
- data/lib/oauth2/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ca4e3435d4b69bcdf5607cf41d9b5f67b3671160d860cda0e8a66fdc6ca9ea7
|
4
|
+
data.tar.gz: 74170cea4731366ce12134db250ca23b937791a349b3cb62c6833a729d8964fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '02886a1ab24fe6cc0f2a0624646fd07b74f1151540e4a79c2a7b50b4fa9d051bdc801d22413ee1c815e0df95f8c20185e98a8edce6e8909b276d0f3be3d3e5e3'
|
7
|
+
data.tar.gz: c23909dd4d2502a9ecd0e7ea8832d9611542af282230bd7c7b126bf76394a80acd14e8cf73be0362ea90875c63192cac4102878cfafab5cfc0419adfeb236a7d
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format (since v2) is based on [Keep a Changelog v1](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning v2](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [2.0.6] - 2022-07-13
|
8
|
+
### Fixed
|
9
|
+
- [#624](https://github.com/oauth-xx/oauth2/pull/624) - Fixes a [regression](https://github.com/oauth-xx/oauth2/pull/623) in v2.0.5, where an error would be raised in refresh_token flows due to (legitimate) lack of access_token (@pboling)
|
10
|
+
|
7
11
|
## [2.0.5] - 2022-07-07
|
8
12
|
### Fixed
|
9
13
|
- [#620](https://github.com/oauth-xx/oauth2/pull/620) - Documentation improvements, to help with upgrading (@swanson)
|
@@ -292,5 +296,6 @@ and this project adheres to [Semantic Versioning v2](https://semver.org/spec/v2.
|
|
292
296
|
[2.0.3]: https://github.com/oauth-xx/oauth2/compare/v2.0.2...v2.0.3
|
293
297
|
[2.0.4]: https://github.com/oauth-xx/oauth2/compare/v2.0.3...v2.0.4
|
294
298
|
[2.0.5]: https://github.com/oauth-xx/oauth2/compare/v2.0.4...v2.0.5
|
295
|
-
[
|
299
|
+
[2.0.6]: https://github.com/oauth-xx/oauth2/compare/v2.0.5...v2.0.6
|
300
|
+
[Unreleased]: https://github.com/oauth-xx/oauth2/compare/v2.0.6...HEAD
|
296
301
|
[gemfiles/readme]: gemfiles/README.md
|
data/README.md
CHANGED
@@ -32,6 +32,8 @@ See the sibling `oauth` gem for OAuth 1.0 implementations in Ruby.
|
|
32
32
|
|
33
33
|
| Version | Release Date | Readme |
|
34
34
|
|---------|--------------|----------------------------------------------------------|
|
35
|
+
| 2.0.6 | 2022-07-13 | https://github.com/oauth-xx/oauth2/blob/v2.0.6/README.md |
|
36
|
+
| 2.0.5 | 2022-07-07 | https://github.com/oauth-xx/oauth2/blob/v2.0.5/README.md |
|
35
37
|
| 2.0.4 | 2022-07-01 | https://github.com/oauth-xx/oauth2/blob/v2.0.4/README.md |
|
36
38
|
| 2.0.3 | 2022-06-28 | https://github.com/oauth-xx/oauth2/blob/v2.0.3/README.md |
|
37
39
|
| 2.0.2 | 2022-06-24 | https://github.com/oauth-xx/oauth2/blob/v2.0.2/README.md |
|
@@ -143,8 +145,8 @@ The link tokens in the following sections should be kept ordered by the row and
|
|
143
145
|
[🖐prs-o-img]: https://img.shields.io/github/issues-pr/oauth-xx/oauth2
|
144
146
|
[🧮prs-c]: https://github.com/oauth-xx/oauth2/pulls?q=is%3Apr+is%3Aclosed
|
145
147
|
[🧮prs-c-img]: https://img.shields.io/github/issues-pr-closed/oauth-xx/oauth2
|
146
|
-
[📗next♻️]: https://github.com/oauth-xx/oauth2/milestone/
|
147
|
-
[📗next-img♻️]: https://img.shields.io/github/milestones/progress/oauth-xx/oauth2/
|
148
|
+
[📗next♻️]: https://github.com/oauth-xx/oauth2/milestone/2
|
149
|
+
[📗next-img♻️]: https://img.shields.io/github/milestones/progress/oauth-xx/oauth2/2?label=Next%20Version
|
148
150
|
|
149
151
|
<!-- 3️⃣ maintenance & linting -->
|
150
152
|
[⛳cclim-maint]: https://codeclimate.com/github/oauth-xx/oauth2/maintainability
|
data/lib/oauth2/access_token.rb
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module OAuth2
|
4
4
|
class AccessToken # rubocop:disable Metrics/ClassLength
|
5
|
+
TOKEN_KEYS_STR = %w[access_token id_token token accessToken idToken].freeze
|
6
|
+
TOKEN_KEYS_SYM = %i[access_token id_token token accessToken idToken].freeze
|
7
|
+
TOKEN_KEY_LOOKUP = TOKEN_KEYS_STR + TOKEN_KEYS_SYM
|
8
|
+
|
5
9
|
attr_reader :client, :token, :expires_in, :expires_at, :expires_latency, :params
|
6
10
|
attr_accessor :options, :refresh_token, :response
|
7
11
|
|
@@ -13,13 +17,13 @@ module OAuth2
|
|
13
17
|
# @option hash [String] 'access_token', 'id_token', 'token', :access_token, :id_token, or :token the access token
|
14
18
|
# @return [AccessToken] the initialized AccessToken
|
15
19
|
def from_hash(client, hash)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
new(client, token,
|
20
|
+
fresh = hash.dup
|
21
|
+
supported_keys = fresh.keys & TOKEN_KEY_LOOKUP
|
22
|
+
key = supported_keys[0]
|
23
|
+
# Having too many is sus, and may lead to bugs. Having none is fine (e.g. refresh flow doesn't need a token).
|
24
|
+
warn("OAuth2::AccessToken.from_hash: `hash` contained more than one 'token' key (#{supported_keys}); using #{key.inspect}.") if supported_keys.length > 1
|
25
|
+
token = fresh.delete(key)
|
26
|
+
new(client, token, fresh)
|
23
27
|
end
|
24
28
|
|
25
29
|
# Initializes an AccessToken from a key/value application/x-www-form-urlencoded string
|
@@ -35,7 +39,7 @@ module OAuth2
|
|
35
39
|
# Initialize an AccessToken
|
36
40
|
#
|
37
41
|
# @param [Client] client the OAuth2::Client instance
|
38
|
-
# @param [String] token the Access Token value
|
42
|
+
# @param [String] token the Access Token value (optional, may not be used in refresh flows)
|
39
43
|
# @param [Hash] opts the options to create the Access Token with
|
40
44
|
# @option opts [String] :refresh_token (nil) the refresh_token value
|
41
45
|
# @option opts [FixNum, String] :expires_in (nil) the number of seconds in which the AccessToken will expire
|
@@ -50,14 +54,19 @@ module OAuth2
|
|
50
54
|
@client = client
|
51
55
|
@token = token.to_s
|
52
56
|
|
53
|
-
if @client.options[:raise_errors] && (@token.nil? || @token.empty?)
|
54
|
-
error = Error.new(opts)
|
55
|
-
raise(error)
|
56
|
-
end
|
57
57
|
opts = opts.dup
|
58
58
|
%i[refresh_token expires_in expires_at expires_latency].each do |arg|
|
59
59
|
instance_variable_set("@#{arg}", opts.delete(arg) || opts.delete(arg.to_s))
|
60
60
|
end
|
61
|
+
no_tokens = (@token.nil? || @token.empty?) && (@refresh_token.nil? || @refresh_token.empty?)
|
62
|
+
if no_tokens
|
63
|
+
if @client.options[:raise_errors]
|
64
|
+
error = Error.new(opts)
|
65
|
+
raise(error)
|
66
|
+
else
|
67
|
+
warn('OAuth2::AccessToken has no token')
|
68
|
+
end
|
69
|
+
end
|
61
70
|
@expires_in ||= opts.delete('expires')
|
62
71
|
@expires_in &&= @expires_in.to_i
|
63
72
|
@expires_at &&= convert_expires_at(@expires_at)
|
data/lib/oauth2/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Boling
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-07-
|
13
|
+
date: 2022-07-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
@@ -307,10 +307,10 @@ licenses:
|
|
307
307
|
- MIT
|
308
308
|
metadata:
|
309
309
|
homepage_uri: https://github.com/oauth-xx/oauth2
|
310
|
-
source_code_uri: https://github.com/oauth-xx/oauth2/tree/v2.0.
|
311
|
-
changelog_uri: https://github.com/oauth-xx/oauth2/blob/v2.0.
|
310
|
+
source_code_uri: https://github.com/oauth-xx/oauth2/tree/v2.0.6
|
311
|
+
changelog_uri: https://github.com/oauth-xx/oauth2/blob/v2.0.6/CHANGELOG.md
|
312
312
|
bug_tracker_uri: https://github.com/oauth-xx/oauth2/issues
|
313
|
-
documentation_uri: https://www.rubydoc.info/gems/oauth2/2.0.
|
313
|
+
documentation_uri: https://www.rubydoc.info/gems/oauth2/2.0.6
|
314
314
|
wiki_uri: https://github.com/oauth-xx/oauth2/wiki
|
315
315
|
rubygems_mfa_required: 'true'
|
316
316
|
post_install_message: |2+
|