oauth 0.5.13 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -3
  3. data/CONTRIBUTING.md +1 -1
  4. data/LICENSE +2 -1
  5. data/README.md +66 -53
  6. data/SECURITY.md +9 -6
  7. data/bin/oauth +8 -4
  8. data/lib/oauth/cli/authorize_command.rb +58 -54
  9. data/lib/oauth/cli/base_command.rb +163 -159
  10. data/lib/oauth/cli/help_command.rb +9 -5
  11. data/lib/oauth/cli/query_command.rb +26 -17
  12. data/lib/oauth/cli/sign_command.rb +56 -52
  13. data/lib/oauth/cli/version_command.rb +8 -4
  14. data/lib/oauth/cli.rb +2 -0
  15. data/lib/oauth/client/action_controller_request.rb +4 -1
  16. data/lib/oauth/client/em_http.rb +4 -4
  17. data/lib/oauth/client/helper.rb +76 -72
  18. data/lib/oauth/client/net_http.rb +111 -104
  19. data/lib/oauth/client.rb +2 -0
  20. data/lib/oauth/consumer.rb +38 -28
  21. data/lib/oauth/errors/error.rb +2 -0
  22. data/lib/oauth/errors/problem.rb +3 -0
  23. data/lib/oauth/errors/unauthorized.rb +4 -0
  24. data/lib/oauth/errors.rb +2 -0
  25. data/lib/oauth/helper.rb +9 -5
  26. data/lib/oauth/oauth.rb +4 -2
  27. data/lib/oauth/oauth_test_helper.rb +2 -0
  28. data/lib/oauth/request_proxy/action_controller_request.rb +3 -24
  29. data/lib/oauth/request_proxy/base.rb +3 -3
  30. data/lib/oauth/request_proxy/mock_request.rb +1 -1
  31. data/lib/oauth/request_proxy/net_http.rb +5 -7
  32. data/lib/oauth/request_proxy/rest_client_request.rb +4 -3
  33. data/lib/oauth/request_proxy.rb +4 -1
  34. data/lib/oauth/server.rb +8 -4
  35. data/lib/oauth/signature/base.rb +71 -65
  36. data/lib/oauth/signature/hmac/sha1.rb +15 -9
  37. data/lib/oauth/signature/hmac/sha256.rb +15 -9
  38. data/lib/oauth/signature/plaintext.rb +18 -20
  39. data/lib/oauth/signature/rsa/sha1.rb +46 -38
  40. data/lib/oauth/signature.rb +3 -0
  41. data/lib/oauth/token.rb +2 -0
  42. data/lib/oauth/tokens/access_token.rb +2 -0
  43. data/lib/oauth/tokens/consumer_token.rb +2 -0
  44. data/lib/oauth/tokens/request_token.rb +5 -2
  45. data/lib/oauth/tokens/server_token.rb +2 -0
  46. data/lib/oauth/tokens/token.rb +2 -0
  47. data/lib/oauth/version.rb +5 -1
  48. data/lib/oauth.rb +8 -2
  49. metadata +32 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3272539ec7202df70017b1b16ccca115081d6a14a0aed0b6fdbee90565ad5b8
4
- data.tar.gz: 2c515938a4066d5f4b0ac0d064e106242f1362c615606c62794a5f39a97d44d2
3
+ metadata.gz: a742c9fad7615c19f25dc2b780f8811029314827b05f91bf803b2a4b92805e10
4
+ data.tar.gz: dda3f9afdca321d3613bc6344d71a4cfffa43e19c380f3d86325aeaed09cc388
5
5
  SHA512:
6
- metadata.gz: e071e35abc38d4140a9c2675080fba950d6bd643fff3aab0e80ec2dd8c5946c46e2956be9dd6f8c4dd9895c8b6f08b13e7f43cd8336f58e870230fcfd4931722
7
- data.tar.gz: 7eb464bb1e9db068903a6fac738d5126fc64688a7b670d931ba78a0283740cbb46329e07fc2895a4568516003bfddb72229d1c3c040165305bb307591a525da7
6
+ metadata.gz: 4abeba00e6da594572d2e74c974ac8658c947aa43fd9ea06f6e600df9a0b7b73d31bd8051cddab35749b8ed37346482c00653f29b9882d3b88a10d0716108403
7
+ data.tar.gz: cdd3b2015294fef30bd722804486c50dc1b19f566b6ae5ddc65e4ceb83e284439ff7059d9a6d5c098bb945122663223b0e383a3732f298b46a5bef1946aa9a39
data/CHANGELOG.md CHANGED
@@ -13,6 +13,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
13
 
