oauth 0.5.8 → 0.6.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 +63 -116
  3. data/CODE_OF_CONDUCT.md +0 -0
  4. data/CONTRIBUTING.md +0 -0
  5. data/LICENSE +0 -0
  6. data/README.md +250 -63
  7. data/SECURITY.md +7 -9
  8. data/TODO +0 -0
  9. data/bin/oauth +8 -4
  10. data/lib/oauth/cli/authorize_command.rb +57 -55
  11. data/lib/oauth/cli/base_command.rb +163 -157
  12. data/lib/oauth/cli/help_command.rb +9 -5
  13. data/lib/oauth/cli/query_command.rb +26 -17
  14. data/lib/oauth/cli/sign_command.rb +58 -55
  15. data/lib/oauth/cli/version_command.rb +8 -4
  16. data/lib/oauth/cli.rb +4 -2
  17. data/lib/oauth/client/action_controller_request.rb +17 -15
  18. data/lib/oauth/client/em_http.rb +31 -29
  19. data/lib/oauth/client/helper.rb +76 -75
  20. data/lib/oauth/client/net_http.rb +109 -102
  21. data/lib/oauth/client.rb +2 -0
  22. data/lib/oauth/consumer.rb +96 -88
  23. data/lib/oauth/errors/error.rb +2 -0
  24. data/lib/oauth/errors/problem.rb +3 -0
  25. data/lib/oauth/errors/unauthorized.rb +4 -0
  26. data/lib/oauth/errors.rb +2 -0
  27. data/lib/oauth/helper.rb +16 -12
  28. data/lib/oauth/oauth.rb +6 -4
  29. data/lib/oauth/oauth_test_helper.rb +2 -0
  30. data/lib/oauth/request_proxy/action_controller_request.rb +0 -0
  31. data/lib/oauth/request_proxy/action_dispatch_request.rb +0 -0
  32. data/lib/oauth/request_proxy/base.rb +2 -2
  33. data/lib/oauth/request_proxy/curb_request.rb +0 -0
  34. data/lib/oauth/request_proxy/em_http_request.rb +0 -0
  35. data/lib/oauth/request_proxy/jabber_request.rb +0 -0
  36. data/lib/oauth/request_proxy/mock_request.rb +1 -1
  37. data/lib/oauth/request_proxy/net_http.rb +8 -8
  38. data/lib/oauth/request_proxy/rack_request.rb +0 -0
  39. data/lib/oauth/request_proxy/rest_client_request.rb +2 -1
  40. data/lib/oauth/request_proxy/typhoeus_request.rb +0 -0
  41. data/lib/oauth/request_proxy.rb +7 -4
  42. data/lib/oauth/server.rb +12 -10
  43. data/lib/oauth/signature/base.rb +73 -66
  44. data/lib/oauth/signature/hmac/sha1.rb +15 -9
  45. data/lib/oauth/signature/hmac/sha256.rb +15 -9
  46. data/lib/oauth/signature/plaintext.rb +18 -20
  47. data/lib/oauth/signature/rsa/sha1.rb +46 -38
  48. data/lib/oauth/signature.rb +8 -5
  49. data/lib/oauth/token.rb +2 -0
  50. data/lib/oauth/tokens/access_token.rb +2 -0
  51. data/lib/oauth/tokens/consumer_token.rb +4 -2
  52. data/lib/oauth/tokens/request_token.rb +12 -10
  53. data/lib/oauth/tokens/server_token.rb +2 -1
  54. data/lib/oauth/tokens/token.rb +2 -0
  55. data/lib/oauth/version.rb +5 -1
  56. data/lib/oauth.rb +8 -2
  57. metadata +34 -32
data/README.md CHANGED
@@ -1,59 +1,234 @@
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/master/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/master/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.
13
+
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.
4
16
 
5
- This README, on branch `v0.5-maintenance`, targets 0.5.x series releases. For later releases please see the `msater` branch README.
17
+ * [OAuth 1.0 Spec][oauth1-spec]
18
+ * [oauth2 sibling gem][sibling-gem] for OAuth 2.0 implementations in Ruby.
19
+
20
+ [oauth1-spec]: http://oauth.net/core/1.0/
21
+ [sibling-gem]: https://github.com/oauth-xx/oauth-ruby
6
22
 
7
23
  ## Status
