oauth 0.6.2 → 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 +27 -1
- data/CONTRIBUTING.md +18 -1
- data/LICENSE +2 -1
- data/README.md +30 -23
- data/SECURITY.md +11 -5
- data/lib/oauth/client/em_http.rb +1 -3
- data/lib/oauth/consumer.rb +4 -12
- data/lib/oauth/request_proxy/action_controller_request.rb +3 -24
- data/lib/oauth/request_proxy/net_http.rb +1 -3
- data/lib/oauth/signature/base.rb +1 -3
- data/lib/oauth/version.rb +1 -1
- metadata +33 -22
- data/bin/oauth +0 -15
- data/lib/oauth/cli/authorize_command.rb +0 -73
- data/lib/oauth/cli/base_command.rb +0 -214
- data/lib/oauth/cli/help_command.rb +0 -26
- data/lib/oauth/cli/query_command.rb +0 -34
- data/lib/oauth/cli/sign_command.rb +0 -84
- data/lib/oauth/cli/version_command.rb +0 -11
- data/lib/oauth/cli.rb +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ed78104bc98c911e6a9cf2a9e5472eb70a883396346379bcf0ca5ad9a5a5a6a
|
4
|
+
data.tar.gz: 918ffe268ffdd0a3e8cb29dda997f07ecef3156c53ff4dde82a68dec5325c8ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ecad352056ded301c816243d846d7628929db7cf10c320ab63627dadc5eb8aa427120f3e74824eb280f8d25e159c639fe16e6405f70d7b02b1ebbf081f0488c
|
7
|
+
data.tar.gz: 8cef46c071d1c2bc8e8a3c766477fa90ac76d61661d3131496e20dade1a199a1d9e2248dd41b022383f956f76a987d6579c3960cd4d437f7a143a3043cd086e0
|
data/CHANGELOG.md
CHANGED
@@ -13,6 +13,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
13
13
|
|
14
14
|
### Removed
|
15
15
|
|
16
|
+
## [1.1.0] 2022-08-29
|
17
|
+
### Changed
|
18
|
+
* `OAuth::CLI` has been extracted to a new gem, `oauth-tty`, hosted on [Gitlab](https://gitlab.com/oauth-xx/oauth-tty)
|
19
|
+
* The public API of `oauth-tty` is backwards compatible (meaning `OAuth::CLI`)
|
20
|
+
* The change within the `oauth` gem is backwards compatible as `oauth-tty` has been added as a dependency
|
21
|
+
* Minor version bump is cautionary, as many lines of code have changed.
|
22
|
+
* `OAuth::Comsumer#options` hash is now handled by `snaky_hash`, which was extracted from `oauth2`
|
23
|
+
* symbolized keys, dot-access and snake-case are now normalized
|
24
|
+
|
25
|
+
## [1.0.1] 2022-08-29
|
26
|
+
### Changed
|
27
|
+
* `OAuth::Comsumer#options` hash is now handled by `snaky_hash`, which was extracted from `oauth2`
|
28
|
+
* symbolized keys, dot-access and snake-case are now normalized
|
29
|
+
|
30
|
+
## [1.0.0] 2022-08-23
|
31
|
+
### Changed
|
32
|
+
* Dropped support for Ruby < 2.7
|
33
|
+
* Dropped support for Rails < 6
|
34
|
+
|
35
|
+
### Added
|
36
|
+
* New EOL Policy
|
37
|
+
* Non-commercial support for the oldest version of Ruby (which itself is going EOL) will be dropped each year in April
|
38
|
+
|
16
39
|
## [0.6.2] 2022-08-29
|
17
40
|
### Changed
|
18
41
|
* `OAuth::Comsumer#options` hash is now handled by `snaky_hash`, which was extracted from `oauth2`
|
@@ -442,7 +465,10 @@ but please have a look at the unit tests.
|
|
442
465
|
* Moved all non-Rails functionality from the Rails plugin:
|
443
466
|
http://code.google.com/p/oauth-plugin/
|
444
467
|
|
445
|
-
[Unreleased]: https://github.com/oauth-xx/oauth-ruby/compare/
|
468
|
+
[Unreleased]: https://github.com/oauth-xx/oauth-ruby/compare/v1.1.0...main
|
469
|
+
[1.1.0]: https://github.com/oauth-xx/oauth-ruby/releases/tag/v1.1.0
|
470
|
+
[1.0.1]: https://github.com/oauth-xx/oauth-ruby/releases/tag/v1.0.1
|
471
|
+
[1.0.0]: https://github.com/oauth-xx/oauth-ruby/releases/tag/v1.0.0
|
446
472
|
[0.6.2]: https://github.com/oauth-xx/oauth-ruby/releases/tag/v0.6.2
|
447
473
|
[0.6.1]: https://github.com/oauth-xx/oauth-ruby/releases/tag/v0.6.1
|
448
474
|
[0.6.0]: https://github.com/oauth-xx/oauth-ruby/releases/tag/v0.6.0
|
data/CONTRIBUTING.md
CHANGED
@@ -8,6 +8,23 @@ To submit a patch, please fork the project and create a patch with
|
|
8
8
|
tests. Once you're happy with it send a pull request and post a message to the
|
9
9
|
[google group][mailinglist].
|
10
10
|
|
11
|
+
## Run tests
|
12
|
+
|
13
|
+
### Against Rails 6
|
14
|
+
|
15
|
+
```bash
|
16
|
+
BUNDLE_GEMFILE=gemfiles/a6.gemfile bundle install
|
17
|
+
BUNDLE_GEMFILE=gemfiles/a6.gemfile bundle exec rake
|
18
|
+
```
|
19
|
+
|
20
|
+
|
21
|
+
### Against Rails 7
|
22
|
+
|
23
|
+
```bash
|
24
|
+
BUNDLE_GEMFILE=gemfiles/a7.gemfile bundle install
|
25
|
+
BUNDLE_GEMFILE=gemfiles/a7.gemfile bundle exec rake
|
26
|
+
```
|
27
|
+
|
11
28
|
## Contributors
|
12
29
|
|
13
30
|
[![Contributors](https://contrib.rocks/image?repo=oauth-xx/oauth-ruby)][contributors]
|
@@ -17,7 +34,7 @@ Made with [contributors-img][contrib-rocks].
|
|
17
34
|
[comment]: <> (Following links are used by README, CONTRIBUTING, Homepage)
|
18
35
|
|
19
36
|
[conduct]: https://github.com/oauth-xx/oauth-ruby/blob/main/CODE_OF_CONDUCT.md
|
20
|
-
[contributing]: https://github.com/oauth-xx/oauth-ruby/blob/main/CONTRIBUTING.md
|
21
37
|
[contributors]: https://github.com/oauth-xx/oauth-ruby/graphs/contributors
|
22
38
|
[mailinglist]: http://groups.google.com/group/oauth-ruby
|
23
39
|
[source]: https://github.com/oauth-xx/oauth-ruby/
|
40
|
+
[contrib-rocks]: https://contrib.rocks
|
data/LICENSE
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2007-2012, 2016-2017
|
3
|
+
Copyright (c) 2007-2012, 2016-2017 Blaine Cook, Larry Halff, Pelle Braendgaard
|
4
|
+
Copyright (c) 2020-2022 Peter Boling
|
4
5
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -20,11 +20,17 @@ See the sibling `oauth2` gem for OAuth 2.0 implementations in Ruby.
|
|
20
20
|
[oauth1-spec]: http://oauth.net/core/1.0/
|
21
21
|
[sibling-gem]: https://github.com/oauth-xx/oauth-ruby
|
22
22
|
|
23
|
-
**
|
23
|
+
**New EOL Policy**
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
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.
|
28
34
|
|
29
35
|
## Status
|
30
36
|
|
@@ -57,10 +63,10 @@ appended indicators:
|
|
57
63
|
|
58
64
|
| | Project | bundle add oauth |
|
59
65
|
|:----|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
60
|
-
| 1️⃣ | name, license, docs | [![RubyGems.org][⛳️name-img]][⛳️gem] [![License: MIT][🖇src-license-img]][🖇src-license] [![
|
66
|
+
| 1️⃣ | name, license, docs | [![RubyGems.org][⛳️name-img]][⛳️gem] [![License: MIT][🖇src-license-img]][🖇src-license] [![RubyDoc.info][🚎yard-img]][🚎yard] |
|
61
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]--> |
|
62
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] |
|
63
|
-
| 4️⃣ | testing | [![Open Issues][⛳iss-o-img]][⛳iss-o] [![Closed Issues][🖇iss-c-img]][🖇iss-c] [![Supported][🏘sup-wf-img]][🏘sup-wf] [![Heads][🚎heads-wf-img]][🚎heads-wf] [![
|
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] |
|
64
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] |
|
65
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] |
|
66
72
|
| 7️⃣ | spread 💖 | [![Liberapay Patrons][⛳liberapay-img]][⛳liberapay] [![Sponsor Me][🖇sponsor-img]][🖇sponsor] [![Tweet @ Peter][🏘tweet-img]][🏘tweet] [🌏][aboutme] [👼][angelme] [💻][coderme] |
|
@@ -74,11 +80,8 @@ The link tokens in the following sections should be kept ordered by the row and
|
|
74
80
|
[⛳️name-img]: https://img.shields.io/badge/name-oauth-brightgreen.svg?style=flat
|
75
81
|
[🖇src-license]: https://opensource.org/licenses/MIT
|
76
82
|
[🖇src-license-img]: https://img.shields.io/badge/License-MIT-green.svg
|
77
|
-
[🏘fossa]: https://app.fossa.io/projects/git%2Bgithub.com%2Foauth-xx%2Foauth-ruby?ref=badge_shield
|
78
|
-
[🏘fossa-img]: https://app.fossa.io/api/projects/git%2Bgithub.com%2Foauth-xx%2Foauth-ruby.svg?type=shield
|
79
83
|
[🚎yard]: https://www.rubydoc.info/github/oauth-xx/oauth-ruby
|
80
84
|
[🚎yard-img]: https://img.shields.io/badge/documentation-rubydoc-brightgreen.svg?style=flat
|
81
|
-
[🖐inch-ci-img]: http://inch-ci.org/github/oauth-xx/oauth-ruby.png
|
82
85
|
|
83
86
|
<!-- 2️⃣ version & activity -->
|
84
87
|
[⛳️version-img]: http://img.shields.io/gem/v/oauth.svg
|
@@ -116,8 +119,6 @@ The link tokens in the following sections should be kept ordered by the row and
|
|
116
119
|
[🏘sup-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/supported.yml/badge.svg
|
117
120
|
[🚎heads-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/heads.yml
|
118
121
|
[🚎heads-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/heads.yml/badge.svg
|
119
|
-
[🖐uns-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/unsupported.yml
|
120
|
-
[🖐uns-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/unsupported.yml/badge.svg
|
121
122
|
[🧮mac-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/macos.yml
|
122
123
|
[🧮mac-wf-img]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/macos.yml/badge.svg
|
123
124
|
[📗win-wf]: https://github.com/oauth-xx/oauth-ruby/actions/workflows/windows.yml
|
@@ -187,12 +188,12 @@ For more see [SECURITY.md][🚎sec-pol].
|
|
187
188
|
## Compatibility
|
188
189
|
|
189
190
|
Targeted ruby compatibility is non-EOL versions of Ruby, currently 2.7, 3.0, and
|
190
|
-
3.1. Ruby is limited to 2.
|
191
|
+
3.1. Ruby is limited to 2.7+ in the gemspec, and this will change with minor version bumps,
|
191
192
|
while the gem is still in 0.x, in accordance with the SemVer spec.
|
192
193
|
|
193
|
-
The `main` branch now targets 1.
|
194
|
-
See `v0.6-maintenance` branch for Ruby >= 2.4.
|
195
|
-
See `v0.5-maintenance` branch for Ruby >= 2.0.
|
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.
|
196
197
|
|
197
198
|
NOTE: No further releases of version < 1.0.x are anticipated.
|
198
199
|
|
@@ -224,12 +225,12 @@ fashion. If critical issues for a particular implementation exist at the time
|
|
224
225
|
of a major release, support for that Ruby version may be dropped.
|
225
226
|
</details>
|
226
227
|
|
227
|
-
| | Ruby OAuth Version | Maintenance Branch | 🚂 Compatibility | Official 💎 | Unofficial 💎 | Incidental 💎 |
|
228
|
-
|
229
|
-
| 1️⃣ | 1.0.x | `main` | Rails 6, 7 | 2.7, 3.0, 3.1 | sorry, not sorry | nope |
|
230
|
-
| 2️⃣ | 0.6.x | `v0.6-maintenance` | Rails 5, 6, 7 | 2.7, 3.0, 3.1 | 2.5, 2.6 | 2.4 |
|
231
|
-
| 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 |
|
232
|
-
| 4️⃣ | older | N/A | | Best of luck to you! | Please upgrade! | noop |
|
228
|
+
| | Ruby OAuth Version | Maintenance Branch | EOL | 🚂 Compatibility | Official 💎 | Unofficial 💎 | Incidental 💎 |
|
229
|
+
|:----|--------------------|--------------------|-----------|------------------------|----------------------|------------------------------|---------------|
|
230
|
+
| 1️⃣ | 1.0.x | `main` | | Rails 6, 7 | 2.7, 3.0, 3.1 | sorry, not sorry | nope |
|
231
|
+
| 2️⃣ | 0.6.x | `v0.6-maintenance` | 04/2024 | Rails 5, 6, 7 | 2.7, 3.0, 3.1 | 2.5, 2.6 | 2.4 |
|
232
|
+
| 3️⃣ | 0.5.x | `v0.5-maintenance` | 04/2023 | Rails 2, 3, 4, 5, 6, 7 | 2.7, 3.0, 3.1 | 2.1, 2.2, 2.3, 2.4, 2.5, 2.6 | 2.0 |
|
233
|
+
| 4️⃣ | older | N/A | yesterday | | Best of luck to you! | Please upgrade! | noop |
|
233
234
|
|
234
235
|
NOTE: Once 1.0 is released, the 0.x series will only receive critical bug and security updates.
|
235
236
|
See [SECURITY.md][🚎sec-pol]
|
@@ -247,7 +248,11 @@ gem. After extraction that gem was made to depend on this gem.
|
|
247
248
|
|
248
249
|
Unfortunately, this gem does have some Rails related bits that are
|
249
250
|
**optional** to load. You don't need Rails! The Rails bits may be pulled out
|
250
|
-
into a separate gem with the
|
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))
|
251
256
|
|
252
257
|
## Usage
|
253
258
|
|
@@ -319,6 +324,8 @@ See [CONTRIBUTING.md][contributing]
|
|
319
324
|
|
320
325
|
Made with [contributors-img][contrib-rocks].
|
321
326
|
|
327
|
+
[contrib-rocks]: https://contrib.rocks
|
328
|
+
|
322
329
|
## Versioning
|
323
330
|
|
324
331
|
This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations of this scheme should be reported as
|
@@ -332,7 +339,7 @@ the [Pessimistic Version Constraint][pvc] with two digits of precision.
|
|
332
339
|
For example:
|
333
340
|
|
334
341
|
```ruby
|
335
|
-
spec.add_dependency "oauth", "~>
|
342
|
+
spec.add_dependency "oauth", "~> 1.1"
|
336
343
|
```
|
337
344
|
|
338
345
|
## License
|
data/SECURITY.md
CHANGED
@@ -2,11 +2,17 @@
|
|
2
2
|
|
3
3
|
## Supported Versions
|
4
4
|
|
5
|
-
| Version | Supported |
|
6
|
-
|
7
|
-
|
|
8
|
-
| 0.
|
9
|
-
|
|
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.
|
10
16
|
|
11
17
|
## Reporting a Vulnerability
|
12
18
|
|
data/lib/oauth/client/em_http.rb
CHANGED
@@ -84,9 +84,7 @@ module EventMachine
|
|
84
84
|
else
|
85
85
|
query.to_s
|
86
86
|
end
|
87
|
-
unless uri_query.to_s.empty?
|
88
|
-
combined_query = [combined_query, uri_query].reject(&:empty?).join("&")
|
89
|
-
end
|
87
|
+
combined_query = [combined_query, uri_query].reject(&:empty?).join("&") unless uri_query.to_s.empty?
|
90
88
|
combined_query.to_s.empty? ? path : "#{path}?#{combined_query}"
|
91
89
|
end
|
92
90
|
|
data/lib/oauth/consumer.rb
CHANGED
@@ -162,9 +162,7 @@ module OAuth
|
|
162
162
|
def get_request_token(request_options = {}, *arguments, &block)
|
163
163
|
# if oauth_callback wasn't provided, it is assumed that oauth_verifiers
|
164
164
|
# will be exchanged out of band
|
165
|
-
unless request_options[:exclude_callback]
|
166
|
-
request_options[:oauth_callback] ||= OAuth::OUT_OF_BAND
|
167
|
-
end
|
165
|
+
request_options[:oauth_callback] ||= OAuth::OUT_OF_BAND unless request_options[:exclude_callback]
|
168
166
|
|
169
167
|
response = if block
|
170
168
|
token_request(
|
@@ -389,13 +387,9 @@ module OAuth
|
|
389
387
|
end
|
390
388
|
|
391
389
|
http_object.read_timeout = http_object.open_timeout = @options[:timeout] || 60
|
392
|
-
if @options[:open_timeout]
|
393
|
-
http_object.open_timeout = @options[:open_timeout]
|
394
|
-
end
|
390
|
+
http_object.open_timeout = @options[:open_timeout] if @options[:open_timeout]
|
395
391
|
http_object.ssl_version = @options[:ssl_version] if @options[:ssl_version]
|
396
|
-
if @options[:ssl_client_cert]
|
397
|
-
http_object.cert = @options[:ssl_client_cert]
|
398
|
-
end
|
392
|
+
http_object.cert = @options[:ssl_client_cert] if @options[:ssl_client_cert]
|
399
393
|
http_object.key = @options[:ssl_client_key] if @options[:ssl_client_key]
|
400
394
|
http_object.set_debug_output(debug_output) if debug_output
|
401
395
|
|
@@ -412,9 +406,7 @@ module OAuth
|
|
412
406
|
# only add if the site host matches the current http object's host
|
413
407
|
# (in case we've specified a full url for token requests)
|
414
408
|
uri = URI.parse(site)
|
415
|
-
if uri.path && uri.path != "/" && uri.host == http.address
|
416
|
-
path = uri.path + path
|
417
|
-
end
|
409
|
+
path = uri.path + path if uri.path && uri.path != "/" && uri.host == http.address
|
418
410
|
|
419
411
|
headers = arguments.first.is_a?(Hash) ? arguments.shift : {}
|
420
412
|
|
@@ -1,36 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_support"
|
4
|
-
require "active_support/version"
|
5
4
|
require "action_controller"
|
6
5
|
require "uri"
|
7
6
|
|
8
|
-
|
9
|
-
# rails 2.x
|
10
|
-
require "action_controller/request"
|
11
|
-
unless ActionController::Request::HTTP_METHODS.include?("patch")
|
12
|
-
ActionController::Request::HTTP_METHODS << "patch"
|
13
|
-
ActionController::Request::HTTP_METHOD_LOOKUP["PATCH"] = :patch
|
14
|
-
ActionController::Request::HTTP_METHOD_LOOKUP["patch"] = :patch
|
15
|
-
end
|
16
|
-
|
17
|
-
elsif Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new("4")
|
18
|
-
# rails 3.x
|
19
|
-
require "action_dispatch/http/request"
|
20
|
-
unless ActionDispatch::Request::HTTP_METHODS.include?("patch")
|
21
|
-
ActionDispatch::Request::HTTP_METHODS << "patch"
|
22
|
-
ActionDispatch::Request::HTTP_METHOD_LOOKUP["PATCH"] = :patch
|
23
|
-
ActionDispatch::Request::HTTP_METHOD_LOOKUP["patch"] = :patch
|
24
|
-
end
|
25
|
-
|
26
|
-
else # rails 4.x and later - already has patch
|
27
|
-
require "action_dispatch/http/request"
|
28
|
-
end
|
7
|
+
require "action_dispatch/http/request"
|
29
8
|
|
30
9
|
module OAuth
|
31
10
|
module RequestProxy
|
32
11
|
class ActionControllerRequest < OAuth::RequestProxy::Base
|
33
|
-
proxies(
|
12
|
+
proxies(::ActionDispatch::Request)
|
34
13
|
|
35
14
|
def method
|
36
15
|
request.method.to_s.upcase
|
@@ -50,7 +29,7 @@ module OAuth
|
|
50
29
|
end
|
51
30
|
end
|
52
31
|
|
53
|
-
# Override from OAuth::RequestProxy::Base to avoid
|
32
|
+
# Override from OAuth::RequestProxy::Base to avoid round-trip
|
54
33
|
# conversion to Hash or Array and thus preserve the original
|
55
34
|
# parameter names
|
56
35
|
def parameters_for_signature
|
@@ -69,9 +69,7 @@ module OAuth
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def auth_header_params
|
72
|
-
unless request["Authorization"] && request["Authorization"][0, 5] == "OAuth"
|
73
|
-
return nil
|
74
|
-
end
|
72
|
+
return nil unless request["Authorization"] && request["Authorization"][0, 5] == "OAuth"
|
75
73
|
|
76
74
|
request["Authorization"]
|
77
75
|
end
|
data/lib/oauth/signature/base.rb
CHANGED
@@ -31,9 +31,7 @@ module OAuth
|
|
31
31
|
@consumer_secret = options[:consumer].secret if options[:consumer]
|
32
32
|
|
33
33
|
# presence of :consumer_secret option will override any Consumer that's provided
|
34
|
-
if options[:consumer_secret]
|
35
|
-
@consumer_secret = options[:consumer_secret]
|
36
|
-
end
|
34
|
+
@consumer_secret = options[:consumer_secret] if options[:consumer_secret]
|
37
35
|
|
38
36
|
## token secret was determined beforehand
|
39
37
|
|
data/lib/oauth/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pelle Braendgaard
|
@@ -18,6 +18,26 @@ bindir: bin
|
|
18
18
|
cert_chain: []
|
19
19
|
date: 2022-08-29 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: oauth-tty
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.0'
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.0.1
|
31
|
+
type: :runtime
|
32
|
+
prerelease: false
|
33
|
+
version_requirements: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - "~>"
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.0'
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.1
|
21
41
|
- !ruby/object:Gem::Dependency
|
22
42
|
name: snaky_hash
|
23
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,14 +184,14 @@ dependencies:
|
|
164
184
|
requirements:
|
165
185
|
- - "~>"
|
166
186
|
- !ruby/object:Gem::Version
|
167
|
-
version: '
|
187
|
+
version: '18.0'
|
168
188
|
type: :development
|
169
189
|
prerelease: false
|
170
190
|
version_requirements: !ruby/object:Gem::Requirement
|
171
191
|
requirements:
|
172
192
|
- - "~>"
|
173
193
|
- !ruby/object:Gem::Version
|
174
|
-
version: '
|
194
|
+
version: '18.0'
|
175
195
|
- !ruby/object:Gem::Dependency
|
176
196
|
name: typhoeus
|
177
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,18 +212,17 @@ dependencies:
|
|
192
212
|
requirements:
|
193
213
|
- - "<="
|
194
214
|
- !ruby/object:Gem::Version
|
195
|
-
version: 3.
|
215
|
+
version: 3.19.0
|
196
216
|
type: :development
|
197
217
|
prerelease: false
|
198
218
|
version_requirements: !ruby/object:Gem::Requirement
|
199
219
|
requirements:
|
200
220
|
- - "<="
|
201
221
|
- !ruby/object:Gem::Version
|
202
|
-
version: 3.
|
222
|
+
version: 3.19.0
|
203
223
|
description:
|
204
224
|
email: oauth-ruby@googlegroups.com
|
205
|
-
executables:
|
206
|
-
- oauth
|
225
|
+
executables: []
|
207
226
|
extensions: []
|
208
227
|
extra_rdoc_files:
|
209
228
|
- TODO
|
@@ -215,15 +234,7 @@ files:
|
|
215
234
|
- README.md
|
216
235
|
- SECURITY.md
|
217
236
|
- TODO
|
218
|
-
- bin/oauth
|
219
237
|
- lib/oauth.rb
|
220
|
-
- lib/oauth/cli.rb
|
221
|
-
- lib/oauth/cli/authorize_command.rb
|
222
|
-
- lib/oauth/cli/base_command.rb
|
223
|
-
- lib/oauth/cli/help_command.rb
|
224
|
-
- lib/oauth/cli/query_command.rb
|
225
|
-
- lib/oauth/cli/sign_command.rb
|
226
|
-
- lib/oauth/cli/version_command.rb
|
227
238
|
- lib/oauth/client.rb
|
228
239
|
- lib/oauth/client/action_controller_request.rb
|
229
240
|
- lib/oauth/client/em_http.rb
|
@@ -268,18 +279,18 @@ licenses:
|
|
268
279
|
- MIT
|
269
280
|
metadata:
|
270
281
|
homepage_uri: https://github.com/oauth-xx/oauth-ruby
|
271
|
-
source_code_uri: https://github.com/oauth-xx/oauth-ruby/tree/
|
272
|
-
changelog_uri: https://github.com/oauth-xx/oauth-ruby/blob/
|
282
|
+
source_code_uri: https://github.com/oauth-xx/oauth-ruby/tree/v1.1.0
|
283
|
+
changelog_uri: https://github.com/oauth-xx/oauth-ruby/blob/v1.1.0/CHANGELOG.md
|
273
284
|
bug_tracker_uri: https://github.com/oauth-xx/oauth-ruby/issues
|
274
|
-
documentation_uri: https://www.rubydoc.info/gems/oauth/
|
285
|
+
documentation_uri: https://www.rubydoc.info/gems/oauth/1.1.0
|
275
286
|
wiki_uri: https://github.com/oauth-xx/oauth-ruby/wiki
|
276
287
|
rubygems_mfa_required: 'true'
|
277
288
|
post_install_message: |2
|
278
289
|
|
279
|
-
You have installed oauth version
|
290
|
+
You have installed oauth version 1.1.0, congratulations!
|
280
291
|
|
281
|
-
Non-commercial support for the
|
282
|
-
The only breaking change will be dropped support for Ruby 2.
|
292
|
+
Non-commercial support for the 1.x series will end by April, 2025. Please make a plan to upgrade to the next version prior to that date.
|
293
|
+
The only breaking change will be dropped support for Ruby 2.7 and any other versions which will also have reached EOL by then.
|
283
294
|
|
284
295
|
Please see:
|
285
296
|
• https://github.com/oauth-xx/oauth-ruby/blob/main/SECURITY.md
|
@@ -307,7 +318,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
307
318
|
requirements:
|
308
319
|
- - ">="
|
309
320
|
- !ruby/object:Gem::Version
|
310
|
-
version: '2.
|
321
|
+
version: '2.7'
|
311
322
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
312
323
|
requirements:
|
313
324
|
- - ">="
|
data/bin/oauth
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "oauth"
|
5
|
-
require "oauth/cli"
|
6
|
-
|
7
|
-
# don't dump a backtrace on a ^C
|
8
|
-
Signal.trap("INT") do
|
9
|
-
puts
|
10
|
-
exit(1)
|
11
|
-
end
|
12
|
-
ARGV << "help" if ARGV.empty?
|
13
|
-
command = ARGV.shift
|
14
|
-
|
15
|
-
OAuth::CLI.new($stdout, $stdin, $stderr, command, ARGV).run
|
@@ -1,73 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module OAuth
|
4
|
-
class CLI
|
5
|
-
class AuthorizeCommand < BaseCommand
|
6
|
-
def required_options
|
7
|
-
[:uri]
|
8
|
-
end
|
9
|
-
|
10
|
-
def _run
|
11
|
-
request_token = get_request_token
|
12
|
-
|
13
|
-
if request_token.callback_confirmed?
|
14
|
-
puts "Server appears to support OAuth 1.0a; enabling support."
|
15
|
-
options[:version] = "1.0a"
|
16
|
-
end
|
17
|
-
|
18
|
-
puts "Please visit this url to authorize:"
|
19
|
-
puts request_token.authorize_url
|
20
|
-
|
21
|
-
# parameters for OAuth 1.0a
|
22
|
-
oauth_verifier = ask_user_for_verifier
|
23
|
-
|
24
|
-
verbosely_get_access_token(request_token, oauth_verifier)
|
25
|
-
end
|
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
|
36
|
-
|
37
|
-
def get_consumer
|
38
|
-
OAuth::Consumer.new \
|
39
|
-
options[:oauth_consumer_key],
|
40
|
-
options[:oauth_consumer_secret],
|
41
|
-
access_token_url: options[:access_token_url],
|
42
|
-
authorize_url: options[:authorize_url],
|
43
|
-
request_token_url: options[:request_token_url],
|
44
|
-
scheme: options[:scheme],
|
45
|
-
http_method: options[:method].to_s.downcase.to_sym
|
46
|
-
end
|
47
|
-
|
48
|
-
def ask_user_for_verifier
|
49
|
-
if options[:version] == "1.0a"
|
50
|
-
puts "Please enter the verification code provided by the SP (oauth_verifier):"
|
51
|
-
@stdin.gets.chomp
|
52
|
-
else
|
53
|
-
puts "Press return to continue..."
|
54
|
-
@stdin.gets
|
55
|
-
nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def verbosely_get_access_token(request_token, oauth_verifier)
|
60
|
-
access_token = request_token.get_access_token(oauth_verifier: oauth_verifier)
|
61
|
-
|
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
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,214 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module OAuth
|
4
|
-
class CLI
|
5
|
-
class BaseCommand
|
6
|
-
def initialize(stdout, stdin, stderr, arguments)
|
7
|
-
@stdout = stdout
|
8
|
-
@stdin = stdin
|
9
|
-
@stderr = stderr
|
10
|
-
|
11
|
-
@options = {}
|
12
|
-
option_parser.parse!(arguments)
|
13
|
-
end
|
14
|
-
|
15
|
-
def run
|
16
|
-
missing = required_options - options.keys
|
17
|
-
if missing.empty?
|
18
|
-
_run
|
19
|
-
else
|
20
|
-
show_missing(missing)
|
21
|
-
puts option_parser.help
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def required_options
|
26
|
-
[]
|
27
|
-
end
|
28
|
-
|
29
|
-
protected
|
30
|
-
|
31
|
-
attr_reader :options
|
32
|
-
|
33
|
-
def show_missing(array)
|
34
|
-
array = array.map { |s| "--#{s}" }.join(" ")
|
35
|
-
OAuth::CLI.puts_red "Options missing to OAuth CLI: #{array}"
|
36
|
-
end
|
37
|
-
|
38
|
-
def xmpp?
|
39
|
-
options[:xmpp]
|
40
|
-
end
|
41
|
-
|
42
|
-
def verbose?
|
43
|
-
options[:verbose]
|
44
|
-
end
|
45
|
-
|
46
|
-
def puts(string = nil)
|
47
|
-
@stdout.puts(string)
|
48
|
-
end
|
49
|
-
|
50
|
-
def alert(string = nil)
|
51
|
-
@stderr.puts(string)
|
52
|
-
end
|
53
|
-
|
54
|
-
def parameters
|
55
|
-
@parameters ||= begin
|
56
|
-
escaped_pairs = options[:params].collect do |pair|
|
57
|
-
if /:/.match?(pair)
|
58
|
-
Hash[*pair.split(":", 2)].collect do |k, v|
|
59
|
-
[CGI.escape(k.strip), CGI.escape(v.strip)].join("=")
|
60
|
-
end
|
61
|
-
else
|
62
|
-
pair
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
querystring = escaped_pairs * "&"
|
67
|
-
cli_params = CGI.parse(querystring)
|
68
|
-
|
69
|
-
{
|
70
|
-
"oauth_consumer_key" => options[:oauth_consumer_key],
|
71
|
-
"oauth_nonce" => options[:oauth_nonce],
|
72
|
-
"oauth_timestamp" => options[:oauth_timestamp],
|
73
|
-
"oauth_token" => options[:oauth_token],
|
74
|
-
"oauth_signature_method" => options[:oauth_signature_method],
|
75
|
-
"oauth_version" => options[:oauth_version]
|
76
|
-
}.reject { |_k, v| v.nil? || v == "" }.merge(cli_params)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def option_parser
|
81
|
-
@option_parser ||= OptionParser.new do |opts|
|
82
|
-
opts.banner = "Usage: oauth <command> [ARGS]"
|
83
|
-
|
84
|
-
_option_parser_defaults
|
85
|
-
_option_parser_common(opts)
|
86
|
-
_option_parser_sign_and_query(opts)
|
87
|
-
_option_parser_authorization(opts)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def _option_parser_defaults
|
92
|
-
options[:oauth_nonce] = OAuth::Helper.generate_key
|
93
|
-
options[:oauth_signature_method] = "HMAC-SHA1"
|
94
|
-
options[:oauth_timestamp] = OAuth::Helper.generate_timestamp
|
95
|
-
options[:oauth_version] = "1.0"
|
96
|
-
options[:method] = :post
|
97
|
-
options[:params] = []
|
98
|
-
options[:scheme] = :header
|
99
|
-
options[:version] = "1.0"
|
100
|
-
end
|
101
|
-
|
102
|
-
def _option_parser_common(opts)
|
103
|
-
## Common Options
|
104
|
-
|
105
|
-
opts.on("-B", "--body", "Use the request body for OAuth parameters.") do
|
106
|
-
options[:scheme] = :body
|
107
|
-
end
|
108
|
-
|
109
|
-
opts.on("--consumer-key KEY", "Specifies the consumer key to use.") do |v|
|
110
|
-
options[:oauth_consumer_key] = v
|
111
|
-
end
|
112
|
-
|
113
|
-
opts.on("--consumer-secret SECRET", "Specifies the consumer secret to use.") do |v|
|
114
|
-
options[:oauth_consumer_secret] = v
|
115
|
-
end
|
116
|
-
|
117
|
-
opts.on("-H", "--header", "Use the 'Authorization' header for OAuth parameters (default).") do
|
118
|
-
options[:scheme] = :header
|
119
|
-
end
|
120
|
-
|
121
|
-
opts.on("-Q", "--query-string", "Use the query string for OAuth parameters.") do
|
122
|
-
options[:scheme] = :query_string
|
123
|
-
end
|
124
|
-
|
125
|
-
opts.on("-O", "--options FILE", "Read options from a file") do |v|
|
126
|
-
arguments = open(v).readlines.map { |l| l.chomp.split }.flatten
|
127
|
-
options2 = parse_options(arguments)
|
128
|
-
options.merge!(options2)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def _option_parser_sign_and_query(opts)
|
133
|
-
opts.separator("\n options for signing and querying")
|
134
|
-
|
135
|
-
opts.on("--method METHOD", "Specifies the method (e.g. GET) to use when signing.") do |v|
|
136
|
-
options[:method] = v
|
137
|
-
end
|
138
|
-
|
139
|
-
opts.on("--nonce NONCE", "Specifies the nonce to use.") do |v|
|
140
|
-
options[:oauth_nonce] = v
|
141
|
-
end
|
142
|
-
|
143
|
-
opts.on("--parameters PARAMS", "Specifies the parameters to use when signing.") do |v|
|
144
|
-
options[:params] << v
|
145
|
-
end
|
146
|
-
|
147
|
-
opts.on("--signature-method METHOD", "Specifies the signature method to use; defaults to HMAC-SHA1.") do |v|
|
148
|
-
options[:oauth_signature_method] = v
|
149
|
-
end
|
150
|
-
|
151
|
-
opts.on("--token TOKEN", "Specifies the token to use.") do |v|
|
152
|
-
options[:oauth_token] = v
|
153
|
-
end
|
154
|
-
|
155
|
-
opts.on("--secret SECRET", "Specifies the token secret to use.") do |v|
|
156
|
-
options[:oauth_token_secret] = v
|
157
|
-
end
|
158
|
-
|
159
|
-
opts.on("--timestamp TIMESTAMP", "Specifies the timestamp to use.") do |v|
|
160
|
-
options[:oauth_timestamp] = v
|
161
|
-
end
|
162
|
-
|
163
|
-
opts.on("--realm REALM", "Specifies the realm to use.") do |v|
|
164
|
-
options[:realm] = v
|
165
|
-
end
|
166
|
-
|
167
|
-
opts.on("--uri URI", "Specifies the URI to use when signing.") do |v|
|
168
|
-
options[:uri] = v
|
169
|
-
end
|
170
|
-
|
171
|
-
opts.on("--version [VERSION]", "Specifies the OAuth version to use.") do |v|
|
172
|
-
options[:oauth_version] = v
|
173
|
-
end
|
174
|
-
|
175
|
-
opts.on("--no-version", "Omit oauth_version.") do
|
176
|
-
options[:oauth_version] = nil
|
177
|
-
end
|
178
|
-
|
179
|
-
opts.on("--xmpp", "Generate XMPP stanzas.") do
|
180
|
-
options[:xmpp] = true
|
181
|
-
options[:method] ||= "iq"
|
182
|
-
end
|
183
|
-
|
184
|
-
opts.on("-v", "--verbose", "Be verbose.") do
|
185
|
-
options[:verbose] = true
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
def _option_parser_authorization(opts)
|
190
|
-
opts.separator("\n options for authorization")
|
191
|
-
|
192
|
-
opts.on("--access-token-url URL", "Specifies the access token URL.") do |v|
|
193
|
-
options[:access_token_url] = v
|
194
|
-
end
|
195
|
-
|
196
|
-
opts.on("--authorize-url URL", "Specifies the authorization URL.") do |v|
|
197
|
-
options[:authorize_url] = v
|
198
|
-
end
|
199
|
-
|
200
|
-
opts.on("--callback-url URL", "Specifies a callback URL.") do |v|
|
201
|
-
options[:oauth_callback] = v
|
202
|
-
end
|
203
|
-
|
204
|
-
opts.on("--request-token-url URL", "Specifies the request token URL.") do |v|
|
205
|
-
options[:request_token_url] = v
|
206
|
-
end
|
207
|
-
|
208
|
-
opts.on("--scope SCOPE", "Specifies the scope (Google-specific).") do |v|
|
209
|
-
options[:scope] = v
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module OAuth
|
4
|
-
class CLI
|
5
|
-
class HelpCommand < BaseCommand
|
6
|
-
def run
|
7
|
-
puts <<-EOT
|
8
|
-
Usage: oauth COMMAND [ARGS]
|
9
|
-
|
10
|
-
Available oauth commands are:
|
11
|
-
a, authorize Obtain an access token and secret for a user
|
12
|
-
q, query Query a protected resource
|
13
|
-
s, sign Generate an OAuth signature
|
14
|
-
|
15
|
-
In addition to those, there are:
|
16
|
-
v, version Displays the current version of the library (or --version, -v)
|
17
|
-
h, help Displays this help (or --help, -h)
|
18
|
-
|
19
|
-
Tip: All commands can be run without args for specific help.
|
20
|
-
|
21
|
-
|
22
|
-
EOT
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module OAuth
|
4
|
-
class CLI
|
5
|
-
class QueryCommand < BaseCommand
|
6
|
-
extend OAuth::Helper
|
7
|
-
|
8
|
-
def required_options
|
9
|
-
%i[oauth_consumer_key oauth_consumer_secret oauth_token oauth_token_secret]
|
10
|
-
end
|
11
|
-
|
12
|
-
def _run
|
13
|
-
consumer = OAuth::Consumer.new(options[:oauth_consumer_key], options[:oauth_consumer_secret],
|
14
|
-
scheme: options[:scheme])
|
15
|
-
|
16
|
-
access_token = OAuth::AccessToken.new(consumer, options[:oauth_token], options[:oauth_token_secret])
|
17
|
-
|
18
|
-
# append params to the URL
|
19
|
-
uri = URI.parse(options[:uri])
|
20
|
-
params = parameters.map do |k, v|
|
21
|
-
Array(v).map do |v2|
|
22
|
-
"#{OAuth::Helper.escape(k)}=#{OAuth::Helper.escape(v2)}"
|
23
|
-
end * "&"
|
24
|
-
end
|
25
|
-
uri.query = [uri.query, *params].compact * "&"
|
26
|
-
puts uri.to_s
|
27
|
-
|
28
|
-
response = access_token.request(options[:method].to_s.downcase.to_sym, uri.to_s)
|
29
|
-
puts "#{response.code} #{response.message}"
|
30
|
-
puts response.body
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module OAuth
|
4
|
-
class CLI
|
5
|
-
class SignCommand < BaseCommand
|
6
|
-
def required_options
|
7
|
-
%i[oauth_consumer_key oauth_consumer_secret oauth_token oauth_token_secret]
|
8
|
-
end
|
9
|
-
|
10
|
-
def _run
|
11
|
-
request = OAuth::RequestProxy.proxy \
|
12
|
-
"method" => options[:method],
|
13
|
-
"uri" => options[:uri],
|
14
|
-
"parameters" => parameters
|
15
|
-
|
16
|
-
puts_verbose_parameters(request) if verbose?
|
17
|
-
|
18
|
-
request.sign! \
|
19
|
-
consumer_secret: options[:oauth_consumer_secret],
|
20
|
-
token_secret: options[:oauth_token_secret]
|
21
|
-
|
22
|
-
if verbose?
|
23
|
-
puts_verbose_request(request)
|
24
|
-
else
|
25
|
-
puts request.oauth_signature
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def puts_verbose_parameters(request)
|
30
|
-
puts "OAuth parameters:"
|
31
|
-
request.oauth_parameters.each do |k, v|
|
32
|
-
puts " #{[k, v].join(": ")}"
|
33
|
-
end
|
34
|
-
puts
|
35
|
-
|
36
|
-
if request.non_oauth_parameters.any?
|
37
|
-
puts "Parameters:"
|
38
|
-
request.non_oauth_parameters.each do |k, v|
|
39
|
-
puts " #{[k, v].join(": ")}"
|
40
|
-
end
|
41
|
-
puts
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def puts_verbose_request(request)
|
46
|
-
puts "Method: #{request.method}"
|
47
|
-
puts "URI: #{request.uri}"
|
48
|
-
unless options[:xmpp]
|
49
|
-
puts "Normalized params: #{request.normalized_parameters}"
|
50
|
-
end
|
51
|
-
puts "Signature base string: #{request.signature_base_string}"
|
52
|
-
|
53
|
-
if xmpp?
|
54
|
-
puts
|
55
|
-
puts "XMPP Stanza:"
|
56
|
-
puts xmpp_output(request)
|
57
|
-
puts
|
58
|
-
puts "Note: You may want to use bare JIDs in your URI."
|
59
|
-
puts
|
60
|
-
else
|
61
|
-
puts "OAuth Request URI: #{request.signed_uri}"
|
62
|
-
puts "Request URI: #{request.signed_uri(with_oauth: false)}"
|
63
|
-
puts "Authorization header: #{request.oauth_header(realm: options[:realm])}"
|
64
|
-
end
|
65
|
-
puts "Signature: #{request.oauth_signature}"
|
66
|
-
puts "Escaped signature: #{OAuth::Helper.escape(request.oauth_signature)}"
|
67
|
-
end
|
68
|
-
|
69
|
-
def xmpp_output(request)
|
70
|
-
<<-EOS
|
71
|
-
<oauth xmlns='urn:xmpp:oauth:0'>
|
72
|
-
<oauth_consumer_key>#{request.oauth_consumer_key}</oauth_consumer_key>
|
73
|
-
<oauth_token>#{request.oauth_token}</oauth_token>
|
74
|
-
<oauth_signature_method>#{request.oauth_signature_method}</oauth_signature_method>
|
75
|
-
<oauth_signature>#{request.oauth_signature}</oauth_signature>
|
76
|
-
<oauth_timestamp>#{request.oauth_timestamp}</oauth_timestamp>
|
77
|
-
<oauth_nonce>#{request.oauth_nonce}</oauth_nonce>
|
78
|
-
<oauth_version>#{request.oauth_version}</oauth_version>
|
79
|
-
</oauth>
|
80
|
-
EOS
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
data/lib/oauth/cli.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "optparse"
|
4
|
-
require "oauth/cli/base_command"
|
5
|
-
require "oauth/cli/help_command"
|
6
|
-
require "oauth/cli/query_command"
|
7
|
-
require "oauth/cli/authorize_command"
|
8
|
-
require "oauth/cli/sign_command"
|
9
|
-
require "oauth/cli/version_command"
|
10
|
-
require "active_support/core_ext/string/inflections"
|
11
|
-
|
12
|
-
module OAuth
|
13
|
-
class CLI
|
14
|
-
def self.puts_red(string)
|
15
|
-
puts "\033[0;91m#{string}\033[0m"
|
16
|
-
end
|
17
|
-
|
18
|
-
ALIASES = {
|
19
|
-
"h" => "help",
|
20
|
-
"v" => "version",
|
21
|
-
"q" => "query",
|
22
|
-
"a" => "authorize",
|
23
|
-
"s" => "sign"
|
24
|
-
}.freeze
|
25
|
-
|
26
|
-
def initialize(stdout, stdin, stderr, command, arguments)
|
27
|
-
klass = get_command_class(parse_command(command))
|
28
|
-
@command = klass.new(stdout, stdin, stderr, arguments)
|
29
|
-
@help_command = HelpCommand.new(stdout, stdin, stderr, [])
|
30
|
-
end
|
31
|
-
|
32
|
-
def run
|
33
|
-
@command.run
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def get_command_class(command)
|
39
|
-
Object.const_get("OAuth::CLI::#{command.camelize}Command")
|
40
|
-
end
|
41
|
-
|
42
|
-
def parse_command(command)
|
43
|
-
case command = command.to_s.downcase
|
44
|
-
when "--version", "-v"
|
45
|
-
"version"
|
46
|
-
when "--help", "-h", nil, ""
|
47
|
-
"help"
|
48
|
-
when *ALIASES.keys
|
49
|
-
ALIASES[command]
|
50
|
-
when *ALIASES.values
|
51
|
-
command
|
52
|
-
else
|
53
|
-
OAuth::CLI.puts_red "Command '#{command}' not found"
|
54
|
-
"help"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|