14
14
  ### Removed
15
15
 
16
+ ## [1.0.0] 2022-08-23
17
+ ### Changed
18
+ * Dropped support for Ruby < 2.7
19
+
20
+ ### Added
21
+ * New EOL Policy
22
+ * Non-commercial support for the oldest version of Ruby (which itself is going EOL) will be dropped each year in April
23
+
24
+ ## [0.6.1] 2022-08-23
25
+ ### Changed
26
+ * Fixed documentation in SECURITY.md
27
+ * Change references to master => main
28
+
29
+ ### Added
30
+ * Post install note about v0.6.x EOL approaching in April, 2024
31
+
32
+ ## [0.6.0] 2022-08-23
33
+ ### Added
34
+ * New option `body_hash_enabled` which defaults to true to maintain backward compatibility with prior releases. Setting to `false` disables generation of a `oauth_body_hash` component as part of the signature computation.
35
+ * Improved documentation of support policy via Tidelift
36
+ * Stop testing against active_support v2
37
+
38
+ ### Changed
39
+ * Utilize version_gem extracted from oauth2 gem for VERSION
40
+ * Added new `OAuth::Version` namespace
41
+ * VERSION constant now at `OAuth::Version::VERSION`
42
+
43
+ ### Removed
44
+ * Ruby 2.0, 2.1, 2.2, and 2.3 are no longer valid install targets
45
+
16
46
  ## [0.5.13] 2022-08-23
17
47
  The "I think I caught 'em all!" Release
18
48
 
@@ -29,7 +59,7 @@ The "Typoes are just the worst!" Release
29
59
  The "Is this the last release with a silly name?" Release
30
60
 
31
61
  ### Added
32
- * Post install note about EOL approaching in April, 2023
62
+ * Post install note about v0.5.x EOL approaching in April, 2023
33
63
 
34
64
  ### Changed
35
65
  * Improved documentation
@@ -311,7 +341,7 @@ The "Can it be the end of the line for 0.5.x?" Release
311
341
 
312
342
  ## [0.3.4] 2009-05-06
313
343
  ### Changed
314
- * OAuth::Client::Helper uses OAuth::VERSION (chadisfaction)
344
+ * OAuth::Client::Helper uses OAuth::Version::VERSION (chadisfaction)
315
345
 
316
346
  ### Fixed
317
347
  * Fix OAuth::RequestProxy::ActionControllerRequest's handling of params (Tristan Groléat)
@@ -409,7 +439,10 @@ but please have a look at the unit tests.
409
439
  * Moved all non-Rails functionality from the Rails plugin:
410
440
  http://code.google.com/p/oauth-plugin/
411
441
 
412
- [Unreleased]: https://github.com/oauth-xx/oauth-ruby/compare/v0.5.13...v0.5-maintenance
442
+ [Unreleased]: https://github.com/oauth-xx/oauth-ruby/compare/v1.0.0...main
443
+ [1.0.0]: https://github.com/oauth-xx/oauth-ruby/releases/tag/v1.0.0
444
+ [0.6.1]: https://github.com/oauth-xx/oauth-ruby/releases/tag/v0.6.1
445
+ [0.6.0]: https://github.com/oauth-xx/oauth-ruby/releases/tag/v0.6.0
413
446
  [0.5.13]: https://github.com/oauth-xx/oauth-ruby/releases/tag/v0.5.13
414
447
  [0.5.12]: https://github.com/oauth-xx/oauth-ruby/releases/tag/v0.5.12
415
448
  [0.5.11]: https://github.com/oauth-xx/oauth-ruby/releases/tag/v0.5.11
data/CONTRIBUTING.md CHANGED
@@ -17,7 +17,7 @@ Made with [contributors-img][contrib-rocks].
17
17
  [comment]: <> (Following links are used by README, CONTRIBUTING, Homepage)