8
24
 
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] |
25
+ <!--
26
+ Numbering rows and badges in each row as a visual "database" lookup,
27
+ as the table is extremely dense, and it can be very difficult to find anything
28
+ Putting one on each row here, to document the emoji that should be used, and for ease of copy/paste.
29
+
30
+ row #s:
31
+ 1️⃣
32
+ 2️⃣
33
+ 3️⃣
34
+ 4️⃣
35
+ 5️⃣
36
+ 6️⃣
37
+ 7️⃣
38
+
39
+ badge #s:
40
+ ⛳️
41
+ 🖇
42
+ 🏘
43
+ 🚎
44
+ 🖐
45
+ 🧮
46
+ 📗
47
+
48
+ appended indicators:
49
+ ♻️ - URL needs to be updated from SASS integration. Find / Replace is insufficient.
50
+ -->
51
+
52
+ | | Project | bundle add oauth2 |
53
+ |:----|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
54
+ | 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] |
55
+ | 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]--> |
56
+ | 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] |
57
+ | 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] |
58
+ | 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] |
59
+ | 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] |
60
+ | 7️⃣ | spread 💖 | [![Liberapay Patrons][⛳liberapay-img]][⛳liberapay] [![Sponsor Me][🖇sponsor-img]][🖇sponsor] [![Tweet @ Peter][🏘tweet-img]][🏘tweet] [🌏][aboutme] [👼][angelme] [💻][coderme] |
61
+
62
+ <!--
63
+ The link tokens in the following sections should be kept ordered by the row and badge numbering scheme
64
+ -->
65
+
66
+ <!-- 1️⃣ name, license, docs -->
67
+ [⛳️gem]: https://rubygems.org/gems/oauth
68
+ [⛳️name-img]: https://img.shields.io/badge/name-oauth-brightgreen.svg?style=flat
69
+ [🖇src-license]: https://opensource.org/licenses/MIT
70
+ [🖇src-license-img]: https://img.shields.io/badge/License-MIT-green.svg
71
+ [🏘fossa]: https://app.fossa.io/projects/git%2Bgithub.com%2Foauth-xx%2Foauth-ruby?ref=badge_shield
72
+ [🏘fossa-img]: https://app.fossa.io/api/projects/git%2Bgithub.com%2Foauth-xx%2Foauth-ruby.svg?type=shield
73
+ [🚎yard]: https://www.rubydoc.info/github/oauth-xx/oauth-ruby
74
+ [🚎yard-img]: https://img.shields.io/badge/documentation-rubydoc-brightgreen.svg?style=flat
75
+ [🖐inch-ci-img]: http://inch-ci.org/github/oauth-xx/oauth-ruby.png
76
+
77
+ <!-- 2️⃣ version & activity -->
78
+ [⛳️version-img]: http://img.shields.io/gem/v/oauth.svg
79
+ [🖇DL-total-img]: https://img.shields.io/gem/dt/oauth.svg
80
+ [🏘DL-rank-img]: https://img.shields.io/gem/rt/oauth.svg
81
+ [🚎src-home]: https://github.com/oauth-xx/oauth-ruby
82
+ [🚎src-home-img]: https://img.shields.io/badge/source-github-brightgreen.svg?style=flat
83
+ [🖐prs-o]: https://github.com/oauth-xx/oauth-ruby/pulls
84
+ [🖐prs-o-img]: https://img.shields.io/github/issues-pr/oauth-xx/oauth-ruby
85
+ [🧮prs-c]: https://github.com/oauth-xx/oauth-ruby/pulls?q=is%3Apr+is%3Aclosed
86
+ [🧮prs-c-img]: https://img.shields.io/github/issues-pr-closed/oauth-xx/oauth-ruby
87
+ [📗next]: https://github.com/oauth-xx/oauth-ruby/milestone/1
88
+ [📗next-img]: https://img.shields.io/github/milestones/progress/oauth-xx/oauth-ruby/1?label=Next%20Version
89
+
90
+ <!-- 3️⃣ maintanence & linting -->
91
+ [⛳cclim-maint]: https://codeclimate.com/github/oauth-xx/oauth-ruby/maintainability
92
+ [⛳cclim-maint-img♻️]: https://api.codeclimate.com/v1/badges/3cf23270c21e8791d788/maintainability
93
+ [🖇triage-help]: https://www.codetriage.com/oauth-xx/oauth-ruby
94
+ [🖇triage-help-img]: https://www.codetriage.com/oauth-xx/oauth-ruby/badges/users.svg
95
+ [🏘depfu♻️]: https://depfu.com/github/oauth-xx/oauth-ruby?project_id=22868
96
+ [🏘depfu-img♻️]: https://badges.depfu.com/badges/d570491bac0ad3b0b65deb3c82028327/count.svg
97
+ [🚎contributors]: https://github.com/oauth-xx/oauth-ruby/graphs/contributors
98
+ [🚎contributors-img]: https://img.shields.io/github/contributors-anon/oauth-xx/oauth-ruby
99
+ [🖐style-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/style.yml
100
+ [🖐style-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/style.yml/badge.svg
101
+ [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
102
+ [🧮kloc-img]: https://img.shields.io/tokei/lines/github.com/oauth-xx/oauth-ruby
103
+
104
+ <!-- 4️⃣ testing -->
105
+ [⛳iss-o]: https://github.com/oauth-xx/oauth-ruby/issues
106
+ [⛳iss-o-img]: https://img.shields.io/github/issues-raw/oauth-xx/oauth-ruby
107
+ [🖇iss-c]: https://github.com/oauth-xx/oauth-ruby/issues?q=is%3Aissue+is%3Aclosed
108
+ [🖇iss-c-img]: https://img.shields.io/github/issues-closed-raw/oauth-xx/oauth-ruby
109
+ [🏘sup-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/supported.yml
110
+ [🏘sup-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/supported.yml/badge.svg
111
+ [🚎heads-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/heads.yml
112
+ [🚎heads-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/heads.yml/badge.svg
113
+ [🖐uns-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/unsupported.yml
114
+ [🖐uns-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/unsupported.yml/badge.svg
115
+ [🧮mac-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/macos.yml
116
+ [🧮mac-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/macos.yml/badge.svg
117
+ [📗win-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/windows.yml
118
+ [📗win-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/windows.yml/badge.svg
119
+
120
+ <!-- 5️⃣ coverage & security -->
121
+ [⛳cclim-cov]: https://codeclimate.com/github/oauth-xx/oauth-ruby/test_coverage
122
+ [⛳cclim-cov-img♻️]: https://api.codeclimate.com/v1/badges/3cf23270c21e8791d788/test_coverage
123
+ [🖇codecov-img♻️]: https://codecov.io/gh/oauth-xx/oauth-ruby/branch/master/graph/badge.svg?token=4ZNAWNxrf9
124
+ [🖇codecov]: https://codecov.io/gh/oauth-xx/oauth-ruby
125
+ [🏘coveralls]: https://coveralls.io/github/oauth-xx/oauth-ruby?branch=master
126
+ [🏘coveralls-img]: https://coveralls.io/repos/github/oauth-xx/oauth-ruby/badge.svg?branch=master
127
+ [🚎sec-pol]: https://github.com/oauth-xx/oauth-ruby/blob/master/SECURITY.md
128
+ [🚎sec-pol-img]: https://img.shields.io/badge/security-policy-brightgreen.svg?style=flat
129
+ [🖐codeQL]: https://github.com/oauth-xx/oauth-ruby/security/code-scanning
130
+ [🖐codeQL-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/codeql-analysis.yml/badge.svg
131
+ [🧮cov-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/coverage.yml
132
+ [🧮cov-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/coverage.yml/badge.svg
133
+
134
+ <!-- 6️⃣ resources -->
135
+ [⛳gh-discussions]: https://github.com/oauth-xx/oauth-ruby/discussions
136
+ [⛳gh-discussions-img]: https://img.shields.io/github/discussions/oauth-xx/oauth-ruby
137
+ [🖇codementor]: https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github
138
+ [🖇codementor-img]: https://cdn.codementor.io/badges/get_help_github.svg
139
+ [🏘chat]: https://gitter.im/oauth-xx/oauth-ruby
140
+ [🏘chat-img]: https://img.shields.io/gitter/room/oauth-xx/oauth-ruby.svg
141
+ [🚎blog]: http://www.railsbling.com/tags/oauth-ruby/
142
+ [🚎blog-img]: https://img.shields.io/badge/blog-railsbling-brightgreen.svg?style=flat
143
+ [🖐wiki]: https://github.com/oauth-xx/oauth-ruby/wiki
144
+ [🖐wiki-img]: https://img.shields.io/badge/wiki-examples-brightgreen.svg?style=flat
145
+
146
+ <!-- 7️⃣ spread 💖 -->
147
+ [⛳liberapay-img]: https://img.shields.io/liberapay/patrons/pboling.svg?logo=liberapay
148
+ [⛳liberapay]: https://liberapay.com/pboling/donate
149
+ [🖇sponsor-img]: https://img.shields.io/badge/sponsor-pboling.svg?style=social&logo=github
150
+ [🖇sponsor]: https://github.com/sponsors/pboling
151
+ [🏘tweet-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow
152
+ [🏘tweet]: http://twitter.com/galtzo
153
+
154
+ <!-- Maintainer Contact Links -->
155
+ [railsbling]: http://www.railsbling.com
156
+ [peterboling]: http://www.peterboling.com
18
157
 
19
- ## What
158
+ ## Installation
20
159
 
21
- This is a RubyGem for implementing both OAuth 1.0 clients and servers in Ruby
22
- applications.
160
+ Install the gem and add to the application's Gemfile by executing:
23
161
 
24
- See the OAuth 1.0 spec http://oauth.net/core/1.0/
162
+ $ bundle add oauth
25
163
 
26
- See the sibling gem [oauth2](https://github.com/oauth-xx/oauth2) for OAuth 2.0 implementations in Ruby.
164
+ If bundler is not being used to manage dependencies, install the gem by executing:
27
165
 
28
- ## Installation
166
+ $ gem install oauth
29
167
 
30
- Add this line to your application's Gemfile:
168
+ ## OAuth for Enterprise
31
169
 
32
- ```ruby
33
- gem "oauth"
34
- ```
170
+ Available as part of the Tidelift Subscription.
35
171
 
36
- And then execute:
172
+ 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)
37
173
 
38
- $ bundle install
174
+ ## Security contact information [![Security Policy][🚎sec-pol-img]][🚎sec-pol]
39
175
 
40
- Or install it yourself as:
176
+ To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
177
+ Tidelift will coordinate the fix and disclosure.
41
178
 
42
- $ gem install oauth
179
+ For more see [SECURITY.md][🚎sec-pol].
43
180
 
44
181
  ## Compatibility
45
182
 
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.
183
+ Targeted ruby compatibility is non-EOL versions of Ruby, currently 2.7, 3.0, and
184
+ 3.1. Ruby is limited to 2.4+ in the gemspec, and this will change with minor version bumps,
185
+ while the gem is still in 0.x, in accordance with the SemVer spec.
186
+
187
+ The `master` branch now targets 1.0.x releases.
188
+ See `v0.6-maintenance` branch for Ruby >= 2.4.
189
+ See `v0.5-maintenance` branch for Ruby >= 2.0.
190
+
191
+ NOTE: If there is another 0.5.x release it is anticipated to be the last of the 0.5.x series.
192
+
193
+ <details>
194
+ <summary>Ruby Engine Compatibility Policy</summary>
195
+
196
+ This gem is tested against MRI, and to a lesser extent, against JRuby, and Truffleruby.
197
+ Each of those has varying versions that target a specific version of MRI Ruby.
198
+ This gem should work in the just-listed Ruby engines according to the targeted MRI compatibility in the table below.
199
+ If you would like to add support for additional engines,
200
+ first make sure Github Actions supports the engine,
201
+ then submit a PR to the correct maintenance branch as according to the table below.
202
+ </details>
203
+
204
+ <details>
205
+ <summary>Ruby Version Compatibility Policy</summary>
206
+
207
+ If something doesn't work on one of these interpreters, it's a bug.
49
208
 
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 | |
209
+ This library may inadvertently work (or seem to work) on other Ruby
210
+ implementations, however support will only be provided for the versions listed
211
+ above.
55
212
 
56
- NOTE: 0.5.7 is anticipated as last release of the 0.5.x series.
213
+ If you would like this library to support another Ruby version, you may
214
+ volunteer to be a maintainer. Being a maintainer entails making sure all tests
215
+ run and pass on that implementation. When something breaks on your
216
+ implementation, you will be responsible for providing patches in a timely
217
+ fashion. If critical issues for a particular implementation exist at the time
218
+ of a major release, support for that Ruby version may be dropped.
219
+ </details>
220
+
221
+ | | Ruby OAuth Version | Maintenance Branch | 🚂 Compatibility | Official 💎 | Unofficial 💎 | Incidental 💎 |
222
+ |:----|--------------------|--------------------|------------------------|----------------------|------------------------------|---------------|
223
+ | 1️⃣ | 1.0.x | `master` | Rails 6, 7 | 2.7, 3.0, 3.1 | sorry, not sorry | nope |
224
+ | 2️⃣ | 0.6.x | `v0.6-maintenance` | Rails 5, 6, 7 | 2.7, 3.0, 3.1 | 2.5, 2.6 | 2.4 |
225
+ | 3️⃣ | 0.5.x | `v0.5-maintenance` | 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 |
226
+ | 4️⃣ | older | N/A | | Best of luck to you! | Please upgrade! | noop |
227
+
228
+ NOTE: Once 1.0 is released, the 0.x series will only receive critical bug and security updates.
229
+ See [SECURITY.md][🚎sec-pol]
230
+
231
+ 🚂 NOTE: See notes on Rails in next section.
57
232
 
58
233
  ## Basics
59
234
 
@@ -61,51 +236,64 @@ This is a ruby library which is intended to be used in creating Ruby Consumer
61
236
  and Service Provider applications. It is NOT a Rails plugin, but could easily
62
237
  be used for the foundation for such a Rails plugin.
63
238
 
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.
239
+ This gem was originally extracted from @pelle's [oauth-plugin](https://github.com/pelle/oauth-plugin)
240
+ gem. After extraction that gem was made to depend on this gem.
241
+
242
+ Unfortunately, this gem does have some Rails related bits that are
243
+ **optional** to load. You don't need Rails! The Rails bits may be pulled out
244
+ into a separate gem after the release of version 1.0 of this gem.
67
245
 
68
246
  ## Usage
69
247
 
70
- We need to specify the oauth_callback url explicitly, otherwise it defaults to
248
+ We need to specify the `oauth_callback` url explicitly, otherwise it defaults to
71
249
  "oob" (Out of Band)
72
250
 
73
- callback_url = "http://127.0.0.1:3000/oauth/callback"
251
+ ```ruby
252
+ callback_url = "http://127.0.0.1:3000/oauth/callback"
253
+ ```
74
254
 
75
255
  Create a new `OAuth::Consumer` instance by passing it a configuration hash:
76
256
 
77
- oauth_consumer = OAuth::Consumer.new("key", "secret", :site => "https://agree2")
257
+ ```ruby
258
+ oauth_consumer = OAuth::Consumer.new("key", "secret", site: "https://agree2")
259
+ ```
78
260
 
79
261
  Start the process by requesting a token
80
262
 
81
- request_token = oauth_consumer.get_request_token(:oauth_callback => callback_url)
263
+ ```ruby
264
+ request_token = oauth_consumer.get_request_token(oauth_callback: callback_url)
82
265
 
83
- session[:token] = request_token.token
84
- session[:token_secret] = request_token.secret
85
- redirect_to request_token.authorize_url(:oauth_callback => callback_url)
266
+ session[:token] = request_token.token
267
+ session[:token_secret] = request_token.secret
268
+ redirect_to request_token.authorize_url(oauth_callback: callback_url)
269
+ ```
86
270
 
87
271
  When user returns create an access_token
88
272
 
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')
273
+ ```ruby
274
+ hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret] }
275
+ request_token = OAuth::RequestToken.from_hash(oauth_consumer, hash)
276
+ access_token = request_token.get_access_token
277
+ # For 3-legged authorization, flow oauth_verifier is passed as param in callback
278
+ # access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
279
+ @photos = access_token.get("/photos.xml")
280
+ ```
95
281
 
96
282
  Now that you have an access token, you can use Typhoeus to interact with the
97
283
  OAuth provider if you choose.
98
284
 
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
285
+ ```ruby
286
+ require "typhoeus"
287
+ require "oauth/request_proxy/typhoeus_request"
288
+ oauth_params = { consumer: oauth_consumer, token: access_token }
289
+ hydra = Typhoeus::Hydra.new
290
+ req = Typhoeus::Request.new(uri, options) # :method needs to be specified in options
291
+ oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(request_uri: uri))
292
+ req.options[:headers]["Authorization"] = oauth_helper.header # Signs the request
293
+ hydra.queue(req)
294
+ hydra.run
295
+ @response = req.response
296
+ ```
109
297
 
110
298
  ## More Information
111
299
 
@@ -130,7 +318,7 @@ Made with [contributors-img][contrib-rocks].
130
318
  This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations of this scheme should be reported as
131
319
  bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be
132
320
  immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new
133
- major versions.
321
+ major versions. Compatibility with a major and minor versions of Ruby will only be changed with a major version bump.
134
322
 
135
323
  As a result of this policy, you can (and should) specify a dependency on this gem using
136
324
  the [Pessimistic Version Constraint][pvc] with two digits of precision.
@@ -138,7 +326,7 @@ the [Pessimistic Version Constraint][pvc] with two digits of precision.
138
326
  For example:
139
327
 
140
328
  ```ruby
141
- spec.add_dependency "oauth", "~> 0.5"
329
+ spec.add_dependency "oauth", "~> 0.6.0"
142
330
  ```
143
331
 
144
332
  ## License
@@ -182,7 +370,6 @@ Comments are welcome. Contact the [OAuth Ruby mailing list (Google Group)][maili
182
370
  [license]: https://github.com/oauth-xx/oauth-ruby/blob/master/LICENSE
183
371
  [license-ref]: https://opensource.org/licenses/MIT
184
372
  [liberapay_donate]: https://liberapay.com/pboling/donate
185
- [politicme]: https://nationalprogressiveparty.org
186
373
  [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
187
374
  [rubygems]: https://rubygems.org/gems/oauth
188
375
  [security]: https://github.com/oauth-xx/oauth-ruby/blob/master/SECURITY.md
data/SECURITY.md CHANGED
@@ -2,15 +2,13 @@
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 |
6
+ |--------------------| ------------------ |
7
+ | 0.6.x (unreleased) | :white_check_mark: |
8
+ | 0.5.x | :white_check_mark: |
9
+ | <= 0.5 | :x: |
11
10
 
12
11
  ## Reporting a Vulnerability
13
12
 
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.
15
-
16
- [contact]: https://railsbling.com/contact
13
+ To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
14
+ Tidelift will coordinate the fix and disclosure.
data/TODO CHANGED
File without changes
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,71 +1,73 @@
1
- class OAuth::CLI
2
- class AuthorizeCommand < BaseCommand
1
+ # frozen_string_literal: true
3
2
 
4
- def required_options
5
- [:uri]
6
- end
7
-
8
- def _run
9
- request_token = get_request_token
10
-
11
- if request_token.callback_confirmed?
12
- puts "Server appears to support OAuth 1.0a; enabling support."
13
- options[:version] = "1.0a"
3
+ module OAuth
4
+ class CLI
5
+ class AuthorizeCommand < BaseCommand
6
+ def required_options
7
+ [:uri]
14
8
  end
15
9
 
16
- puts "Please visit this url to authorize:"
17
- puts request_token.authorize_url
10
+ def _run
11
+ request_token = get_request_token
18
12
 
19
- # parameters for OAuth 1.0a
20
- 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
21
17
 
22
- verbosely_get_access_token(request_token, oauth_verifier)
23
- end
18
+ puts "Please visit this url to authorize:"
19
+ puts request_token.authorize_url
24
20
 
25
- def get_request_token
26
- consumer = get_consumer
27
- scope_options = options[:scope] ? { "scope" => options[:scope] } : {}
28
- consumer.get_request_token({ :oauth_callback => options[:oauth_callback] }, scope_options)
29
- rescue OAuth::Unauthorized => e
30
- alert "A problem occurred while attempting to authorize:"
31
- alert e
32
- alert e.request.body
33
- end
21
+ # parameters for OAuth 1.0a
22
+ oauth_verifier = ask_user_for_verifier
34
23
 
35
- def get_consumer
36
- OAuth::Consumer.new \
37
- options[:oauth_consumer_key],
38
- options[:oauth_consumer_secret],
39
- :access_token_url => options[:access_token_url],
40
- :authorize_url => options[:authorize_url],
41
- :request_token_url => options[:request_token_url],
42
- :scheme => options[:scheme],
43
- :http_method => options[:method].to_s.downcase.to_sym
44
- end
24
+ verbosely_get_access_token(request_token, oauth_verifier)
25
+ end
45
26
 
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
46
36
 
47
- def ask_user_for_verifier
48
- if options[:version] == "1.0a"
49
- puts "Please enter the verification code provided by the SP (oauth_verifier):"
50
- @stdin.gets.chomp
51
- else
52
- puts "Press return to continue..."
53
- @stdin.gets
54
- nil
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
55
57
  end
56
- end
57
58
 
58
- def verbosely_get_access_token(request_token, oauth_verifier)
59
- 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)
60
61
 
61
- puts "Response:"
62
- access_token.params.each do |k,v|
63
- 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
64
70
  end
65
- rescue OAuth::Unauthorized => e
66
- alert "A problem occurred while attempting to obtain an access token:"
67
- alert e
68
- alert e.request.body
69
71
  end
70
72
  end
71
73
  end