oauth2 2.0.22 → 2.0.24

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7964123b20cd2a456b4207c27b2695bbe8e46b30efdafc01731bdf97038fd58e
4
- data.tar.gz: 908001fb4aa70279ee6384a0de5fefb43bf3c8b64466e5df248f244b353a270c
3
+ metadata.gz: 6a0de4e6399834238562b52bb7e5c00550453118dfd111cb4bdc58de0e9e6657
4
+ data.tar.gz: d61082265dbbd08a4554d475fd7b9980f2beeae912e218191911db5dc12e55d5
5
5
  SHA512:
6
- metadata.gz: 772d189a481bf1329bcbb0443f98ce2feefefcc77387dad7d8f6128ebd2139a29fc0c2410721394aec5bcece3f786b980c33eba6acc0fe6ecd1c4366308dc0fb
7
- data.tar.gz: 959412178a6d2b37902c1b91a7e3b8c688dc1142dc118e56752ddaf0fdc99c06017d297d96ccfd0b37bca1dc2308c441050b40b64f06d31a815c6f5df7c91d0d
6
+ metadata.gz: 9a8cfb81304f9337ea276cbda2741e9d808885b0b301e55dfb9f76fa0f835f636c97e9ab29a896cc4b17e3801c3b9eacca33b520f77d94fe1b67eb9f39c23751
7
+ data.tar.gz: 93a8e651d24279a9f13b7bc267a19210830d9ed5fb33c79dcb820d998de55b89c4b6a241667945466f7782a11fcf3b3bae00156a697f02505e5a7ac0f3ddeec4
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1,3 @@
1
- ��7[+l�����emy*پ~�4�"N4o��R�V^צ�w^8J��n*|څG�
2
- Y�Cg(GA��ÿ�D��Y$En=��6(w��4���Ѹ6ŷ�=��O3Hб� �������`ؠђbZ]~z�/��FB��:G^lr+\���u���4�> ��
3
- �ܰ�d��dS'�R��?��>繱��S|����k�/c�~�Wҗ.�B���rɵ��l��L����ݡala��9\s�=�%LJZ4D�\��0M4E�_���� ��ylIzM"�|4/�y~;�����0u�?��O�ۮ�g`�/��ь��b��vvH
1
+ 6t�� �����v�����?�� V75K�:IK ��;~,'d��\�OR���o
2
+ �Q��W�D�μO�&�z.��V��<�r���(v��|r��!meħa��˸?"QZ{�; �B 81 \� Fb�9��ji�Z�,v'
3
+ 5�.7��`q�q��� �w��uK�S� Y���LO��u/��+�^L%�y�<�Լ�/��ӝ�_j;��K݇<�I����'�����K�/㮖��A������u!S�W}��&�{r�-���v��Yfv�ԩ��\�W�l@�{�^�<T�Ǝ��w~�зpS�]kr��7L6��p����>��4�+k�;\iAkc��W��?$�H��E��q�ͳ
data/CHANGELOG.md CHANGED
@@ -30,6 +30,47 @@ Please file a bug if you notice a violation of semantic versioning.
30
30
 
31
31
  ### Security
32
32
 
33
+ ## [2.0.24] - 2026-06-18
34
+
35
+ - TAG: [v2.0.24][2.0.24t]
36
+ - COVERAGE: 100.00% -- 558/558 lines in 15 files
37
+ - BRANCH COVERAGE: 97.89% -- 186/190 branches in 15 files
38
+ - 88.35% documented
39
+
40
+ ### Changed
41
+
42
+ - Raised the `anonymous_loader` runtime dependency floor to `>= 0.1.1`.
43
+ - Raised the `auth-sanitizer` runtime dependency floor to `>= 0.2.2` and
44
+ switched isolated sanitizer loading to the released `anonymous_loader` gem,
45
+ including local workspace wiring for the new runtime dependency.
46
+
47
+ ### Fixed
48
+
49
+ - Fixed isolated `auth-sanitizer` loading when Bundler standalone setup makes
50
+ `auth_sanitizer/loader.rb` available on `$LOAD_PATH` without adding
51
+ `auth-sanitizer` to `Gem.loaded_specs` or `GEM_PATH`.
52
+
53
+ ## [2.0.23] - 2026-06-13
54
+
55
+ - TAG: [v2.0.23][2.0.23t]
56
+ - COVERAGE: 100.00% -- 562/562 lines in 15 files
57
+ - BRANCH COVERAGE: 97.89% -- 186/190 branches in 15 files
58
+ - 88.35% documented
59
+
60
+ ### Changed
61
+
62
+ - Upgraded to snaky_hash v2.0.6 by @pboling
63
+ - Refreshed generated GHA workflow action SHA pins by @pboling
64
+
65
+ ### Fixed
66
+
67
+ - Addressed Reek code-quality checks with targeted cleanup and documented compatibility exclusions by @pboling
68
+ - Fixed deprecation warning from MultiXML by @robzolkos
69
+
70
+ [gh!733]: https://github.com/ruby-oauth/oauth2/pull/733
71
+
72
+ - Fixed head appraisal dependency conflicts and Ruby 2.4 protocol-relative redirect handling by @pboling
73
+
33
74
  ## [2.0.22] - 2026-06-07
34
75
 
35
76
  - TAG: [v2.0.22][2.0.22t]
@@ -45,7 +86,9 @@ Please file a bug if you notice a violation of semantic versioning.
45
86
 
46
87
  ### Security
47
88
 
48
- - [GHSA-pp92-crg2-gfv9] Prevent protocol-relative redirect `Location` values from changing request authority, and strip `Authorization` headers from cross-origin redirects.
89
+ - [GHSA-pp92-crg2-gfv9][GHSA-pp92-crg2-gfv9] Prevent protocol-relative redirect `Location` values from changing request authority, and strip `Authorization` headers from cross-origin redirects by @tonghuaroot and @pboling
90
+
91
+ [GHSA-pp92-crg2-gfv9]: https://github.com/ruby-oauth/oauth2/security/advisories/GHSA-pp92-crg2-gfv9
49
92
 
50
93
  ## [2.0.21] - 2026-06-06
51
94
 
@@ -67,7 +110,9 @@ Please file a bug if you notice a violation of semantic versioning.
67
110
  ### Changed
68
111
 
69
112
  - Raised generated `version_gem` dependency floor to `version_gem` >= 1.1.10 - by @pboling
70
- - Raised the runtime dependency floor for `auth-sanitizer` to `>= 0.2.1` - by @pboling
113
+ - Raised the runtime dependency floor for `auth-sanitizer` to `>= 0.2.1` so
114
+ OAuth2 consumers get hash and nested-attribute inspect redaction fixes plus
115
+ downstream RBS duplicate-declaration fixes - by @pboling
71
116
  - Refreshed generated package metadata, support documentation, CI workflows,
72
117
  and development dependency floors from the current kettle-jem template - by @pboling
73
118
  - Documented the current per-version Ruby, JRuby, and TruffleRuby CI matrix in
@@ -863,7 +908,11 @@ Please file a bug if you notice a violation of semantic versioning.
863
908
 
864
909
  [gemfiles/readme]: gemfiles/README.md
865
910
 
866
- [Unreleased]: https://github.com/ruby-oauth/oauth2/compare/v2.0.22...HEAD
911
+ [Unreleased]: https://github.com/ruby-oauth/oauth2/compare/v2.0.24...HEAD
912
+ [2.0.24]: https://github.com/ruby-oauth/oauth2/compare/v2.0.23...v2.0.24
913
+ [2.0.24t]: https://github.com/ruby-oauth/oauth2/releases/tag/v2.0.24
914
+ [2.0.23]: https://github.com/ruby-oauth/oauth2/compare/v2.0.22...v2.0.23
915
+ [2.0.23t]: https://github.com/ruby-oauth/oauth2/releases/tag/v2.0.23
867
916
  [2.0.22]: https://github.com/ruby-oauth/oauth2/compare/v2.0.21...v2.0.22
868
917
  [2.0.22t]: https://github.com/ruby-oauth/oauth2/releases/tag/v2.0.22
869
918
  [2.0.21]: https://github.com/ruby-oauth/oauth2/compare/v2.0.20...v2.0.21
data/CONTRIBUTING.md CHANGED
@@ -109,14 +109,14 @@ Git diff driver setup
109
109
  - Git hosting forges generally ignore external diff drivers, so pull request views may still show raw textual diffs even when local `git diff` uses semantic drivers.
110
110
 
111
111
  ```console
112
- K_JEM_TEMPLATING=true bundle exec kettle-jem install
112
+ K_JEM_TEMPLATING=true kettle-jem install
113
113
  ```
114
114
 
115
115
  Troubleshooting Git diffs
116
116
  - Use `git diff --no-ext-diff` to compare against Git's built-in diff output.
117
117
  - Use `git diff --no-textconv` when a textconv projection obscures the raw file bytes you need to inspect.
118
118
  - If Git reports a missing `smorg-*` executable, rerun `bundle install` and the setup command above, then check `git config --local --get-regexp '^diff\.smorg-'`.
119
- - To remove managed local entries, run `K_JEM_TEMPLATING=true bundle exec kettle-jem install --undo`; remove global command registrations with `git config --global --unset-all diff.smorg-ruby.command`.
119
+ - To remove managed local entries, run `K_JEM_TEMPLATING=true kettle-jem install --undo`; remove global command registrations with `git config --global --unset-all diff.smorg-ruby.command`.
120
120
 
121
121
  For a quick starting point, this repository’s `mise.toml` defines the shared defaults, and `.env.local` can override them locally. Copy `.env.local.example` to `.env.local`, use `KEY=value` lines, and either activate `mise` in your shell or run commands through `mise exec -C /path/to/project -- ...`.
122
122
 
data/LICENSE.md CHANGED
@@ -107,4 +107,5 @@ Choose the option that best fits your use case:
107
107
  - Copyright (c) 2025 Sasa Rosic
108
108
  - Copyright (c) 2026 Jonathan Grinstead
109
109
  - Copyright (c) 2026 kain
110
+ - Copyright (c) 2026 Rob Zolkos
110
111
  - Copyright (c) 2026 StepSecurity Bot
data/README.md CHANGED
@@ -171,9 +171,22 @@ This test floor is configured by `ruby.test_minimum` in `.kettle-jem.yml` and
171
171
  may be higher than the gem's runtime compatibility floor when legacy Rubies are
172
172
  not practical for the current toolchain.
173
173
 
174
- | 🚚 _Amazing_ test matrix was brought to you by | 🔎 appraisal2 🔎 and the color 💚 green 💚 |
175
- |------------------------------------------------|--------------------------------------------------------|
176
- | 👟 Check it out! | ✨ [github.com/appraisal-rb/appraisal2][💎appraisal2] ✨ |
174
+ | 🚚 _Amazing_ test matrix was brought to you by | The Kettle dev/test stack |
175
+ |------------------------------------------------|---------------------------|
176
+
177
+ <details>
178
+ <summary>How We Manage Complexity In Tests</summary>
179
+
180
+ | Gem | Source | Role | Daily download rank |
181
+ |-----|--------|------|---------------------|
182
+ | [appraisal2](https://bestgems.org/gems/appraisal2) | [GitHub](https://github.com/appraisal-rb/appraisal2) | multi-dependency Appraisal matrix generation | [![Daily download rank for appraisal2](https://img.shields.io/gem/rd/appraisal2.svg?style=flat-square)](https://bestgems.org/gems/appraisal2) |
183
+ | [appraisal2-rubocop](https://bestgems.org/gems/appraisal2-rubocop) | [GitHub](https://github.com/appraisal-rb/appraisal2-rubocop) | RuboCop Appraisal generator integration | [![Daily download rank for appraisal2-rubocop](https://img.shields.io/gem/rd/appraisal2-rubocop.svg?style=flat-square)](https://bestgems.org/gems/appraisal2-rubocop) |
184
+ | [turbo_tests2](https://bestgems.org/gems/turbo_tests2) | [GitHub](https://github.com/galtzo-floss/turbo_tests2) | parallel test execution | [![Daily download rank for turbo_tests2](https://img.shields.io/gem/rd/turbo_tests2.svg?style=flat-square)](https://bestgems.org/gems/turbo_tests2) |
185
+ | [kettle-test](https://bestgems.org/gems/kettle-test) | [GitHub](https://github.com/kettle-dev/kettle-test) | standard test runner and coverage harness | [![Daily download rank for kettle-test](https://img.shields.io/gem/rd/kettle-test.svg?style=flat-square)](https://bestgems.org/gems/kettle-test) |
186
+ | [kettle-soup-cover](https://bestgems.org/gems/kettle-soup-cover) | [GitHub](https://github.com/kettle-dev/kettle-soup-cover) | SimpleCov coverage policy and reporting | [![Daily download rank for kettle-soup-cover](https://img.shields.io/gem/rd/kettle-soup-cover.svg?style=flat-square)](https://bestgems.org/gems/kettle-soup-cover) |
187
+ | [rubocop-lts](https://bestgems.org/gems/rubocop-lts) | [GitHub](https://github.com/rubocop-lts/rubocop-lts) | Ruby-version-aware linting | [![Daily download rank for rubocop-lts](https://img.shields.io/gem/rd/rubocop-lts.svg?style=flat-square)](https://bestgems.org/gems/rubocop-lts) |
188
+
189
+ </details>
177
190
 
178
191
  ### Federated DVCS
179
192
 
@@ -660,9 +673,13 @@ NOTE: [kettle-readme-backers][kettle-readme-backers] updates this list every day
660
673
 
661
674
  <!-- OPENCOLLECTIVE-ORGANIZATIONS:START -->
662
675
  No sponsors yet. Be the first!
676
+
677
+ ### Open Collective for Donors
678
+
679
+ [Bill Woika](https://opencollective.com/bill-woika) [Philipp Ebneter](https://opencollective.com/guest-e77282f7) [Grigoriy](https://opencollective.com/guest-c93e0c48)
663
680
  <!-- OPENCOLLECTIVE-ORGANIZATIONS:END -->
664
681
 
665
- [kettle-readme-backers]: https://github.com/ruby-oauth/oauth2/blob/main/exe/kettle-readme-backers
682
+ [kettle-readme-backers]: https://github.com/ruby-oauth/oauth2/blob/main/bin/kettle-readme-backers
666
683
 
667
684
  ### Another way to support open-source
668
685
 
@@ -871,6 +888,7 @@ See [LICENSE.md][📄license] for the official copyright notice.
871
888
  - Copyright (c) 2025 Sasa Rosic
872
889
  - Copyright (c) 2026 Jonathan Grinstead
873
890
  - Copyright (c) 2026 kain
891
+ - Copyright (c) 2026 Rob Zolkos
874
892
  - Copyright (c) 2026 StepSecurity Bot
875
893
 
876
894
  </details>
@@ -1086,7 +1104,7 @@ Thanks for RTFM. ☺️
1086
1104
  [📌gitmoji]: https://gitmoji.dev
1087
1105
  [📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
1088
1106
  [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
1089
- [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.542-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
1107
+ [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.558-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
1090
1108
  [🔐security]: https://github.com/ruby-oauth/oauth2/blob/main/SECURITY.md
1091
1109
  [🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
1092
1110
  [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
@@ -1094,7 +1112,7 @@ Thanks for RTFM. ☺️
1094
1112
  [📄license-ref]: MIT.md
1095
1113
  [📄license-img]: https://img.shields.io/badge/License-MIT-259D6C.svg
1096
1114
  [📄license-compat]: https://www.apache.org/legal/resolved.html#category-a
1097
- [📄license-compat-img]: https://img.shields.io/badge/Apache_Compatible:_Category_A-✓-259D6C.svg?style=flat&logo=Apache
1115
+ [📄license-compat-img]: https://img.shields.io/badge/Apache_Compatible:_Category_A-%E2%9C%93-259D6C.svg?style=flat&logo=Apache
1098
1116
 
1099
1117
  [📄ilo-declaration]: https://www.ilo.org/declaration/lang--en/index.htm
1100
1118
  [📄ilo-declaration-img]: https://img.shields.io/badge/ILO_Fundamental_Principles-✓-259D6C.svg?style=flat
@@ -1114,7 +1132,7 @@ Thanks for RTFM. ☺️
1114
1132
  | Package | oauth2 |
1115
1133
  | Description | 🔐 A Ruby wrapper for the OAuth 2.0 Authorization Framework, including the OAuth 2.1 draft spec, and OpenID Connect (OIDC) |
1116
1134
  | Homepage | https://github.com/ruby-oauth/oauth2 |
1117
- | Source | https://github.com/ruby-oauth/oauth2/tree/v2.0.21 |
1135
+ | Source | https://github.com/ruby-oauth/oauth2 |
1118
1136
  | License | `MIT` |
1119
1137
  | Funding | https://github.com/sponsors/pboling, https://issuehunt.io/u/pboling, https://ko-fi.com/pboling, https://liberapay.com/pboling/donate, https://opencollective.com/ruby-oauth, https://patreon.com/galtzo, https://polar.sh/pboling, https://thanks.dev/u/gh/pboling, https://tidelift.com/funding/github/rubygems/oauth2, https://www.buymeacoffee.com/pboling |
1120
1138
  <!-- kettle-jem:metadata:end -->
@@ -68,13 +68,7 @@ module OAuth2
68
68
  end
69
69
  # :nocov:
70
70
  # TODO: Get rid of this branching logic when dropping Hashie < v3.2
71
- token = if !defined?(Hashie::VERSION) # i.e. <= "1.1.0"; the first Hashie to ship with a VERSION constant
72
- warn("snaky_hash and oauth2 will drop support for Hashie v0 in the next major version. Please upgrade to a modern Hashie.")
73
- # There is a bug in Hashie v0, which is accounts for.
74
- fresh.delete(t_key) || fresh[t_key] || ""
75
- else
76
- fresh.delete(t_key) || ""
77
- end
71
+ token = extract_token_value(fresh, t_key)
78
72
  # :nocov:
79
73
  new(client, token, fresh)
80
74
  end
@@ -108,6 +102,17 @@ Custom token_name (#{key}) is not found in (#{hash.keys})
108
102
  You may need to set `snaky: false`. See inline documentation for more info.
109
103
  ])
110
104
  end
105
+
106
+ # :nocov:
107
+ def extract_token_value(fresh, key)
108
+ token_value = fresh.delete(key)
109
+ return token_value || "" if defined?(Hashie::VERSION)
110
+
111
+ warn("snaky_hash and oauth2 will drop support for Hashie v0 in the next major version. Please upgrade to a modern Hashie.")
112
+ # There is a bug in Hashie v0, which this accounts for.
113
+ token_value || fresh[key] || ""
114
+ end
115
+ # :nocov:
111
116
  end
112
117
 
113
118
  # Initialize an AccessToken
@@ -305,8 +310,8 @@ You may need to set `snaky: false`. See inline documentation for more info.
305
310
  # TODO: Switch when dropping Ruby < 2.5 support
306
311
  # params.transform_keys(&:to_sym) # Ruby 2.5 only
307
312
  # Old Ruby transform_keys alternative:
308
- sheesh = @params.each_with_object({}) { |(k, v), memo|
309
- memo[k.to_sym] = v
313
+ sheesh = @params.each_with_object({}) { |(key, value), memo|
314
+ memo[key.to_sym] = value
310
315
  }
311
316
  sheesh.merge(hsh)
312
317
  end
@@ -375,6 +380,7 @@ You may need to set `snaky: false`. See inline documentation for more info.
375
380
 
376
381
  def configure_authentication!(opts, verb)
377
382
  mode_opt = options[:mode]
383
+ param_name = options[:param_name]
378
384
  mode =
379
385
  if mode_opt.respond_to?(:call)
380
386
  mode_opt.call(verb)
@@ -388,19 +394,19 @@ You may need to set `snaky: false`. See inline documentation for more info.
388
394
 
389
395
  case mode
390
396
  when :header
391
- opts[:headers] ||= {}
392
- opts[:headers].merge!(headers)
397
+ request_headers = opts[:headers] ||= {}
398
+ request_headers.merge!(headers)
393
399
  when :query
394
400
  # OAuth 2.1 note: Bearer tokens in the query string are omitted from the spec due to security risks.
395
401
  # Prefer the default :header mode whenever possible.
396
- opts[:params] ||= {}
397
- opts[:params][options[:param_name]] = token
402
+ request_params = opts[:params] ||= {}
403
+ request_params[param_name] = token
398
404
  when :body
399
- opts[:body] ||= {}
400
- if opts[:body].is_a?(Hash)
401
- opts[:body][options[:param_name]] = token
405
+ request_body = opts[:body] ||= {}
406
+ if request_body.is_a?(Hash)
407
+ request_body[param_name] = token
402
408
  else
403
- opts[:body] += "&#{options[:param_name]}=#{token}"
409
+ opts[:body] = "#{request_body}&#{param_name}=#{token}"
404
410
  end
405
411
  # @todo support for multi-part (file uploads)
406
412
  else
@@ -1,31 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "anonymous_loader"
4
+
3
5
  module OAuth2
4
6
  AUTH_SANITIZER = begin
5
- auth_sanitizer_requirement = Gem::Requirement.new("~> 0.2", ">= 0.2.1")
6
- auth_sanitizer_spec = Gem.loaded_specs["auth-sanitizer"]
7
- unless auth_sanitizer_spec && auth_sanitizer_requirement.satisfied_by?(auth_sanitizer_spec.version)
8
- # :nocov:
9
- auth_sanitizer_spec = Gem::Specification.find_by_name("auth-sanitizer", auth_sanitizer_requirement)
10
- # :nocov:
11
- end
12
-
13
- auth_sanitizer_loader_path = File.join(
14
- auth_sanitizer_spec.full_gem_path,
15
- "lib/auth_sanitizer/loader.rb"
16
- )
17
- unless File.file?(auth_sanitizer_loader_path)
18
- # :nocov:
19
- raise LoadError, "oauth2 requires auth-sanitizer #{auth_sanitizer_requirement}; " \
20
- "loader not found at #{auth_sanitizer_loader_path}"
21
- # :nocov:
22
- end
23
-
24
- auth_sanitizer_loader_namespace = Module.new
25
- auth_sanitizer_loader_namespace.module_eval(
26
- File.read(auth_sanitizer_loader_path),
27
- auth_sanitizer_loader_path,
28
- 1
7
+ auth_sanitizer_requirement = Gem::Requirement.new("~> 0.2", ">= 0.2.2")
8
+ auth_sanitizer_loader_namespace = AnonymousLoader.load_path(
9
+ gem_name: "auth-sanitizer",
10
+ require_path: "auth_sanitizer/loader.rb",
11
+ version_requirement: auth_sanitizer_requirement,
12
+ version_file: "auth/sanitizer/version.rb"
29
13
  )
30
14
 
31
15
  auth_sanitizer_loader_namespace.
data/lib/oauth2/client.rb CHANGED
@@ -86,8 +86,9 @@ module OAuth2
86
86
  @connection ||=
87
87
  Faraday.new(site, options[:connection_opts]) do |builder|
88
88
  oauth_debug_logging(builder)
89
- if options[:connection_build]
90
- options[:connection_build].call(builder)
89
+ connection_build = options[:connection_build]
90
+ if connection_build
91
+ connection_build.call(builder)
91
92
  else
92
93
  builder.request(:url_encoded) # form-encode POST params
93
94
  builder.adapter(Faraday.default_adapter) # make requests with Net::HTTP
@@ -149,9 +150,9 @@ module OAuth2
149
150
 
150
151
  case status
151
152
  when 301, 302, 303, 307
152
- req_opts[:redirect_count] ||= 0
153
- req_opts[:redirect_count] += 1
154
- return response if req_opts[:redirect_count] > options[:max_redirects]
153
+ redirect_count = (req_opts[:redirect_count] || 0).to_i + 1
154
+ req_opts[:redirect_count] = redirect_count
155
+ return response if redirect_count > options[:max_redirects]
155
156
 
156
157
  if status == 303
157
158
  verb = :get
@@ -338,8 +339,9 @@ module OAuth2
338
339
  #
339
340
  # @return [Hash] the params to add to a request or URL
340
341
  def redirection_params
341
- if options[:redirect_uri]
342
- {"redirect_uri" => options[:redirect_uri]}
342
+ redirect_uri = options[:redirect_uri]
343
+ if redirect_uri
344
+ {"redirect_uri" => redirect_uri}
343
345
  else
344
346
  {}
345
347
  end
@@ -446,7 +448,7 @@ module OAuth2
446
448
  url = connection.build_url(url).to_s
447
449
  # See: Hash#partition https://bugs.ruby-lang.org/issues/16252
448
450
  req_opts, oauth_opts = opts.
449
- partition { |k, _v| RESERVED_REQ_KEYS.include?(k.to_s) }.
451
+ partition { |key, _value| RESERVED_REQ_KEYS.include?(key.to_s) }.
450
452
  map(&:to_h)
451
453
 
452
454
  begin
@@ -454,10 +456,10 @@ module OAuth2
454
456
  req.params.update(req_opts[:params]) if req_opts[:params]
455
457
  yield(req) if block_given?
456
458
  end
457
- rescue Faraday::ConnectionFailed => e
458
- raise ConnectionError, e
459
- rescue Faraday::TimeoutError => e
460
- raise TimeoutError, e
459
+ rescue Faraday::ConnectionFailed => exception
460
+ raise ConnectionError, exception
461
+ rescue Faraday::TimeoutError => exception
462
+ raise TimeoutError, exception
461
463
  end
462
464
 
463
465
  parse = oauth_opts.key?(:parse) ? oauth_opts.delete(:parse) : Response::DEFAULT_OPTIONS[:parse]
@@ -467,29 +469,42 @@ module OAuth2
467
469
  end
468
470
 
469
471
  def resolve_redirect_location(current_location, location)
470
- safe_location =
471
- if location.respond_to?(:start_with?) && location.start_with?("//")
472
- "./#{location}"
473
- else
474
- location
475
- end
472
+ return protocol_relative_redirect_location(current_location, location) if location.respond_to?(:start_with?) && location.start_with?("//")
476
473
 
477
- current_location.merge(safe_location)
474
+ current_location.merge(location)
475
+ end
476
+
477
+ def protocol_relative_redirect_location(current_location, location)
478
+ protocol_relative_location = URI.parse(location)
479
+ authority = +""
480
+ authority << "#{protocol_relative_location.userinfo}@" if protocol_relative_location.userinfo
481
+ authority << protocol_relative_location.host.to_s
482
+ authority << ":#{protocol_relative_location.port}" if protocol_relative_location.port
483
+
484
+ current_location.dup.tap do |safe_location|
485
+ safe_location.path = "///#{authority}#{protocol_relative_location.path}"
486
+ safe_location.query = protocol_relative_location.query if safe_location.respond_to?(:query=)
487
+ safe_location.fragment = protocol_relative_location.fragment if safe_location.respond_to?(:fragment=)
488
+ end
478
489
  end
479
490
 
480
491
  def sanitize_redirect_options(req_opts, current_location, next_location)
481
492
  return req_opts unless cross_origin_redirect?(current_location, next_location)
482
493
 
483
494
  headers = req_opts[:headers]
484
- return req_opts unless headers && headers.any? { |key, _value| key.to_s.casecmp("Authorization").zero? }
495
+ return req_opts unless headers && headers.any? { |key, _value| authorization_header?(key) }
485
496
 
486
497
  safe_opts = req_opts.dup
487
498
  safe_headers = headers.dup
488
- safe_headers.delete_if { |key, _value| key.to_s.casecmp("Authorization").zero? }
499
+ safe_headers.delete_if { |key, _value| authorization_header?(key) }
489
500
  safe_opts[:headers] = safe_headers
490
501
  safe_opts
491
502
  end
492
503
 
504
+ def authorization_header?(key)
505
+ key.to_s.casecmp("Authorization").zero?
506
+ end
507
+
493
508
  def cross_origin_redirect?(current_location, next_location)
494
509
  current_location.scheme != next_location.scheme ||
495
510
  current_location.host != next_location.host ||
@@ -595,12 +610,13 @@ module OAuth2
595
610
 
596
611
  def oauth_debug_logging(builder)
597
612
  if OAuth2::OAUTH_DEBUG
613
+ config = OAuth2.config
598
614
  builder.response(
599
615
  :logger,
600
616
  OAuth2::AUTH_SANITIZER::SanitizedLogger.new(
601
617
  options[:logger],
602
- filtered_keys: OAuth2.config[:filtered_debug_keys],
603
- label: OAuth2.config[:filtered_label]
618
+ filtered_keys: config[:filtered_debug_keys],
619
+ label: config[:filtered_label]
604
620
  ),
605
621
  bodies: true
606
622
  )
data/lib/oauth2/error.rb CHANGED
@@ -20,9 +20,10 @@ module OAuth2
20
20
  @code = nil
21
21
  @description = nil
22
22
  if response.respond_to?(:parsed)
23
- if response.parsed.is_a?(Hash)
24
- @code = response.parsed["error"]
25
- @description = response.parsed["error_description"]
23
+ parsed_response = response.parsed
24
+ if parsed_response.is_a?(Hash)
25
+ @code = parsed_response["error"]
26
+ @description = parsed_response["error_description"]
26
27
  end
27
28
  elsif response.is_a?(Hash)
28
29
  @code = response["error"]
@@ -46,11 +47,12 @@ module OAuth2
46
47
  # @return [String] Message suitable for StandardError
47
48
  def error_message(response_body, opts = {})
48
49
  lines = []
50
+ error_description = opts[:error_description]
49
51
 
50
- lines << opts[:error_description] if opts[:error_description]
52
+ lines << error_description if error_description
51
53
 
52
- error_string = if response_body.respond_to?(:encode) && opts[:error_description].respond_to?(:encoding)
53
- script_encoding = opts[:error_description].encoding
54
+ error_string = if response_body.respond_to?(:encode) && error_description.respond_to?(:encoding)
55
+ script_encoding = error_description.encoding
54
56
  response_body.encode(script_encoding, invalid: :replace, undef: :replace)
55
57
  else
56
58
  response_body
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "json"
4
+ require "set"
4
5
  require "multi_xml"
5
6
  require "rack"
6
7
 
@@ -108,15 +109,16 @@ module OAuth2
108
109
  def parsed
109
110
  return @parsed if defined?(@parsed)
110
111
 
112
+ response_parser = parser
111
113
  @parsed =
112
- if parser.respond_to?(:call)
113
- case parser.arity
114
+ if response_parser.respond_to?(:call)
115
+ case response_parser.arity
114
116
  when 0
115
- parser.call
117
+ response_parser.call
116
118
  when 1
117
- parser.call(body)
119
+ response_parser.call(body)
118
120
  else
119
- parser.call(body, response)
121
+ response_parser.call(body, response)
120
122
  end
121
123
  end
122
124
 
@@ -132,9 +134,10 @@ module OAuth2
132
134
  #
133
135
  # @return [String, nil] The content type or nil if headers are not present
134
136
  def content_type
135
- return unless response.headers
137
+ response_headers = response.headers
138
+ return unless response_headers
136
139
 
137
- ((response.headers.values_at("content-type", "Content-Type").compact.first || "").split(";").first || "").strip.downcase
140
+ ((response_headers.values_at("content-type", "Content-Type").compact.first || "").split(";").first || "").strip.downcase
138
141
  end
139
142
 
140
143
  # Determines the parser to be used for the response body
@@ -154,11 +157,12 @@ module OAuth2
154
157
  def parser
155
158
  return @parser if defined?(@parser)
156
159
 
160
+ parse_option = options[:parse]
157
161
  @parser =
158
- if options[:parse].respond_to?(:call)
159
- options[:parse]
160
- elsif options[:parse]
161
- @@parsers[options[:parse].to_sym]
162
+ if parse_option.respond_to?(:call)
163
+ parse_option
164
+ elsif parse_option
165
+ @@parsers[parse_option.to_sym]
162
166
  end
163
167
 
164
168
  @parser ||= @@parsers[@@content_types[content_type]]
@@ -171,7 +175,7 @@ end
171
175
  OAuth2::Response.register_parser(:xml, ["text/xml", "application/rss+xml", "application/rdf+xml", "application/atom+xml", "application/xml"]) do |body|
172
176
  next body unless body.respond_to?(:to_str)
173
177
 
174
- MultiXml.parse(body)
178
+ (defined?(MultiXML) ? MultiXML : MultiXml).parse(body)
175
179
  end
176
180
 
177
181
  # Register JSON parser
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OAuth2
4
4
  module Version
5
- VERSION = "2.0.22"
5
+ VERSION = "2.0.24"
6
6
  end
7
7
  VERSION = Version::VERSION # Traditional Constant Location
8
8
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,12 +1,105 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.22
4
+ version: 2.0.24
5
5
  platform: ruby
6
6
  authors:
7
- - Peter Boling
8
7
  - Erik Michaels-Ober
8
+ - Jeremy Kemper
9
9
  - Michael Bleigh
10
+ - Paul Walker
11
+ - rick
12
+ - Tim Habermaas
13
+ - Wynn Netherland
14
+ - Alexander Lang
15
+ - Greg Spurrier
16
+ - Jay Adkisson
17
+ - Luke Saunders
18
+ - Simon Gate
19
+ - Bas Vodde
20
+ - Damian Janowski
21
+ - Daniël van de Burgt
22
+ - Dorren Chen
23
+ - Igor Sales
24
+ - Leigh Caplan
25
+ - Michael Andrews
26
+ - Omer Rauchwerger
27
+ - Saverio Trioni
28
+ - Trent Ogren
29
+ - Vsevolod Romashov
30
+ - Antonio Tapiador del Dujo
31
+ - Eduardo Gurgel
32
+ - Geostellar Developer
33
+ - Niels Ganser
34
+ - Rainux Luo
35
+ - Taylor Hedberg
36
+ - Tim Clem
37
+ - Dave Stevens
38
+ - Ellis Berner
39
+ - Frank Macreery
40
+ - Olivier Lacan
41
+ - Peter Souter
42
+ - Ryan Williams
43
+ - Andrew Cantino and Jeff Moore
44
+ - Thomas Walpole
45
+ - Bo Jeanes
46
+ - Cody Cutrer
47
+ - Edward Rudd
48
+ - Lawrence Oluyede
49
+ - Linus Pettersson
50
+ - Motoshi Nishihira
51
+ - Adrian Setyadi
52
+ - Benjamin Quorning
53
+ - Christoph Petschnig
54
+ - Nathaniel Bibler
55
+ - Oleg
56
+ - Samuel Cochran
57
+ - tetsuya
58
+ - Yury Velikanau
59
+ - Alex Kowalczuk
60
+ - asm__
61
+ - David Christensen
62
+ - fossabot
63
+ - Jeff Moore
64
+ - Jonathan del Strother
65
+ - Joseph Page
66
+ - Lomey
67
+ - Markus Bengts
68
+ - Mathias Klippinge
69
+ - nikz
70
+ - Peter H. Boling
71
+ - Daniel Fockler
72
+ - Elliot Crosby-McCullough
73
+ - João Paulo
74
+ - Orien Madgwick
75
+ - Ryan T. Hosford
76
+ - Tom Corley
77
+ - anvox
78
+ - Jesse Cotton
79
+ - Olle Jonsson
80
+ - Stephen Reid
81
+ - Anders Carling
82
+ - dobon
83
+ - Jan Zaydowicz
84
+ - Nicholas Palaniuk
85
+ - Stan Hu
86
+ - Bouke van der Bijl
87
+ - nov
88
+ - Rick Selby
89
+ - Ryo Takahashi
90
+ - Jessie Young
91
+ - Карим Гимадеев
92
+ - Aboling0
93
+ - Elise Wood
94
+ - Manuel van Rijn
95
+ - Annibelle Boling
96
+ - Mark James
97
+ - Mridang Agarwalla
98
+ - Sasa Rosic
99
+ - Jonathan Grinstead
100
+ - kain
101
+ - Rob Zolkos
102
+ - StepSecurity Bot
10
103
  bindir: exe
11
104
  cert_chain:
12
105
  - |
@@ -39,6 +132,26 @@ cert_chain:
39
132
  -----END CERTIFICATE-----
40
133
  date: 1980-01-02 00:00:00.000000000 Z
41
134
  dependencies:
135
+ - !ruby/object:Gem::Dependency
136
+ name: anonymous_loader
137
+ requirement: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '0.1'
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: 0.1.1
145
+ type: :runtime
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '0.1'
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: 0.1.1
42
155
  - !ruby/object:Gem::Dependency
43
156
  name: auth-sanitizer
44
157
  requirement: !ruby/object:Gem::Requirement
@@ -48,7 +161,7 @@ dependencies:
48
161
  version: '0.2'
49
162
  - - ">="
50
163
  - !ruby/object:Gem::Version
51
- version: 0.2.1
164
+ version: 0.2.2
52
165
  type: :runtime
53
166
  prerelease: false
54
167
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +171,7 @@ dependencies:
58
171
  version: '0.2'
59
172
  - - ">="
60
173
  - !ruby/object:Gem::Version
61
- version: 0.2.1
174
+ version: 0.2.2
62
175
  - !ruby/object:Gem::Dependency
63
176
  name: faraday
64
177
  requirement: !ruby/object:Gem::Requirement
@@ -156,7 +269,7 @@ dependencies:
156
269
  version: '2.0'
157
270
  - - ">="
158
271
  - !ruby/object:Gem::Version
159
- version: 2.0.5
272
+ version: 2.0.6
160
273
  type: :runtime
161
274
  prerelease: false
162
275
  version_requirements: !ruby/object:Gem::Requirement
@@ -166,7 +279,7 @@ dependencies:
166
279
  version: '2.0'
167
280
  - - ">="
168
281
  - !ruby/object:Gem::Version
169
- version: 2.0.5
282
+ version: 2.0.6
170
283
  - !ruby/object:Gem::Dependency
171
284
  name: version_gem
172
285
  requirement: !ruby/object:Gem::Requirement
@@ -176,7 +289,7 @@ dependencies:
176
289
  version: '1.1'
177
290
  - - ">="
178
291
  - !ruby/object:Gem::Version
179
- version: 1.1.11
292
+ version: 1.1.12
180
293
  type: :runtime
181
294
  prerelease: false
182
295
  version_requirements: !ruby/object:Gem::Requirement
@@ -186,27 +299,27 @@ dependencies:
186
299
  version: '1.1'
187
300
  - - ">="
188
301
  - !ruby/object:Gem::Version
189
- version: 1.1.11
302
+ version: 1.1.12
190
303
  - !ruby/object:Gem::Dependency
191
304
  name: kettle-dev
192
305
  requirement: !ruby/object:Gem::Requirement
193
306
  requirements:
194
307
  - - "~>"
195
308
  - !ruby/object:Gem::Version
196
- version: '2.1'
309
+ version: '2.2'
197
310
  - - ">="
198
311
  - !ruby/object:Gem::Version
199
- version: 2.1.1
312
+ version: 2.2.12
200
313
  type: :development
201
314
  prerelease: false
202
315
  version_requirements: !ruby/object:Gem::Requirement
203
316
  requirements:
204
317
  - - "~>"
205
318
  - !ruby/object:Gem::Version
206
- version: '2.1'
319
+ version: '2.2'
207
320
  - - ">="
208
321
  - !ruby/object:Gem::Version
209
- version: 2.1.1
322
+ version: 2.2.12
210
323
  - !ruby/object:Gem::Dependency
211
324
  name: bundler-audit
212
325
  requirement: !ruby/object:Gem::Requirement
@@ -264,7 +377,7 @@ dependencies:
264
377
  version: '3.1'
265
378
  - - ">="
266
379
  - !ruby/object:Gem::Version
267
- version: 3.1.1
380
+ version: 3.1.2
268
381
  type: :development
269
382
  prerelease: false
270
383
  version_requirements: !ruby/object:Gem::Requirement
@@ -274,7 +387,7 @@ dependencies:
274
387
  version: '3.1'
275
388
  - - ">="
276
389
  - !ruby/object:Gem::Version
277
- version: 3.1.1
390
+ version: 3.1.2
278
391
  - !ruby/object:Gem::Dependency
279
392
  name: kettle-test
280
393
  requirement: !ruby/object:Gem::Requirement
@@ -284,7 +397,7 @@ dependencies:
284
397
  version: '2.0'
285
398
  - - ">="
286
399
  - !ruby/object:Gem::Version
287
- version: 2.0.3
400
+ version: 2.0.5
288
401
  type: :development
289
402
  prerelease: false
290
403
  version_requirements: !ruby/object:Gem::Requirement
@@ -294,7 +407,7 @@ dependencies:
294
407
  version: '2.0'
295
408
  - - ">="
296
409
  - !ruby/object:Gem::Version
297
- version: 2.0.3
410
+ version: 2.0.5
298
411
  - !ruby/object:Gem::Dependency
299
412
  name: turbo_tests2
300
413
  requirement: !ruby/object:Gem::Requirement
@@ -304,7 +417,7 @@ dependencies:
304
417
  version: '3.1'
305
418
  - - ">="
306
419
  - !ruby/object:Gem::Version
307
- version: 3.1.1
420
+ version: 3.1.4
308
421
  type: :development
309
422
  prerelease: false
310
423
  version_requirements: !ruby/object:Gem::Requirement
@@ -314,7 +427,7 @@ dependencies:
314
427
  version: '3.1'
315
428
  - - ">="
316
429
  - !ruby/object:Gem::Version
317
- version: 3.1.1
430
+ version: 3.1.4
318
431
  - !ruby/object:Gem::Dependency
319
432
  name: ruby-progressbar
320
433
  requirement: !ruby/object:Gem::Requirement
@@ -358,7 +471,7 @@ dependencies:
358
471
  version: '2.0'
359
472
  - - ">="
360
473
  - !ruby/object:Gem::Version
361
- version: 2.0.1
474
+ version: 2.0.2
362
475
  type: :development
363
476
  prerelease: false
364
477
  version_requirements: !ruby/object:Gem::Requirement
@@ -368,7 +481,7 @@ dependencies:
368
481
  version: '2.0'
369
482
  - - ">="
370
483
  - !ruby/object:Gem::Version
371
- version: 2.0.1
484
+ version: 2.0.2
372
485
  - !ruby/object:Gem::Dependency
373
486
  name: addressable
374
487
  requirement: !ruby/object:Gem::Requirement
@@ -447,7 +560,6 @@ description: "\U0001F510 A Ruby wrapper for the OAuth 2.0 Authorization Framewor
447
560
  including the OAuth 2.1 draft spec, and OpenID Connect (OIDC)"
448
561
  email:
449
562
  - floss@galtzo.com
450
- - oauth-ruby@googlegroups.com
451
563
  executables: []
452
564
  extensions: []
453
565
  extra_rdoc_files:
@@ -502,10 +614,10 @@ licenses:
502
614
  - MIT
503
615
  metadata:
504
616
  homepage_uri: https://oauth2.galtzo.com
505
- source_code_uri: https://github.com/ruby-oauth/oauth2/tree/v2.0.22
506
- changelog_uri: https://github.com/ruby-oauth/oauth2/blob/v2.0.22/CHANGELOG.md
617
+ source_code_uri: https://github.com/ruby-oauth/oauth2/tree/v2.0.24
618
+ changelog_uri: https://github.com/ruby-oauth/oauth2/blob/v2.0.24/CHANGELOG.md
507
619
  bug_tracker_uri: https://github.com/ruby-oauth/oauth2/issues
508
- documentation_uri: https://www.rubydoc.info/gems/oauth2/2.0.22
620
+ documentation_uri: https://www.rubydoc.info/gems/oauth2/2.0.24
509
621
  funding_uri: https://github.com/sponsors/pboling
510
622
  wiki_uri: https://github.com/ruby-oauth/oauth2/wiki
511
623
  news_uri: https://www.railsbling.com/tags/oauth2
metadata.gz.sig CHANGED
Binary file