18
18
 
19
19
  [conduct]: https://github.com/oauth-xx/oauth-ruby/blob/main/CODE_OF_CONDUCT.md
20
- [contributing]: https://github.com/oauth-xx/oauth-ruby/blob/main/CONTRIBUTING.md
21
20
  [contributors]: https://github.com/oauth-xx/oauth-ruby/graphs/contributors
22
21
  [mailinglist]: http://groups.google.com/group/oauth-ruby
23
22
  [source]: https://github.com/oauth-xx/oauth-ruby/
23
+ [contrib-rocks]: https://contrib.rocks
data/LICENSE CHANGED
@@ -1,6 +1,7 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2007-2012, 2016-2017, 2020-2021 Blaine Cook, Larry Halff, Pelle Braendgaard, Peter Boling
3
+ Copyright (c) 2007-2012, 2016-2017 Blaine Cook, Larry Halff, Pelle Braendgaard
4
+ Copyright (c) 2020-2022 Peter Boling
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
7
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -20,11 +20,17 @@ See the sibling `oauth2` gem for OAuth 2.0 implementations in Ruby.
20
20
  [oauth1-spec]: http://oauth.net/core/1.0/
21
21
  [sibling-gem]: https://github.com/oauth-xx/oauth-ruby
22
22
 
23
- **NOTE**
23
+ **New EOL Policy**
24
24
 
25
- This README, on branch `v0.5-maintenance`, targets 0.5.x series releases.
26
- The v0.5.x series of releases will be EOL no later than April, 2023.
27
- For later releases please see the `main` branch README.
25
+ Versions 1.0.x will be EOL no later than April, 2025.
26
+ Versions 0.6.x will be EOL no later than April, 2024.
27
+ Versions 0.5.x will be EOL no later than April, 2023.
28
+
29
+ This will facilitate dropping support for old, dead, and crusty versions of Ruby.
30
+
31
+ Non-commercial support for the oldest version of Ruby (which itself is going EOL) will be dropped each year in April.
32
+
33
+ Please upgrade to version 1.0. The only breaking change in 1.0 is dropping old Rubies.
28
34
 
29
35
  ## Status
30
36
 
@@ -55,15 +61,15 @@ appended indicators:
55
61
  ♻️ - URL needs to be updated from SASS integration. Find / Replace is insufficient.
56
62
  -->
57
63
 
