oauth 0.5.8 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +136 -115
  3. data/CODE_OF_CONDUCT.md +0 -0
  4. data/CONTRIBUTING.md +19 -2
  5. data/LICENSE +2 -1
  6. data/README.md +267 -67
  7. data/SECURITY.md +18 -8
  8. data/TODO +0 -0
  9. data/lib/oauth/client/action_controller_request.rb +17 -15
  10. data/lib/oauth/client/em_http.rb +30 -30
  11. data/lib/oauth/client/helper.rb +76 -75
  12. data/lib/oauth/client/net_http.rb +109 -102
  13. data/lib/oauth/client.rb +2 -0
  14. data/lib/oauth/consumer.rb +113 -110
  15. data/lib/oauth/errors/error.rb +2 -0
  16. data/lib/oauth/errors/problem.rb +3 -0
  17. data/lib/oauth/errors/unauthorized.rb +4 -0
  18. data/lib/oauth/errors.rb +2 -0
  19. data/lib/oauth/helper.rb +16 -12
  20. data/lib/oauth/oauth.rb +6 -4
  21. data/lib/oauth/oauth_test_helper.rb +2 -0
  22. data/lib/oauth/request_proxy/action_controller_request.rb +3 -24
  23. data/lib/oauth/request_proxy/action_dispatch_request.rb +0 -0
  24. data/lib/oauth/request_proxy/base.rb +2 -2
  25. data/lib/oauth/request_proxy/curb_request.rb +0 -0
  26. data/lib/oauth/request_proxy/em_http_request.rb +0 -0
  27. data/lib/oauth/request_proxy/jabber_request.rb +0 -0
  28. data/lib/oauth/request_proxy/mock_request.rb +1 -1
  29. data/lib/oauth/request_proxy/net_http.rb +5 -7
  30. data/lib/oauth/request_proxy/rack_request.rb +0 -0
  31. data/lib/oauth/request_proxy/rest_client_request.rb +2 -1
  32. data/lib/oauth/request_proxy/typhoeus_request.rb +0 -0
  33. data/lib/oauth/request_proxy.rb +7 -4
  34. data/lib/oauth/server.rb +12 -10
  35. data/lib/oauth/signature/base.rb +71 -66
  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 +8 -5
  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 +4 -2
  44. data/lib/oauth/tokens/request_token.rb +12 -10
  45. data/lib/oauth/tokens/server_token.rb +2 -1
  46. data/lib/oauth/tokens/token.rb +2 -0
  47. data/lib/oauth/version.rb +5 -1
  48. data/lib/oauth.rb +9 -2
  49. metadata +87 -35
  50. data/bin/oauth +0 -11
  51. data/lib/oauth/cli/authorize_command.rb +0 -71
  52. data/lib/oauth/cli/base_command.rb +0 -208
  53. data/lib/oauth/cli/help_command.rb +0 -22
  54. data/lib/oauth/cli/query_command.rb +0 -25
  55. data/lib/oauth/cli/sign_command.rb +0 -81
  56. data/lib/oauth/cli/version_command.rb +0 -7
  57. data/lib/oauth/cli.rb +0 -56
data/README.md CHANGED
@@ -1,59 +1,241 @@
1
+ <p align="center">
2
+ <a href="http://oauth.net/core/1.0/" target="_blank" rel="noopener">
3
+ <img width="124px" src="https://github.com/oauth-xx/oauth-ruby/raw/main/docs/images/logo/Oauth_logo.svg?raw=true" alt="OAuth 1.0 Logo by Chris Messina, CC BY-SA 3.0, via Wikimedia Commons">
4
+ </a>
5
+ <a href="https://www.ruby-lang.org/" target="_blank" rel="noopener">
6
+ <img width="124px" src="https://github.com/oauth-xx/oauth-ruby/raw/main/docs/images/logo/ruby-logo-198px.svg?raw=true" alt="Yukihiro Matsumoto, Ruby Visual Identity Team, CC BY-SA 2.5">
7
+ </a>
8
+ </p>
9
+
1
10
  # Ruby OAuth
2
11
 
3
- **NOTE**
12
+ OAuth 1.0 is an industry-standard protocol for authorization.
4
13
 
5
- This README, on branch `v0.5-maintenance`, targets 0.5.x series releases. For later releases please see the `msater` branch README.
14
+ This is a RubyGem for implementing both OAuth 1.0 clients and servers in Ruby applications.
15
+ See the sibling `oauth2` gem for OAuth 2.0 implementations in Ruby.
6
16
 
7
- ## Status
17
+ * [OAuth 1.0 Spec][oauth1-spec]
18
+ * [oauth2 sibling gem][sibling-gem] for OAuth 2.0 implementations in Ruby.
8
19
 
