oauth 0.5.6 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +504 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/CONTRIBUTING.md +40 -0
- data/LICENSE +19 -17
- data/README.md +390 -0
- data/SECURITY.md +26 -0
- data/lib/oauth/client/action_controller_request.rb +23 -21
- data/lib/oauth/client/em_http.rb +99 -99
- data/lib/oauth/client/helper.rb +83 -82
- data/lib/oauth/client/net_http.rb +112 -105
- data/lib/oauth/client.rb +2 -0
- data/lib/oauth/consumer.rb +147 -133
- data/lib/oauth/errors/error.rb +2 -0
- data/lib/oauth/errors/problem.rb +3 -0
- data/lib/oauth/errors/unauthorized.rb +7 -1
- data/lib/oauth/errors.rb +5 -3
- data/lib/oauth/helper.rb +26 -18
- data/lib/oauth/oauth.rb +6 -4
- data/lib/oauth/oauth_test_helper.rb +6 -4
- data/lib/oauth/request_proxy/action_controller_request.rb +49 -71
- data/lib/oauth/request_proxy/action_dispatch_request.rb +8 -4
- data/lib/oauth/request_proxy/base.rb +136 -132
- data/lib/oauth/request_proxy/curb_request.rb +49 -43
- data/lib/oauth/request_proxy/em_http_request.rb +59 -49
- data/lib/oauth/request_proxy/jabber_request.rb +12 -9
- data/lib/oauth/request_proxy/mock_request.rb +5 -3
- data/lib/oauth/request_proxy/net_http.rb +61 -54
- data/lib/oauth/request_proxy/rack_request.rb +35 -31
- data/lib/oauth/request_proxy/rest_client_request.rb +54 -50
- data/lib/oauth/request_proxy/typhoeus_request.rb +51 -45
- data/lib/oauth/request_proxy.rb +7 -4
- data/lib/oauth/server.rb +14 -12
- data/lib/oauth/signature/base.rb +78 -71
- data/lib/oauth/signature/hmac/sha1.rb +16 -10
- data/lib/oauth/signature/hmac/sha256.rb +16 -10
- data/lib/oauth/signature/plaintext.rb +18 -20
- data/lib/oauth/signature/rsa/sha1.rb +46 -38
- data/lib/oauth/signature.rb +8 -5
- data/lib/oauth/token.rb +7 -5
- data/lib/oauth/tokens/access_token.rb +5 -3
- data/lib/oauth/tokens/consumer_token.rb +4 -2
- data/lib/oauth/tokens/request_token.rb +12 -10
- data/lib/oauth/tokens/server_token.rb +2 -1
- data/lib/oauth/tokens/token.rb +2 -0
- data/lib/oauth/version.rb +5 -1
- data/lib/oauth.rb +17 -9
- metadata +105 -98
- data/README.rdoc +0 -88
- data/bin/oauth +0 -11
- data/lib/oauth/cli/authorize_command.rb +0 -71
- data/lib/oauth/cli/base_command.rb +0 -208
- data/lib/oauth/cli/help_command.rb +0 -22
- data/lib/oauth/cli/query_command.rb +0 -25
- data/lib/oauth/cli/sign_command.rb +0 -81
- data/lib/oauth/cli/version_command.rb +0 -7
- data/lib/oauth/cli.rb +0 -56
data/README.md
ADDED
@@ -0,0 +1,390 @@
|
|
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
|
+
|
10
|
+
# Ruby OAuth
|
11
|
+
|
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.
|
16
|
+
|
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
|
22
|
+
|
23
|
+
**New EOL Policy**
|
24
|
+
|
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.
|
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.1. The only breaking change in 1.x is dropping old Rubies.
|
34
|
+
|
35
|
+
## Status
|
36
|
+
|
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
|
166
|
+
|
167
|
+
Install the gem and add to the application's Gemfile by executing:
|
168
|
+
|
169
|
+
$ bundle add oauth
|
170
|
+
|
171
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
172
|
+
|
173
|
+
$ gem install oauth
|
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
|
+
|
188
|
+
## Compatibility
|
189
|
+
|
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>
|
213
|
+
|
214
|
+
If something doesn't work on one of these interpreters, it's a bug.
|
215
|
+
|
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.
|
239
|
+
|
240
|
+
## Basics
|
241
|
+
|
242
|
+
This is a ruby library which is intended to be used in creating Ruby Consumer
|
243
|
+
and Service Provider applications. It is NOT a Rails plugin, but could easily
|
244
|
+
be used for the foundation for such a Rails plugin.
|
245
|
+
|
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))
|
256
|
+
|
257
|
+
## Usage
|
258
|
+
|
259
|
+
We need to specify the `oauth_callback` url explicitly, otherwise it defaults to
|
260
|
+
"oob" (Out of Band)
|
261
|
+
|
262
|
+
```ruby
|
263
|
+
callback_url = "http://127.0.0.1:3000/oauth/callback"
|
264
|
+
```
|
265
|
+
|
266
|
+
Create a new `OAuth::Consumer` instance by passing it a configuration hash:
|
267
|
+
|
268
|
+
```ruby
|
269
|
+
oauth_consumer = OAuth::Consumer.new("key", "secret", site: "https://agree2")
|
270
|
+
```
|
271
|
+
|
272
|
+
Start the process by requesting a token
|
273
|
+
|
274
|
+
```ruby
|
275
|
+
request_token = oauth_consumer.get_request_token(oauth_callback: callback_url)
|
276
|
+
|
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
|
+
```
|
281
|
+
|
282
|
+
When user returns create an access_token
|
283
|
+
|
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
|
+
```
|
292
|
+
|
293
|
+
Now that you have an access token, you can use Typhoeus to interact with the
|
294
|
+
OAuth provider if you choose.
|
295
|
+
|
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
|
+
```
|
308
|
+
|
309
|
+
## More Information
|
310
|
+
|
311
|
+
* RubyDoc Documentation: [![RubyDoc.info](https://img.shields.io/badge/documentation-rubydoc-brightgreen.svg?style=flat)][documentation]
|
312
|
+
* Mailing List/Google Group: [![Mailing List](https://img.shields.io/badge/group-mailinglist-violet.svg?style=social&logo=google)][mailinglist]
|
313
|
+
* GitHub Discussions: [![Discussion](https://img.shields.io/badge/discussions-github-brightgreen.svg?style=flat)][gh_discussions]
|
314
|
+
* Live Chat on Gitter: [![Join the chat at https://gitter.im/oauth-xx/oauth-ruby](https://badges.gitter.im/Join%20Chat.svg)][chat]
|
315
|
+
* Maintainer's Blog: [![Blog](https://img.shields.io/badge/blog-railsbling-brightgreen.svg?style=flat)][blogpage]
|
316
|
+
|
317
|
+
## Contributing
|
318
|
+
|
319
|
+
See [CONTRIBUTING.md][contributing]
|
320
|
+
|
321
|
+
## Contributors
|
322
|
+
|
323
|
+
[![Contributors](https://contrib.rocks/image?repo=oauth-xx/oauth-ruby)][contributors]
|
324
|
+
|
325
|
+
Made with [contributors-img][contrib-rocks].
|
326
|
+
|
327
|
+
[contrib-rocks]: https://contrib.rocks
|
328
|
+
|
329
|
+
## Versioning
|
330
|
+
|
331
|
+
This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations of this scheme should be reported as
|
332
|
+
bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be
|
333
|
+
immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new
|
334
|
+
major versions. Compatibility with a major and minor versions of Ruby will only be changed with a major version bump.
|
335
|
+
|
336
|
+
As a result of this policy, you can (and should) specify a dependency on this gem using
|
337
|
+
the [Pessimistic Version Constraint][pvc] with two digits of precision.
|
338
|
+
|
339
|
+
For example:
|
340
|
+
|
341
|
+
```ruby
|
342
|
+
spec.add_dependency "oauth", "~> 1.1"
|
343
|
+
```
|
344
|
+
|
345
|
+
## License
|
346
|
+
|
347
|
+
The gem is available as open source under the terms of
|
348
|
+
the [MIT License][license] [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)][license-ref].
|
349
|
+
See [LICENSE][license] for the [Copyright Notice][copyright-notice-explainer].
|
350
|
+
|
351
|
+
## Contact
|
352
|
+
|
353
|
+
OAuth Ruby has been created and maintained by a large number of talented
|
354
|
+
individuals. The current maintainer is Peter Boling ([@pboling][gh_sponsors]).
|
355
|
+
|
356
|
+
Comments are welcome. Contact the [OAuth Ruby mailing list (Google Group)][mailinglist] or [GitHub Discussions][gh_discussions].
|
357
|
+
|
358
|
+
[comment]: <> (Following links are used by README, CONTRIBUTING, Homepage)
|
359
|
+
|
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
|
362
|
+
[contributors]: https://github.com/oauth-xx/oauth-ruby/graphs/contributors
|
363
|
+
[mailinglist]: http://groups.google.com/group/oauth-ruby
|
364
|
+
[source]: https://github.com/oauth-xx/oauth-ruby/
|
365
|
+
|
366
|
+
[comment]: <> (Following links are used by README, Homepage)
|
367
|
+
|
368
|
+
[aboutme]: https://about.me/peter.boling
|
369
|
+
[actions]: https://github.com/oauth-xx/oauth-ruby/actions
|
370
|
+
[angelme]: https://angel.co/peter-boling
|
371
|
+
[blogpage]: http://www.railsbling.com/tags/oauth/
|
372
|
+
[chat]: https://gitter.im/oauth-xx/oauth-ruby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
373
|
+
[climate_coverage]: https://codeclimate.com/github/oauth-xx/oauth-ruby/test_coverage
|
374
|
+
[climate_maintainability]: https://codeclimate.com/github/oauth-xx/oauth-ruby/maintainability
|
375
|
+
[code_triage]: https://www.codetriage.com/oauth-xx/oauth-ruby
|
376
|
+
[codecov_coverage]: https://codecov.io/gh/oauth-xx/oauth-ruby
|
377
|
+
[coderme]:http://coderwall.com/pboling
|
378
|
+
[depfu]: https://depfu.com/github/oauth-xx/oauth-ruby?project_id=22868
|
379
|
+
[documentation]: https://rubydoc.info/github/oauth-xx/oauth-ruby
|
380
|
+
[followme-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow
|
381
|
+
[gh_discussions]: https://github.com/oauth-xx/oauth-ruby/discussions
|
382
|
+
[gh_sponsors]: https://github.com/sponsors/pboling
|
383
|
+
[license]: https://github.com/oauth-xx/oauth-ruby/blob/main/LICENSE
|
384
|
+
[license-ref]: https://opensource.org/licenses/MIT
|
385
|
+
[liberapay_donate]: https://liberapay.com/pboling/donate
|
386
|
+
[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
387
|
+
[rubygems]: https://rubygems.org/gems/oauth
|
388
|
+
[security]: https://github.com/oauth-xx/oauth-ruby/blob/main/SECURITY.md
|
389
|
+
[semver]: http://semver.org/
|
390
|
+
[tweetme]: http://twitter.com/galtzo
|
data/SECURITY.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
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.
|
16
|
+
|
17
|
+
## Reporting a Vulnerability
|
18
|
+
|
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.
|
25
|
+
|
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)
|
@@ -1,21 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
if defined? ActionDispatch
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require "oauth/request_proxy/rack_request"
|
5
|
+
require "oauth/request_proxy/action_dispatch_request"
|
6
|
+
require "action_dispatch/testing/test_process"
|
5
7
|
else
|
6
|
-
require
|
7
|
-
require
|
8
|
+
require "oauth/request_proxy/action_controller_request"
|
9
|
+
require "action_controller/test_process"
|
8
10
|
end
|
9
11
|
|
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
|
-
|
28
|
-
|
29
|
+
class << self
|
30
|
+
attr_writer :use_oauth
|
29
31
|
end
|
30
32
|
|
31
33
|
def self.use_oauth?
|
@@ -33,33 +35,33 @@ module ActionController
|
|
33
35
|
end
|
34
36
|
|
35
37
|
def configure_oauth(consumer = nil, token = nil, options = {})
|
36
|
-
@oauth_options = { :
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
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,
|
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
|
-
|
53
|
+
send("set_oauth_#{@oauth_options[:scheme]}")
|
51
54
|
end
|
52
55
|
|
53
56
|
def set_oauth_header
|
54
|
-
env[
|
57
|
+
env["Authorization"] = @oauth_helper.header
|
55
58
|
end
|
56
59
|
|
57
60
|
def set_oauth_parameters
|
58
61
|
@query_parameters = @oauth_helper.parameters_with_oauth
|
59
|
-
@query_parameters.merge!(:
|
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
|