58
- | | Project | bundle add oauth |
59
- |:----|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
60
- | 1️⃣ | name, license, docs | [![RubyGems.org][⛳️name-img]][⛳️gem] [![License: MIT][🖇src-license-img]][🖇src-license] [![FOSSA][🏘fossa-img]][🏘fossa] [![RubyDoc.info][🚎yard-img]][🚎yard] [![InchCI][🖐inch-ci-img]][🚎yard] |
61
- | 2️⃣ | version & activity | [![Gem Version][⛳️version-img]][⛳️gem] [![Total Downloads][🖇DL-total-img]][⛳️gem] [![Download Rank][🏘DL-rank-img]][⛳️gem] [![Source Code][🚎src-home-img]][🚎src-home] [![Open PRs][🖐prs-o-img]][🖐prs-o] [![Closed PRs][🧮prs-c-img]][🧮prs-c] |
62
- | 3️⃣ | maintenance & linting | [![Maintainability][⛳cclim-maint-img♻️]][⛳cclim-maint] [![Helpers][🖇triage-help-img]][🖇triage-help] [![Depfu][🏘depfu-img♻️]][🏘depfu♻️] [![Contributors][🚎contributors-img]][🚎contributors] [![Style][🖐style-wf-img]][🖐style-wf] [![Kloc Roll][🧮kloc-img]][🧮kloc] |
63
- | 4️⃣ | testing | [![Open Issues][⛳iss-o-img]][⛳iss-o] [![Closed Issues][🖇iss-c-img]][🖇iss-c] [![Supported][🏘sup-wf-img]][🏘sup-wf] [![Heads][🚎heads-wf-img]][🚎heads-wf] [![Unofficial Support][🖐uns-wf-img]][🖐uns-wf] [![MacOS][🧮mac-wf-img]][🧮mac-wf] [![Windows][📗win-wf-img]][📗win-wf] |
64
- | 5️⃣ | coverage & security | [![CodeClimate][⛳cclim-cov-img♻️]][⛳cclim-cov] [![CodeCov][🖇codecov-img♻️]][🖇codecov] [![Coveralls][🏘coveralls-img]][🏘coveralls] [![Security Policy][🚎sec-pol-img]][🚎sec-pol] [![CodeQL][🖐codeQL-img]][🖐codeQL] [![Code Coverage][🧮cov-wf-img]][🧮cov-wf] |
65
- | 6️⃣ | resources | [![Discussion][⛳gh-discussions-img]][⛳gh-discussions] [![Get help on Codementor][🖇codementor-img]][🖇codementor] [![Chat][🏘chat-img]][🏘chat] [![Blog][🚎blog-img]][🚎blog] [![Blog][🖐wiki-img]][🖐wiki] |
66
- | 7️⃣ | spread 💖 | [![Liberapay Patrons][⛳liberapay-img]][⛳liberapay] [![Sponsor Me][🖇sponsor-img]][🖇sponsor] [![Tweet @ Peter][🏘tweet-img]][🏘tweet] [🌏][aboutme] [👼][angelme] [💻][coderme] |
64
+ | | Project | bundle add oauth |
65
+ |:----|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
66
+ | 1️⃣ | name, license, docs | [![RubyGems.org][⛳️name-img]][⛳️gem] [![License: MIT][🖇src-license-img]][🖇src-license] [![RubyDoc.info][🚎yard-img]][🚎yard] |
67
+ | 2️⃣ | version & activity | [![Gem Version][⛳️version-img]][⛳️gem] [![Total Downloads][🖇DL-total-img]][⛳️gem] [![Download Rank][🏘DL-rank-img]][⛳️gem] [![Source Code][🚎src-home-img]][🚎src-home] [![Open PRs][🖐prs-o-img]][🖐prs-o] [![Closed PRs][🧮prs-c-img]][🧮prs-c] <!--[![Next Version][📗next-img]][📗next]--> |
68
+ | 3️⃣ | maintenance & linting | [![Maintainability][⛳cclim-maint-img♻️]][⛳cclim-maint] [![Helpers][🖇triage-help-img]][🖇triage-help] [![Depfu][🏘depfu-img♻️]][🏘depfu♻️] [![Contributors][🚎contributors-img]][🚎contributors] [![Style][🖐style-wf-img]][🖐style-wf] [![Kloc Roll][🧮kloc-img]][🧮kloc] |
69
+ | 4️⃣ | testing | [![Open Issues][⛳iss-o-img]][⛳iss-o] [![Closed Issues][🖇iss-c-img]][🖇iss-c] [![Supported][🏘sup-wf-img]][🏘sup-wf] [![Heads][🚎heads-wf-img]][🚎heads-wf] [![MacOS][🧮mac-wf-img]][🧮mac-wf] [![Windows][📗win-wf-img]][📗win-wf] |
70
+ | 5️⃣ | coverage & security | [![CodeClimate][⛳cclim-cov-img♻️]][⛳cclim-cov] [![CodeCov][🖇codecov-img♻️]][🖇codecov] [![Coveralls][🏘coveralls-img]][🏘coveralls] [![Security Policy][🚎sec-pol-img]][🚎sec-pol] [![CodeQL][🖐codeQL-img]][🖐codeQL] [![Code Coverage][🧮cov-wf-img]][🧮cov-wf] |
71
+ | 6️⃣ | resources | [![Discussion][⛳gh-discussions-img]][⛳gh-discussions] [![Get help on Codementor][🖇codementor-img]][🖇codementor] [![Chat][🏘chat-img]][🏘chat] [![Blog][🚎blog-img]][🚎blog] [![Blog][🖐wiki-img]][🖐wiki] |
72
+ | 7️⃣ | spread 💖 | [![Liberapay Patrons][⛳liberapay-img]][⛳liberapay] [![Sponsor Me][🖇sponsor-img]][🖇sponsor] [![Tweet @ Peter][🏘tweet-img]][🏘tweet] [🌏][aboutme] [👼][angelme] [💻][coderme] |
67
73
 