9
- | Project | Ruby Oauth |
10
- |--------------------------- |--------------------------- |
11
- | name, license, docs | [![RubyGems.org](https://img.shields.io/badge/name-oauth-brightgreen.svg?style=flat)][rubygems] [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)][license-ref] [![RubyDoc.info](https://img.shields.io/badge/documentation-rubydoc-brightgreen.svg?style=flat)][documentation] |
12
- | version & downloads | [![Version](https://img.shields.io/gem/v/oauth.svg)][rubygems] [![Total Downloads](https://img.shields.io/gem/dt/oauth.svg)][rubygems] [![Downloads Today](https://img.shields.io/gem/rd/oauth.svg)][rubygems] [![Homepage](https://img.shields.io/badge/source-github-brightgreen.svg?style=flat)][source] |
13
- | dependencies & linting | [![Depfu](https://badges.depfu.com/badges/d570491bac0ad3b0b65deb3c82028327/count.svg)][depfu] [![lint status](https://github.com/oauth-xx/oauth-ruby/actions/workflows/style.yml/badge.svg)][actions] |
14
- | unit tests | [![supported rubies](https://github.com/oauth-xx/oauth-ruby/actions/workflows/supported.yml/badge.svg)][actions] [![unsupported status](https://github.com/oauth-xx/oauth-ruby/actions/workflows/unsupported.yml/badge.svg)][actions] |
15
- | coverage & maintainability | [![Test Coverage](https://api.codeclimate.com/v1/badges/3cf23270c21e8791d788/test_coverage)][climate_coverage] [![codecov](https://codecov.io/gh/oauth-xx/oauth-ruby/branch/master/graph/badge.svg?token=4ZNAWNxrf9)][codecov_coverage] [![Maintainability](https://api.codeclimate.com/v1/badges/3cf23270c21e8791d788/maintainability)][climate_maintainability] [![Maintenance Policy](https://img.shields.io/badge/maintenance-policy-brightgreen.svg?style=flat)][security] |
16
- | resources | [![Discussion](https://img.shields.io/badge/discussions-github-brightgreen.svg?style=flat)][gh_discussions] [![Mailing List](https://img.shields.io/badge/group-mailinglist.svg?style=social&logo=google)][mailinglist] [![Join the chat at https://gitter.im/oauth-xx/oauth-ruby](https://badges.gitter.im/Join%20Chat.svg)][chat] [![Blog](https://img.shields.io/badge/blog-railsbling-brightgreen.svg?style=flat)][blogpage] |
17
- | Spread ~♡ⓛⓞⓥⓔ♡~ | [![Open Source Helpers](https://www.codetriage.com/oauth-xx/oauth-ruby/badges/users.svg)][code_triage] [![Liberapay Patrons](https://img.shields.io/liberapay/patrons/pboling.svg?logo=liberapay)][liberapay_donate] [![Sponsor Me](https://img.shields.io/badge/sponsor-pboling.svg?style=social&logo=github)][gh_sponsors] [🌏][aboutme] [👼][angelme] [💻][coderme] [🌹][politicme] [![Tweet @ Peter][followme-img]][tweetme] |
20
+ [oauth1-spec]: http://oauth.net/core/1.0/
21
+ [sibling-gem]: https://github.com/oauth-xx/oauth-ruby
18
22
 
19
- ## What
23
+ **New EOL Policy**
20
24
 
21
- This is a RubyGem for implementing both OAuth 1.0 clients and servers in Ruby
22
- applications.
25
+ Versions 1.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.
23
28
 
24
- See the OAuth 1.0 spec http://oauth.net/core/1.0/
29
+ This will facilitate dropping support for old, dead, and crusty versions of Ruby.
25
30
 
26
- See the sibling gem [oauth2](https://github.com/oauth-xx/oauth2) for OAuth 2.0 implementations in Ruby.
31
+ Non-commercial support for the oldest version of Ruby (which itself is going EOL) will be dropped each year in April.
27
32
 
28
- ## Installation
33
+ Please upgrade to version 1.1. The only breaking change in 1.x is dropping old Rubies.
29
34
 
30
- Add this line to your application's Gemfile:
35
+ ## Status
31
36
 
32
- ```ruby
33
- gem "oauth"
34
- ```
37
+ <!--
38
+ Numbering rows and badges in each row as a visual "database" lookup,
39
+ as the table is extremely dense, and it can be very difficult to find anything
40
+ Putting one on each row here, to document the emoji that should be used, and for ease of copy/paste.
41
+
42
+ row #s:
43
+ 1️⃣
44
+ 2️⃣
45
+ 3️⃣
46
+ 4️⃣
47
+ 5️⃣
48
+ 6️⃣
49
+ 7️⃣
50
+
51
+ badge #s:
52
+ ⛳️
53
+ 🖇
54
+ 🏘
55
+ 🚎
56
+ 🖐
57
+ 🧮
58
+ 📗
59
+
60
+ appended indicators:
61
+ ♻️ - URL needs to be updated from SASS integration. Find / Replace is insufficient.
62
+ -->
63
+
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] |
73
+
74
+ <!--
75
+ The link tokens in the following sections should be kept ordered by the row and badge numbering scheme
76
+ -->
77
+
78
+ <!-- 1️⃣ name, license, docs -->
79
+ [⛳️gem]: https://rubygems.org/gems/oauth
80
+ [⛳️name-img]: https://img.shields.io/badge/name-oauth-brightgreen.svg?style=flat
81
+ [🖇src-license]: https://opensource.org/licenses/MIT
82
+ [🖇src-license-img]: https://img.shields.io/badge/License-MIT-green.svg
83
+ [🚎yard]: https://www.rubydoc.info/github/oauth-xx/oauth-ruby
84
+ [🚎yard-img]: https://img.shields.io/badge/documentation-rubydoc-brightgreen.svg?style=flat
85
+
86
+ <!-- 2️⃣ version & activity -->
87
+ [⛳️version-img]: http://img.shields.io/gem/v/oauth.svg
88
+ [🖇DL-total-img]: https://img.shields.io/gem/dt/oauth.svg
89
+ [🏘DL-rank-img]: https://img.shields.io/gem/rt/oauth.svg
90
+ [🚎src-home]: https://github.com/oauth-xx/oauth-ruby
91
+ [🚎src-home-img]: https://img.shields.io/badge/source-github-brightgreen.svg?style=flat
92
+ [🖐prs-o]: https://github.com/oauth-xx/oauth-ruby/pulls
93
+ [🖐prs-o-img]: https://img.shields.io/github/issues-pr/oauth-xx/oauth-ruby
94
+ [🧮prs-c]: https://github.com/oauth-xx/oauth-ruby/pulls?q=is%3Apr+is%3Aclosed
95
+ [🧮prs-c-img]: https://img.shields.io/github/issues-pr-closed/oauth-xx/oauth-ruby
96
+ [📗next]: https://github.com/oauth-xx/oauth-ruby/milestone/1
97
+ [📗next-img]: https://img.shields.io/github/milestones/progress/oauth-xx/oauth-ruby/1?label=Next%20Version
98
+
99
+ <!-- 3️⃣ maintanence & linting -->
100
+ [⛳cclim-maint]: https://codeclimate.com/github/oauth-xx/oauth-ruby/maintainability
101
+ [⛳cclim-maint-img♻️]: https://api.codeclimate.com/v1/badges/3cf23270c21e8791d788/maintainability
102
+ [🖇triage-help]: https://www.codetriage.com/oauth-xx/oauth-ruby
103
+ [🖇triage-help-img]: https://www.codetriage.com/oauth-xx/oauth-ruby/badges/users.svg
104
+ [🏘depfu♻️]: https://depfu.com/github/oauth-xx/oauth-ruby?project_id=22868
105
+ [🏘depfu-img♻️]: https://badges.depfu.com/badges/d570491bac0ad3b0b65deb3c82028327/count.svg
106
+ [🚎contributors]: https://github.com/oauth-xx/oauth-ruby/graphs/contributors
107
+ [🚎contributors-img]: https://img.shields.io/github/contributors-anon/oauth-xx/oauth-ruby
108
+ [🖐style-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/style.yml
109
+ [🖐style-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/style.yml/badge.svg
110
+ [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
111
+ [🧮kloc-img]: https://img.shields.io/tokei/lines/github.com/oauth-xx/oauth-ruby
112
+
113
+ <!-- 4️⃣ testing -->
114
+ [⛳iss-o]: https://github.com/oauth-xx/oauth-ruby/issues
115
+ [⛳iss-o-img]: https://img.shields.io/github/issues-raw/oauth-xx/oauth-ruby
116
+ [🖇iss-c]: https://github.com/oauth-xx/oauth-ruby/issues?q=is%3Aissue+is%3Aclosed
117
+ [🖇iss-c-img]: https://img.shields.io/github/issues-closed-raw/oauth-xx/oauth-ruby
118
+ [🏘sup-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/supported.yml
119
+ [🏘sup-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/supported.yml/badge.svg
120
+ [🚎heads-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/heads.yml
121
+ [🚎heads-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/heads.yml/badge.svg
122
+ [🧮mac-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/macos.yml
123
+ [🧮mac-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/macos.yml/badge.svg
124
+ [📗win-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/windows.yml
125
+ [📗win-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/windows.yml/badge.svg
126
+
127
+ <!-- 5️⃣ coverage & security -->
128
+ [⛳cclim-cov]: https://codeclimate.com/github/oauth-xx/oauth-ruby/test_coverage
129
+ [⛳cclim-cov-img♻️]: https://api.codeclimate.com/v1/badges/3cf23270c21e8791d788/test_coverage
130
+ [🖇codecov-img♻️]: https://codecov.io/gh/oauth-xx/oauth-ruby/branch/main/graph/badge.svg?token=4ZNAWNxrf9
131
+ [🖇codecov]: https://codecov.io/gh/oauth-xx/oauth-ruby
132
+ [🏘coveralls]: https://coveralls.io/github/oauth-xx/oauth-ruby?branch=main
133
+ [🏘coveralls-img]: https://coveralls.io/repos/github/oauth-xx/oauth-ruby/badge.svg?branch=main
134
+ [🚎sec-pol]: https://github.com/oauth-xx/oauth-ruby/blob/main/SECURITY.md
135
+ [🚎sec-pol-img]: https://img.shields.io/badge/security-policy-brightgreen.svg?style=flat
136
+ [🖐codeQL]: https://github.com/oauth-xx/oauth-ruby/security/code-scanning
137
+ [🖐codeQL-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/codeql-analysis.yml/badge.svg
138
+ [🧮cov-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/coverage.yml
139
+ [🧮cov-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/coverage.yml/badge.svg
140
+
141
+ <!-- 6️⃣ resources -->
142
+ [⛳gh-discussions]: https://github.com/oauth-xx/oauth-ruby/discussions
143
+ [⛳gh-discussions-img]: https://img.shields.io/github/discussions/oauth-xx/oauth-ruby
144
+ [🖇codementor]: https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github
145
+ [🖇codementor-img]: https://cdn.codementor.io/badges/get_help_github.svg
146
+ [🏘chat]: https://gitter.im/oauth-xx/oauth-ruby
147
+ [🏘chat-img]: https://img.shields.io/gitter/room/oauth-xx/oauth-ruby.svg
148
+ [🚎blog]: http://www.railsbling.com/tags/oauth-ruby/
149
+ [🚎blog-img]: https://img.shields.io/badge/blog-railsbling-brightgreen.svg?style=flat
150
+ [🖐wiki]: https://github.com/oauth-xx/oauth-ruby/wiki
151
+ [🖐wiki-img]: https://img.shields.io/badge/wiki-examples-brightgreen.svg?style=flat
152
+
153
+ <!-- 7️⃣ spread 💖 -->
154
+ [⛳liberapay-img]: https://img.shields.io/liberapay/patrons/pboling.svg?logo=liberapay
155
+ [⛳liberapay]: https://liberapay.com/pboling/donate
156
+ [🖇sponsor-img]: https://img.shields.io/badge/sponsor-pboling.svg?style=social&logo=github
157
+ [🖇sponsor]: https://github.com/sponsors/pboling
158
+ [🏘tweet-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow
159
+ [🏘tweet]: http://twitter.com/galtzo
160
+
161
+ <!-- Maintainer Contact Links -->
162
+ [railsbling]: http://www.railsbling.com
163
+ [peterboling]: http://www.peterboling.com
164
+
165
+ ## Installation
35
166
 
36
- And then execute:
167
+ Install the gem and add to the application's Gemfile by executing:
37
168
 
38
- $ bundle install
169
+ $ bundle add oauth
39
170
 
40
- Or install it yourself as:
171
+ If bundler is not being used to manage dependencies, install the gem by executing:
41
172
 
42
173
  $ gem install oauth
43
174
 
175
+ ## OAuth for Enterprise
176
+
177
+ Available as part of the Tidelift Subscription.
178
+
179
+ The maintainers of OAuth2 and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. [Learn more.](https://tidelift.com/subscription/pkg/rubygems-oauth?utm_source=rubygems-oauth&utm_medium=referral&utm_campaign=enterprise)
180
+
181
+ ## Security contact information [![Security Policy][🚎sec-pol-img]][🚎sec-pol]
182
+
183
+ To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
184
+ Tidelift will coordinate the fix and disclosure.
185
+
186
+ For more see [SECURITY.md][🚎sec-pol].
187
+
44
188
  ## Compatibility
45
189
 
46
- Targeted ruby compatibility is non-EOL versions of Ruby, currently 2.6, 2.7, and
47
- 3.0. Ruby is limited to 2.0+ in the gemspec, and this may change while the gem is
48
- still at version 0.x. The `master` branch currently targets 0.6.x releases.
190
+ Targeted ruby compatibility is non-EOL versions of Ruby, currently 2.7, 3.0, and
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.
193
+
194
+ The `main` branch now targets 1.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.
197
+
198
+ NOTE: No further releases of version < 1.0.x are anticipated.
199
+
200
+ <details>
201
+ <summary>Ruby Engine Compatibility Policy</summary>
202
+
203
+ This gem is tested against MRI, and to a lesser extent, against JRuby, and Truffleruby.
204
+ Each of those has varying versions that target a specific version of MRI Ruby.
205
+ This gem should work in the just-listed Ruby engines according to the targeted MRI compatibility in the table below.
206
+ If you would like to add support for additional engines,
207
+ first make sure Github Actions supports the engine,
208
+ then submit a PR to the correct maintenance branch as according to the table below.
209
+ </details>
210
+
211
+ <details>
212
+ <summary>Ruby Version Compatibility Policy</summary>
49
213
 
50
- | Ruby OAuth Version | Maintenance Branch | Officially Supported Rubies | Unofficially Supported Rubies |
51
- |--------------------- | ------------------ | ------------------------------------------- | ----------------------------- |
52
- | 0.7.x (hypothetical) | N/A | 2.7, 3.0, 3.1 | 2.6 |
53
- | 0.6.x | `master` | 2.6, 2.7, 3.0 | 2.3, 2.4, 2.5 |
54
- | 0.5.x | `v0.5-maintenance` | 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0 | |
214
+ If something doesn't work on one of these interpreters, it's a bug.
55
215
 
56
- NOTE: 0.5.7 is anticipated as last release of the 0.5.x series.
216
+ This library may inadvertently work (or seem to work) on other Ruby
217
+ implementations, however support will only be provided for the versions listed
218
+ above.
219
+
220
+ If you would like this library to support another Ruby version, you may
221
+ volunteer to be a maintainer. Being a maintainer entails making sure all tests
222
+ run and pass on that implementation. When something breaks on your
223
+ implementation, you will be responsible for providing patches in a timely
224
+ fashion. If critical issues for a particular implementation exist at the time
225
+ of a major release, support for that Ruby version may be dropped.
226
+ </details>
227
+
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 |
234
+
235
+ NOTE: Once 1.0 is released, the 0.x series will only receive critical bug and security updates.
236
+ See [SECURITY.md][🚎sec-pol]
237
+
238
+ 🚂 NOTE: See notes on Rails in next section.
57
239
 
58
240
  ## Basics
59
241
 
@@ -61,51 +243,68 @@ This is a ruby library which is intended to be used in creating Ruby Consumer
61
243
  and Service Provider applications. It is NOT a Rails plugin, but could easily
62
244
  be used for the foundation for such a Rails plugin.
63
245
 
64
- As a matter of fact it has been pulled out from an OAuth Rails GEM
65
- (https://rubygems.org/gems/oauth-plugin https://github.com/pelle/oauth-plugin)
66
- which now uses this gem as a dependency.
246
+ This gem was originally extracted from @pelle's [oauth-plugin](https://github.com/pelle/oauth-plugin)
247
+ gem. After extraction that gem was made to depend on this gem.
248
+
249
+ Unfortunately, this gem does have some Rails related bits that are
250
+ **optional** to load. You don't need Rails! The Rails bits may be pulled out
251
+ into a separate gem with the 1.x minor updates of this gem.
252
+
253
+ ## Extensions
254
+
255
+ * [oauth-tty (on Gitlab)](https://gitlab.com/oauth-xx/oauth-tty) ([rubygems.org](https://rubygems.org/gems/oauth-tty))
67
256
 
68
257
  ## Usage
69
258
 
70
- We need to specify the oauth_callback url explicitly, otherwise it defaults to
259
+ We need to specify the `oauth_callback` url explicitly, otherwise it defaults to
71
260
  "oob" (Out of Band)
72
261
 
73
- callback_url = "http://127.0.0.1:3000/oauth/callback"
262
+ ```ruby
263
+ callback_url = "http://127.0.0.1:3000/oauth/callback"
264
+ ```
74
265
 
75
266
  Create a new `OAuth::Consumer` instance by passing it a configuration hash:
76
267
 
77
- oauth_consumer = OAuth::Consumer.new("key", "secret", :site => "https://agree2")
268
+ ```ruby
269
+ oauth_consumer = OAuth::Consumer.new("key", "secret", site: "https://agree2")
270
+ ```
78
271
 
79
272
  Start the process by requesting a token
80
273
 
81
- request_token = oauth_consumer.get_request_token(:oauth_callback => callback_url)
274
+ ```ruby
275
+ request_token = oauth_consumer.get_request_token(oauth_callback: callback_url)
82
276
 
83
- session[:token] = request_token.token
84
- session[:token_secret] = request_token.secret
85
- redirect_to request_token.authorize_url(:oauth_callback => callback_url)
277
+ session[:token] = request_token.token
278
+ session[:token_secret] = request_token.secret
279
+ redirect_to request_token.authorize_url(oauth_callback: callback_url)
280
+ ```
86
281
 
87
282
  When user returns create an access_token
88
283
 
89
- hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}
90
- request_token = OAuth::RequestToken.from_hash(oauth_consumer, hash)
91
- access_token = request_token.get_access_token
92
- # For 3-legged authorization, flow oauth_verifier is passed as param in callback
93
- # access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
94
- @photos = access_token.get('/photos.xml')
284
+ ```ruby
285
+ hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret] }
286
+ request_token = OAuth::RequestToken.from_hash(oauth_consumer, hash)
287
+ access_token = request_token.get_access_token
288
+ # For 3-legged authorization, flow oauth_verifier is passed as param in callback
289
+ # access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
290
+ @photos = access_token.get("/photos.xml")
291
+ ```
95
292
 
96
293
  Now that you have an access token, you can use Typhoeus to interact with the
97
294
  OAuth provider if you choose.
98
295
 
99
- require 'typhoeus'
100
- require 'oauth/request_proxy/typhoeus_request'
101
- oauth_params = {:consumer => oauth_consumer, :token => access_token}
102
- hydra = Typhoeus::Hydra.new
103
- req = Typhoeus::Request.new(uri, options) # :method needs to be specified in options
104
- oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri))
105
- req.options[:headers].merge!({"Authorization" => oauth_helper.header}) # Signs the request
106
- hydra.queue(req)
107
- hydra.run
108
- @response = req.response
296
+ ```ruby
297
+ require "typhoeus"
298
+ require "oauth/request_proxy/typhoeus_request"
299
+ oauth_params = { consumer: oauth_consumer, token: access_token }
300
+ hydra = Typhoeus::Hydra.new
301
+ req = Typhoeus::Request.new(uri, options) # :method needs to be specified in options
302
+ oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(request_uri: uri))
303
+ req.options[:headers]["Authorization"] = oauth_helper.header # Signs the request
304
+ hydra.queue(req)
305
+ hydra.run
306
+ @response = req.response
307
+ ```
109
308
 
110
309
  ## More Information
111
310
 
@@ -125,12 +324,14 @@ See [CONTRIBUTING.md][contributing]
125
324
 
126
325
  Made with [contributors-img][contrib-rocks].
127
326
 
327
+ [contrib-rocks]: https://contrib.rocks
328
+
128
329
  ## Versioning
129
330
 
130
331
  This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations of this scheme should be reported as
131
332
  bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be
132
333
  immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new
133
- major versions.
334
+ major versions. Compatibility with a major and minor versions of Ruby will only be changed with a major version bump.
134
335
 
135
336
  As a result of this policy, you can (and should) specify a dependency on this gem using
136
337
  the [Pessimistic Version Constraint][pvc] with two digits of precision.
@@ -138,7 +339,7 @@ the [Pessimistic Version Constraint][pvc] with two digits of precision.
138
339
  For example:
139
340
 
140
341
  ```ruby
141
- spec.add_dependency "oauth", "~> 0.5"
342
+ spec.add_dependency "oauth", "~> 1.1"
142
343
  ```
143
344
 
144
345
  ## License
@@ -156,8 +357,8 @@ Comments are welcome. Contact the [OAuth Ruby mailing list (Google Group)][maili
156
357
 
157
358
  [comment]: <> (Following links are used by README, CONTRIBUTING, Homepage)
158
359
 
159
- [conduct]: https://github.com/oauth-xx/oauth-ruby/blob/master/CODE_OF_CONDUCT.md
160
- [contributing]: https://github.com/oauth-xx/oauth-ruby/blob/master/CONTRIBUTING.md
360
+ [conduct]: https://github.com/oauth-xx/oauth-ruby/blob/main/CODE_OF_CONDUCT.md
361
+ [contributing]: https://github.com/oauth-xx/oauth-ruby/blob/main/CONTRIBUTING.md
161
362
  [contributors]: https://github.com/oauth-xx/oauth-ruby/graphs/contributors
162
363
  [mailinglist]: http://groups.google.com/group/oauth-ruby
163
364
  [source]: https://github.com/oauth-xx/oauth-ruby/
@@ -179,12 +380,11 @@ Comments are welcome. Contact the [OAuth Ruby mailing list (Google Group)][maili
179
380
  [followme-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow
180
381
  [gh_discussions]: https://github.com/oauth-xx/oauth-ruby/discussions
181
382
  [gh_sponsors]: https://github.com/sponsors/pboling
182
- [license]: https://github.com/oauth-xx/oauth-ruby/blob/master/LICENSE
383
+ [license]: https://github.com/oauth-xx/oauth-ruby/blob/main/LICENSE
183
384
  [license-ref]: https://opensource.org/licenses/MIT
184
385
  [liberapay_donate]: https://liberapay.com/pboling/donate
185
- [politicme]: https://nationalprogressiveparty.org
186
386
  [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
187
387
  [rubygems]: https://rubygems.org/gems/oauth
188
- [security]: https://github.com/oauth-xx/oauth-ruby/blob/master/SECURITY.md
388
+ [security]: https://github.com/oauth-xx/oauth-ruby/blob/main/SECURITY.md
189
389
  [semver]: http://semver.org/
190
390
  [tweetme]: http://twitter.com/galtzo
data/SECURITY.md CHANGED
@@ -2,15 +2,25 @@
2
2
 
3
3
  ## Supported Versions
4
4
 
5
- | Version | Supported |
6
- | ------- | ------------------ |
7
- | 0.7.x | :white_check_mark: |
8
- | 0.6.x | :white_check_mark: |
9
- | 0.5.x | :white_check_mark: |
10
- | <= 0.5 | :x: |
5
+ | Version | Supported | EOL |
6
+ |---------|--------------------|---------|
7
+ | 1.1.x | :white_check_mark: | 04/2025 |
8
+ | 1.0.x | :white_check_mark: | 04/2025 |
9
+ | 0.6.x | :white_check_mark: | 04/2024 |
10
+ | 0.5.x | :white_check_mark: | 04/2023 |
11
+ | <= 0.5 | :x: | :x: |
12
+
13
+ ### EOL Policy
14
+
15
+ Non-commercial support for the oldest version of Ruby (which itself is going EOL) will be dropped each year in April.
11
16
 
12
17
  ## Reporting a Vulnerability
13
18
 
14
- Peter Boling is the primary maintainer of the this gem. Please find a way to [contact him directly][contact] to report the issue. Include as much relevant information as possible.
19
+ To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
20
+ Tidelift will coordinate the fix and disclosure.
21
+
22
+ ## OAuth for Enterprise
23
+
24
+ Available as part of the Tidelift Subscription.
15
25
 
16
- [contact]: https://railsbling.com/contact
26
+ The maintainers of oauth and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. [Learn more.](https://tidelift.com/subscription/pkg/rubygems-oauth?utm_source=rubygems-oauth&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
data/TODO CHANGED
File without changes
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if defined? ActionDispatch
2
4
  require "oauth/request_proxy/rack_request"
3
5
  require "oauth/request_proxy/action_dispatch_request"
@@ -10,12 +12,12 @@ end
10
12
  module ActionController
11
13
  class Base
12
14
  if defined? ActionDispatch
13
- def process_with_new_base_test(request, response=nil)
15
+ def process_with_new_base_test(request, response = nil)
14
16
  request.apply_oauth! if request.respond_to?(:apply_oauth!)
15
17
  super(request, response)
16
18
  end
17
19
  else
18
- def process_with_oauth(request, response=nil)
20
+ def process_with_oauth(request, response = nil)
19
21
  request.apply_oauth! if request.respond_to?(:apply_oauth!)
20
22
  process_without_oauth(request, response)
21
23
  end
@@ -24,8 +26,8 @@ module ActionController
24
26
  end
25
27
 
26
28
  class TestRequest
27
- def self.use_oauth=(bool)
28
- @use_oauth = bool
29
+ class << self
30
+ attr_writer :use_oauth
29
31
  end
30
32
 
31
33
  def self.use_oauth?
@@ -33,21 +35,22 @@ module ActionController
33
35
  end
34
36
 
35
37
  def configure_oauth(consumer = nil, token = nil, options = {})
36
- @oauth_options = { :consumer => consumer,
37
- :token => token,
38
- :scheme => "header",
39
- :signature_method => nil,
40
- :nonce => nil,
41
- :timestamp => nil }.merge(options)
38
+ @oauth_options = { consumer: consumer,
39
+ token: token,
40
+ scheme: "header",
41
+ signature_method: nil,
42
+ nonce: nil,
43
+ timestamp: nil }.merge(options)
42
44
  end
43
45
 
44
46
  def apply_oauth!
45
47
  return unless ActionController::TestRequest.use_oauth? && @oauth_options
46
48
 
47
- @oauth_helper = OAuth::Client::Helper.new(self, @oauth_options.merge(:request_uri => (respond_to?(:fullpath) ? fullpath : request_uri)))
49
+ @oauth_helper = OAuth::Client::Helper.new(self,
50
+ @oauth_options.merge(request_uri: (respond_to?(:fullpath) ? fullpath : request_uri)))
48
51
  @oauth_helper.amend_user_agent_header(env)
49
52
 
50
- self.send("set_oauth_#{@oauth_options[:scheme]}")
53
+ send("set_oauth_#{@oauth_options[:scheme]}")
51
54
  end
52
55
 
53
56
  def set_oauth_header
@@ -56,10 +59,9 @@ module ActionController
56
59
 
57
60
  def set_oauth_parameters
58
61
  @query_parameters = @oauth_helper.parameters_with_oauth
59
- @query_parameters.merge!(:oauth_signature => @oauth_helper.signature)
62
+ @query_parameters.merge!(oauth_signature: @oauth_helper.signature)
60
63
  end
61
64
 
62
- def set_oauth_query_string
63
- end
65
+ def set_oauth_query_string; end
64
66
  end
65
67
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "em-http"
2
4
  require "oauth/helper"
3
5
  require "oauth/request_proxy/em_http_request"
@@ -23,16 +25,16 @@ module EventMachine
23
25
  #
24
26
  # See Also: {OAuth core spec version 1.0, section 5.4.1}[http://oauth.net/core/1.0#rfc.section.5.4.1]
25
27
  def oauth!(http, consumer = nil, token = nil, options = {})
26
- options = { :request_uri => normalized_oauth_uri(http),
27
- :consumer => consumer,
28
- :token => token,
29
- :scheme => "header",
30
- :signature_method => nil,
31
- :nonce => nil,
32
- :timestamp => nil }.merge(options)
28
+ options = { request_uri: normalized_oauth_uri(http),
29
+ consumer: consumer,
30
+ token: token,
31
+ scheme: "header",
32
+ signature_method: nil,
33
+ nonce: nil,
34
+ timestamp: nil }.merge(options)
33
35
 
34
36
  @oauth_helper = OAuth::Client::Helper.new(self, options)
35
- self.__send__(:"set_oauth_#{options[:scheme]}")
37
+ __send__(:"set_oauth_#{options[:scheme]}")
36
38
  end
37
39
 
38
40
  # Create a string suitable for signing for an HTTP request. This process involves parameter
@@ -49,13 +51,13 @@ module EventMachine
49
51
  #
50
52
  # See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1]
51
53
  def signature_base_string(http, consumer = nil, token = nil, options = {})
52
- options = { :request_uri => normalized_oauth_uri(http),
53
- :consumer => consumer,
54
- :token => token,
55
- :scheme => "header",
56
- :signature_method => nil,
57
- :nonce => nil,
58
- :timestamp => nil }.merge(options)
54
+ options = { request_uri: normalized_oauth_uri(http),
55
+ consumer: consumer,
56
+ token: token,
57
+ scheme: "header",
58
+ signature_method: nil,
59
+ nonce: nil,
60
+ timestamp: nil }.merge(options)
59
61
 
60
62
  OAuth::Client::Helper.new(self, options).signature_base_string
61
63
  end
@@ -77,14 +79,12 @@ module EventMachine
77
79
  protected
78
80
 
79
81
  def combine_query(path, query, uri_query)
80
- combined_query = if query.kind_of?(Hash)
81
- query.map { |k, v| encode_param(k, v) }.join("&")
82
- else
83
- query.to_s
84
- end
85
- if !uri_query.to_s.empty?
86
- combined_query = [combined_query, uri_query].reject {|part| part.empty?}.join("&")
87
- end
82
+ combined_query = if query.is_a?(Hash)
83
+ query.map { |k, v| encode_param(k, v) }.join("&")
84
+ else
85
+ query.to_s
86
+ end
87
+ combined_query = [combined_query, uri_query].reject(&:empty?).join("&") unless uri_query.to_s.empty?
88
88
  combined_query.to_s.empty? ? path : "#{path}?#{combined_query}"
89
89
  end
90
90
 
@@ -95,17 +95,17 @@ module EventMachine
95
95
  uri.host = http.address
96
96
  uri.port = http.port
97
97
 
98
- if http.respond_to?(:use_ssl?) && http.use_ssl?
99
- uri.scheme = "https"
100
- else
101
- uri.scheme = "http"
102
- end
98
+ uri.scheme = if http.respond_to?(:use_ssl?) && http.use_ssl?
99
+ "https"
100
+ else
101
+ "http"
102
+ end
103
103
  uri.to_s
104
104
  end
105
105
 
106
106
  def set_oauth_header
107
- self.req[:head] ||= {}
108
- self.req[:head].merge!("Authorization" => @oauth_helper.header)
107
+ req[:head] ||= {}
108
+ req[:head].merge!("Authorization" => @oauth_helper.header)
109
109
  end
110
110
 
111
111
  def set_oauth_body