68
74
  <!--
69
75
  The link tokens in the following sections should be kept ordered by the row and badge numbering scheme
@@ -74,11 +80,8 @@ The link tokens in the following sections should be kept ordered by the row and
74
80
  [⛳️name-img]: https://img.shields.io/badge/name-oauth-brightgreen.svg?style=flat
75
81
  [🖇src-license]: https://opensource.org/licenses/MIT
76
82
  [🖇src-license-img]: https://img.shields.io/badge/License-MIT-green.svg
77
- [🏘fossa]: https://app.fossa.io/projects/git%2Bgithub.com%2Foauth-xx%2Foauth-ruby?ref=badge_shield
78
- [🏘fossa-img]: https://app.fossa.io/api/projects/git%2Bgithub.com%2Foauth-xx%2Foauth-ruby.svg?type=shield
79
83
  [🚎yard]: https://www.rubydoc.info/github/oauth-xx/oauth-ruby
80
84
  [🚎yard-img]: https://img.shields.io/badge/documentation-rubydoc-brightgreen.svg?style=flat
81
- [🖐inch-ci-img]: http://inch-ci.org/github/oauth-xx/oauth-ruby.png
82
85
 
83
86
  <!-- 2️⃣ version & activity -->
84
87
  [⛳️version-img]: http://img.shields.io/gem/v/oauth.svg
@@ -116,8 +119,6 @@ The link tokens in the following sections should be kept ordered by the row and
116
119
  [🏘sup-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/supported.yml/badge.svg
117
120
  [🚎heads-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/heads.yml
118
121
  [🚎heads-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/heads.yml/badge.svg
119
- [🖐uns-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/unsupported.yml
120
- [🖐uns-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/unsupported.yml/badge.svg
121
122
  [🧮mac-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/macos.yml
122
123
  [🧮mac-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/macos.yml/badge.svg
123
124
  [📗win-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/windows.yml
@@ -187,12 +188,14 @@ For more see [SECURITY.md][🚎sec-pol].
187
188
  ## Compatibility
188
189
 
189
190
  Targeted ruby compatibility is non-EOL versions of Ruby, currently 2.7, 3.0, and
190
- 3.1. Ruby is limited to 2.0+ in the gemspec on this `v0.5-maintenance` branch.
191
+ 3.1. Ruby is limited to 2.7+ in the gemspec, and this will change with minor version bumps,
192
+ while the gem is still in 0.x, in accordance with the SemVer spec.
191
193
 
192
- The `v0.6-maintenance` branch targets 0.6.x releases.
193
- See `v0.5-maintenance` branch for older rubies.
194
+ The `main` branch now targets 1.0.x releases, for Ruby >= 2.7.
195
+ See `v0.6-maintenance` (EOL April, 2024) branch for Ruby >= 2.4.
196
+ See `v0.5-maintenance` (EOL April, 2023) branch for Ruby >= 2.0.
194
197
 
195
- NOTE: No further releases of the 0.5.x series are anticipated.
198
+ NOTE: No further releases of version < 1.0.x are anticipated.
196
199
 
197
200
  <details>
198
201
  <summary>Ruby Engine Compatibility Policy</summary>
@@ -222,17 +225,18 @@ fashion. If critical issues for a particular implementation exist at the time
222
225
  of a major release, support for that Ruby version may be dropped.
223
226
  </details>
224
227
 
225
- | | Ruby OAuth Version | Maintenance Branch | 🚂 Compatibility | Official 💎 | Unofficial 💎 | Incidental 💎 |
226
- |:----|--------------------|--------------------|------------------------|----------------------|-------------------------|---------------|
227
- | 1️⃣ | 1.0.x | `main` | Rails 6, 7 | 2.7, 3.0, 3.1 | sorry, not sorry | nope |
228
- | 2️⃣ | 0.6.x | `v0.6-maintenance` | Rails 5, 6, 7 | 2.7, 3.0, 3.1 | 2.5, 2.6 | 2.4 |
229
- | 3️⃣ | 0.5.x | `v0.5-maintenance` | Rails 2, 3, 4, 5, 6, 7 | 2.7, 3.0, 3.1 | 2.2, 2.3, 2.4, 2.5, 2.6 | 2.0, 2.1 |
230
- | 4️⃣ | older | N/A | | Best of luck to you! | Please upgrade! | noop |
228
+ | | Ruby OAuth Version | Maintenance Branch | EOL | 🚂 Compatibility | Official 💎 | Unofficial 💎 | Incidental 💎 |
229
+ |:----|--------------------|--------------------|-----------|------------------------|----------------------|------------------------------|---------------|
230
+ | 1️⃣ | 1.0.x | `main` | | Rails 6, 7 | 2.7, 3.0, 3.1 | sorry, not sorry | nope |
231
+ | 2️⃣ | 0.6.x | `v0.6-maintenance` | 04/2024 | Rails 5, 6, 7 | 2.7, 3.0, 3.1 | 2.5, 2.6 | 2.4 |
232
+ | 3️⃣ | 0.5.x | `v0.5-maintenance` | 04/2023 | Rails 2, 3, 4, 5, 6, 7 | 2.7, 3.0, 3.1 | 2.1, 2.2, 2.3, 2.4, 2.5, 2.6 | 2.0 |
233
+ | 4️⃣ | older | N/A | yesterday | | Best of luck to you! | Please upgrade! | noop |
231
234
 
232
- NOTE: Support for version 0.5.x will end in April, 2023
233
235
  NOTE: Once 1.0 is released, the 0.x series will only receive critical bug and security updates.
234
236
  See [SECURITY.md][🚎sec-pol]
235
237
 
238
+ 🚂 NOTE: See notes on Rails in next section.
239
+
236
240
  ## Basics
237
241
 
238
242
  This is a ruby library which is intended to be used in creating Ruby Consumer
@@ -257,38 +261,46 @@ callback_url = "http://127.0.0.1:3000/oauth/callback"
257
261
 
258
262
  Create a new `OAuth::Consumer` instance by passing it a configuration hash:
259
263
 
260
- oauth_consumer = OAuth::Consumer.new("key", "secret", :site => "https://agree2")
264
+ ```ruby
265
+ oauth_consumer = OAuth::Consumer.new("key", "secret", site: "https://agree2")
266
+ ```
261
267
 
262
268
  Start the process by requesting a token
263
269
 
264
- request_token = oauth_consumer.get_request_token(:oauth_callback => callback_url)
270
+ ```ruby
271
+ request_token = oauth_consumer.get_request_token(oauth_callback: callback_url)
265
272
 
266
- session[:token] = request_token.token
267
- session[:token_secret] = request_token.secret
268
- redirect_to request_token.authorize_url(:oauth_callback => callback_url)
273
+ session[:token] = request_token.token
274
+ session[:token_secret] = request_token.secret
275
+ redirect_to request_token.authorize_url(oauth_callback: callback_url)
276
+ ```
269
277
 
270
278
  When user returns create an access_token
271
279
 
272
- hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}
273
- request_token = OAuth::RequestToken.from_hash(oauth_consumer, hash)
274
- access_token = request_token.get_access_token
275
- # For 3-legged authorization, flow oauth_verifier is passed as param in callback
276
- # access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
277
- @photos = access_token.get('/photos.xml')
280
+ ```ruby
281
+ hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret] }
282
+ request_token = OAuth::RequestToken.from_hash(oauth_consumer, hash)
283
+ access_token = request_token.get_access_token
284
+ # For 3-legged authorization, flow oauth_verifier is passed as param in callback
285
+ # access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
286
+ @photos = access_token.get("/photos.xml")
287
+ ```
278
288
 
279
289
  Now that you have an access token, you can use Typhoeus to interact with the
280
290
  OAuth provider if you choose.
281
291
 
282
- require 'typhoeus'
283
- require 'oauth/request_proxy/typhoeus_request'
284
- oauth_params = {:consumer => oauth_consumer, :token => access_token}
285
- hydra = Typhoeus::Hydra.new
286
- req = Typhoeus::Request.new(uri, options) # :method needs to be specified in options
287
- oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri))
288
- req.options[:headers].merge!({"Authorization" => oauth_helper.header}) # Signs the request
289
- hydra.queue(req)
290
- hydra.run
291
- @response = req.response
292
+ ```ruby
293
+ require "typhoeus"
294
+ require "oauth/request_proxy/typhoeus_request"
295
+ oauth_params = { consumer: oauth_consumer, token: access_token }
296
+ hydra = Typhoeus::Hydra.new
297
+ req = Typhoeus::Request.new(uri, options) # :method needs to be specified in options
298
+ oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(request_uri: uri))
299
+ req.options[:headers]["Authorization"] = oauth_helper.header # Signs the request
300
+ hydra.queue(req)
301
+ hydra.run
302
+ @response = req.response
303
+ ```
292
304
 
293
305
  ## More Information
294
306
 
@@ -308,6 +320,8 @@ See [CONTRIBUTING.md][contributing]
308
320
 
309
321
  Made with [contributors-img][contrib-rocks].
310
322
 
323
+ [contrib-rocks]: https://contrib.rocks
324
+
311
325
  ## Versioning
312
326
 
313
327
  This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations of this scheme should be reported as
@@ -316,13 +330,12 @@ immediately released that restores compatibility. Breaking changes to the public
316
330
  major versions. Compatibility with a major and minor versions of Ruby will only be changed with a major version bump.
317
331
 
318
332
  As a result of this policy, you can (and should) specify a dependency on this gem using
319
- the [Pessimistic Version Constraint][pvc] with two digits of precision once it hits a 1.0 release.
320
- While on 0.x releases three digits of precision should be used.
333
+ the [Pessimistic Version Constraint][pvc] with two digits of precision.
321
334
 
322
335
  For example:
323
336
 
324
337
  ```ruby
325
- spec.add_dependency "oauth", "~> 0.5.10"
338
+ spec.add_dependency "oauth", "~> 1.0"
326
339
  ```
327
340
 
328
341
  ## License
data/SECURITY.md CHANGED
@@ -2,13 +2,16 @@
2
2
 
3
3
  ## Supported Versions
4
4
 
5
- | Version | Supported |
6
- |---------|--------------------|
7
- | 0.6.x | :white_check_mark: |
8
- | 0.5.x | :white_check_mark: |
9
- | <= 0.5 | :x: |
5
+ | Version | Supported | EOL |
6
+ |---------|--------------------|---------|
7
+ | 1.0.x | :white_check_mark: | 04/2025 |
8
+ | 0.6.x | :white_check_mark: | 04/2024 |
9
+ | 0.5.x | :white_check_mark: | 04/2023 |
10
+ | <= 0.5 | :x: | :x: |
10
11
 
11
- NOTE: Support for version 0.5.x will end in April, 2023
12
+ ### EOL Policy
13
+
14
+ Non-commercial support for the oldest version of Ruby (which itself is going EOL) will be dropped each year in April.
12
15
 
13
16
  ## Reporting a Vulnerability
14
17
 
data/bin/oauth CHANGED
@@ -1,11 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require_relative "../lib/oauth"
4
+ require "oauth"
4
5
  require "oauth/cli"
5
6
 
6
- Signal.trap("INT") { puts; exit(1) } # don't dump a backtrace on a ^C
7
-
7
+ # don't dump a backtrace on a ^C
8
+ Signal.trap("INT") do
9
+ puts
10
+ exit(1)
11
+ end
8
12
  ARGV << "help" if ARGV.empty?
9
13
  command = ARGV.shift
10
14
 
11
- OAuth::CLI.new(STDOUT, STDIN, STDERR, command, ARGV).run
15
+ OAuth::CLI.new($stdout, $stdin, $stderr, command, ARGV).run
@@ -1,69 +1,73 @@
1
- class OAuth::CLI
2
- class AuthorizeCommand < BaseCommand
3
- def required_options
4
- [:uri]
5
- end
6
-
7
- def _run
8
- request_token = get_request_token
1
+ # frozen_string_literal: true
9
2
 
10
- if request_token.callback_confirmed?
11
- puts "Server appears to support OAuth 1.0a; enabling support."
12
- options[:version] = "1.0a"
3
+ module OAuth
4
+ class CLI
5
+ class AuthorizeCommand < BaseCommand
6
+ def required_options
7
+ [:uri]
13
8
  end
14
9
 
15
- puts "Please visit this url to authorize:"
16
- puts request_token.authorize_url
10
+ def _run
11
+ request_token = get_request_token
17
12
 
18
- # parameters for OAuth 1.0a
19
- oauth_verifier = ask_user_for_verifier
13
+ if request_token.callback_confirmed?
14
+ puts "Server appears to support OAuth 1.0a; enabling support."
15
+ options[:version] = "1.0a"
16
+ end
20
17
 
21
- verbosely_get_access_token(request_token, oauth_verifier)
22
- end
18
+ puts "Please visit this url to authorize:"
19
+ puts request_token.authorize_url
23
20
 
24
- def get_request_token
25
- consumer = get_consumer
26
- scope_options = options[:scope] ? { "scope" => options[:scope] } : {}
27
- consumer.get_request_token({ oauth_callback: options[:oauth_callback] }, scope_options)
28
- rescue OAuth::Unauthorized => e
29
- alert "A problem occurred while attempting to authorize:"
30
- alert e
31
- alert e.request.body
32
- end
21
+ # parameters for OAuth 1.0a
22
+ oauth_verifier = ask_user_for_verifier
33
23
 
34
- def get_consumer
35
- OAuth::Consumer.new \
36
- options[:oauth_consumer_key],
37
- options[:oauth_consumer_secret],
38
- access_token_url: options[:access_token_url],
39
- authorize_url: options[:authorize_url],
40
- request_token_url: options[:request_token_url],
41
- scheme: options[:scheme],
42
- http_method: options[:method].to_s.downcase.to_sym
43
- end
24
+ verbosely_get_access_token(request_token, oauth_verifier)
25
+ end
44
26
 
45
- def ask_user_for_verifier
46
- if options[:version] == "1.0a"
47
- puts "Please enter the verification code provided by the SP (oauth_verifier):"
48
- @stdin.gets.chomp
49
- else
50
- puts "Press return to continue..."
51
- @stdin.gets
52
- nil
27
+ def get_request_token
28
+ consumer = get_consumer
29
+ scope_options = options[:scope] ? { "scope" => options[:scope] } : {}
30
+ consumer.get_request_token({ oauth_callback: options[:oauth_callback] }, scope_options)
31
+ rescue OAuth::Unauthorized => e
32
+ alert "A problem occurred while attempting to authorize:"
33
+ alert e
34
+ alert e.request.body
35
+ end
36
+
37
+ def get_consumer
38
+ OAuth::Consumer.new \
39
+ options[:oauth_consumer_key],
40
+ options[:oauth_consumer_secret],
41
+ access_token_url: options[:access_token_url],
42
+ authorize_url: options[:authorize_url],
43
+ request_token_url: options[:request_token_url],
44
+ scheme: options[:scheme],
45
+ http_method: options[:method].to_s.downcase.to_sym
46
+ end
47
+
48
+ def ask_user_for_verifier
49
+ if options[:version] == "1.0a"
50
+ puts "Please enter the verification code provided by the SP (oauth_verifier):"
51
+ @stdin.gets.chomp
52
+ else
53
+ puts "Press return to continue..."
54
+ @stdin.gets
55
+ nil
56
+ end
53
57
  end
54
- end
55
58
 
56
- def verbosely_get_access_token(request_token, oauth_verifier)
57
- access_token = request_token.get_access_token(oauth_verifier: oauth_verifier)
59
+ def verbosely_get_access_token(request_token, oauth_verifier)
60
+ access_token = request_token.get_access_token(oauth_verifier: oauth_verifier)
58
61
 
59
- puts "Response:"
60
- access_token.params.each do |k, v|
61
- puts " #{k}: #{v}" unless k.is_a?(Symbol)
62
+ puts "Response:"
63
+ access_token.params.each do |k, v|
64
+ puts " #{k}: #{v}" unless k.is_a?(Symbol)
65
+ end
66
+ rescue OAuth::Unauthorized => e
67
+ alert "A problem occurred while attempting to obtain an access token:"
68
+ alert e
69
+ alert e.request.body
62
70
  end
63
- rescue OAuth::Unauthorized => e
64
- alert "A problem occurred while attempting to obtain an access token:"
65
- alert e
66
- alert e.request.body
67
71
  end
68
72
  end
69
73
  end