oauth2 1.3.1 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +170 -0
- data/CODE_OF_CONDUCT.md +133 -0
- data/LICENSE +22 -0
- data/README.md +137 -23
- data/lib/oauth2/access_token.rb +12 -4
- data/lib/oauth2/authenticator.rb +10 -0
- data/lib/oauth2/client.rb +63 -16
- data/lib/oauth2/mac_token.rb +11 -3
- data/lib/oauth2/response.rb +5 -3
- data/lib/oauth2/strategy/assertion.rb +3 -3
- data/lib/oauth2/strategy/password.rb +2 -2
- data/lib/oauth2/version.rb +10 -4
- data/spec/helper.rb +37 -0
- data/spec/oauth2/access_token_spec.rb +216 -0
- data/spec/oauth2/authenticator_spec.rb +84 -0
- data/spec/oauth2/client_spec.rb +506 -0
- data/spec/oauth2/mac_token_spec.rb +117 -0
- data/spec/oauth2/response_spec.rb +90 -0
- data/spec/oauth2/strategy/assertion_spec.rb +58 -0
- data/spec/oauth2/strategy/auth_code_spec.rb +107 -0
- data/spec/oauth2/strategy/base_spec.rb +5 -0
- data/spec/oauth2/strategy/client_credentials_spec.rb +69 -0
- data/spec/oauth2/strategy/implicit_spec.rb +26 -0
- data/spec/oauth2/strategy/password_spec.rb +55 -0
- data/spec/oauth2/version_spec.rb +23 -0
- metadata +219 -24
- data/.document +0 -5
- data/CONTRIBUTING.md +0 -18
- data/LICENSE.md +0 -20
- data/oauth2.gemspec +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 74ca15f9b1935885fe123c9b0801b9f0605c1bfa904bebe371d201a61b559f31
|
4
|
+
data.tar.gz: 3b719ec6748493cba5112dfca8ebff22b13c0c9690330d4422f9d81b1abf5185
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ec3c9c311effac7f8864c2dc3d7332761ee6a986f2924adec3b77620abe3dc63984d1c01e9ca0a1283907a5b2ba23ee31dfd4bd630fa7d803fba116ba1e652d
|
7
|
+
data.tar.gz: 1e1d37d5953bdd7e03e13f697648e56afdb63ea54bbdbaee7ee229302149c5047c533a15d6498a355ef78d17d991d79ce8f94fe8728229431e3fad5c3132a9ad
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
## unreleased
|
5
|
+
|
6
|
+
## [1.4.7] - 2021-03-18
|
7
|
+
|
8
|
+
- [#541](https://github.com/oauth-xx/oauth2/pull/541) - Backport fix to expires_at handling [#533](https://github.com/oauth-xx/oauth2/pull/533) to 1-4-stable branch. (@dobon)
|
9
|
+
|
10
|
+
## [1.4.6] - 2021-03-18
|
11
|
+
|
12
|
+
- [#540](https://github.com/oauth-xx/oauth2/pull/540) - Add VERSION constant (@pboling)
|
13
|
+
- [#537](https://github.com/oauth-xx/oauth2/pull/537) - Fix crash in OAuth2::Client#get_token (@anderscarling)
|
14
|
+
- [#538](https://github.com/oauth-xx/oauth2/pull/538) - Remove reliance on globally included OAuth2 in tests for version 1.4 (@anderscarling)
|
15
|
+
|
16
|
+
## [1.4.5] - 2021-03-18
|
17
|
+
|
18
|
+
- [#535](https://github.com/oauth-xx/oauth2/pull/535) - Compatibility with range of supported Ruby OpenSSL versions, Rubocop updates, Github Actions (@pboling)
|
19
|
+
- [#518](https://github.com/oauth-xx/oauth2/pull/518) - Add extract_access_token option to OAuth2::Client (@jonspalmer)
|
20
|
+
|
21
|
+
## [1.4.4] - 2020-02-12
|
22
|
+
|
23
|
+
- [#408](https://github.com/oauth-xx/oauth2/pull/408) - Fixed expires_at for formatted time (@Lomey)
|
24
|
+
|
25
|
+
## [1.4.3] - 2020-01-29
|
26
|
+
|
27
|
+
- [#483](https://github.com/oauth-xx/oauth2/pull/483) - add project metadata to gemspec (@orien)
|
28
|
+
- [#495](https://github.com/oauth-xx/oauth2/pull/495) - support additional types of access token requests (@SteveyblamFreeagent, @thomcorley, @dgholz)
|
29
|
+
- Adds support for private_key_jwt and tls_client_auth
|
30
|
+
- [#433](https://github.com/oauth-xx/oauth2/pull/433) - allow field names with square brackets and numbers in params (@asm256)
|
31
|
+
|
32
|
+
## [1.4.2] - 2019-10-01
|
33
|
+
|
34
|
+
- [#478](https://github.com/oauth-xx/oauth2/pull/478) - support latest version of faraday & fix build (@pboling)
|
35
|
+
- officially support Ruby 2.6 and truffleruby
|
36
|
+
|
37
|
+
## [1.4.1] - 2018-10-13
|
38
|
+
|
39
|
+
- [#417](https://github.com/oauth-xx/oauth2/pull/417) - update jwt dependency (@thewoolleyman)
|
40
|
+
- [#419](https://github.com/oauth-xx/oauth2/pull/419) - remove rubocop dependency (temporary, added back in [#423](https://github.com/oauth-xx/oauth2/pull/423)) (@pboling)
|
41
|
+
- [#418](https://github.com/oauth-xx/oauth2/pull/418) - update faraday dependency (@pboling)
|
42
|
+
- [#420](https://github.com/oauth-xx/oauth2/pull/420) - update [oauth2.gemspec](https://github.com/oauth-xx/oauth2/blob/1-4-stable/oauth2.gemspec) (@pboling)
|
43
|
+
- [#421](https://github.com/oauth-xx/oauth2/pull/421) - fix [CHANGELOG.md](https://github.com/oauth-xx/oauth2/blob/1-4-stable/CHANGELOG.md) for previous releases (@pboling)
|
44
|
+
- [#422](https://github.com/oauth-xx/oauth2/pull/422) - update [LICENSE](https://github.com/oauth-xx/oauth2/blob/1-4-stable/LICENSE) and [README.md](https://github.com/oauth-xx/oauth2/blob/1-4-stable/README.md) (@pboling)
|
45
|
+
- [#423](https://github.com/oauth-xx/oauth2/pull/423) - update [builds](https://travis-ci.org/oauth-xx/oauth2/builds), [Rakefile](https://github.com/oauth-xx/oauth2/blob/1-4-stable/Rakefile) (@pboling)
|
46
|
+
- officially document supported Rubies
|
47
|
+
* Ruby 1.9.3
|
48
|
+
* Ruby 2.0.0
|
49
|
+
* Ruby 2.1
|
50
|
+
* Ruby 2.2
|
51
|
+
* [JRuby 1.7][jruby-1.7] (targets MRI v1.9)
|
52
|
+
* [JRuby 9.0][jruby-9.0] (targets MRI v2.0)
|
53
|
+
* Ruby 2.3
|
54
|
+
* Ruby 2.4
|
55
|
+
* Ruby 2.5
|
56
|
+
* [JRuby 9.1][jruby-9.1] (targets MRI v2.3)
|
57
|
+
* [JRuby 9.2][jruby-9.2] (targets MRI v2.5)
|
58
|
+
|
59
|
+
[jruby-1.7]: https://www.jruby.org/2017/05/11/jruby-1-7-27.html
|
60
|
+
[jruby-9.0]: https://www.jruby.org/2016/01/26/jruby-9-0-5-0.html
|
61
|
+
[jruby-9.1]: https://www.jruby.org/2017/05/16/jruby-9-1-9-0.html
|
62
|
+
[jruby-9.2]: https://www.jruby.org/2018/05/24/jruby-9-2-0-0.html
|
63
|
+
|
64
|
+
## [1.4.0] - 2017-06-09
|
65
|
+
|
66
|
+
- Drop Ruby 1.8.7 support (@sferik)
|
67
|
+
- Fix some RuboCop offenses (@sferik)
|
68
|
+
- _Dependency_: Remove Yardstick (@sferik)
|
69
|
+
- _Dependency_: Upgrade Faraday to 0.12 (@sferik)
|
70
|
+
|
71
|
+
## [1.3.1] - 2017-03-03
|
72
|
+
|
73
|
+
- Add support for Ruby 2.4.0 (@pschambacher)
|
74
|
+
- _Dependency_: Upgrade Faraday to Faraday 0.11 (@mcfiredrill, @rhymes, @pschambacher)
|
75
|
+
|
76
|
+
## [1.3.0] - 2016-12-28
|
77
|
+
|
78
|
+
- Add support for header-based authentication to the `Client` so it can be used across the library (@bjeanes)
|
79
|
+
- Default to header-based authentication when getting a token from an authorisation code (@maletor)
|
80
|
+
- **Breaking**: Allow an `auth_scheme` (`:basic_auth` or `:request_body`) to be set on the client, defaulting to `:request_body` to maintain backwards compatibility (@maletor, @bjeanes)
|
81
|
+
- Handle `redirect_uri` according to the OAuth 2 spec, so it is passed on redirect and at the point of token exchange (@bjeanes)
|
82
|
+
- Refactor handling of encoding of error responses (@urkle)
|
83
|
+
- Avoid instantiating an `Error` if there is no error to raise (@urkle)
|
84
|
+
- Add support for Faraday 0.10 (@rhymes)
|
85
|
+
|
86
|
+
## [1.2.0] - 2016-07-01
|
87
|
+
|
88
|
+
- Properly handle encoding of error responses (so we don't blow up, for example, when Google's response includes a ∞) (@Motoshi-Nishihira)
|
89
|
+
- Make a copy of the options hash in `AccessToken#from_hash` to avoid accidental mutations (@Linuus)
|
90
|
+
- Use `raise` rather than `fail` to throw exceptions (@sferik)
|
91
|
+
|
92
|
+
## [1.1.0] - 2016-01-30
|
93
|
+
|
94
|
+
- Various refactors (eliminating `Hash#merge!` usage in `AccessToken#refresh!`, use `yield` instead of `#call`, freezing mutable objects in constants, replacing constants with class variables) (@sferik)
|
95
|
+
- Add support for Rack 2, and bump various other dependencies (@sferik)
|
96
|
+
|
97
|
+
## [1.0.0] - 2014-07-09
|
98
|
+
|
99
|
+
### Added
|
100
|
+
- Add an implementation of the MAC token spec.
|
101
|
+
|
102
|
+
### Fixed
|
103
|
+
- Fix Base64.strict_encode64 incompatibility with Ruby 1.8.7.
|
104
|
+
|
105
|
+
## [0.5.0] - 2011-07-29
|
106
|
+
|
107
|
+
### Changed
|
108
|
+
- [breaking] `oauth_token` renamed to `oauth_bearer`.
|
109
|
+
- [breaking] `authorize_path` Client option renamed to `authorize_url`.
|
110
|
+
- [breaking] `access_token_path` Client option renamed to `token_url`.
|
111
|
+
- [breaking] `access_token_method` Client option renamed to `token_method`.
|
112
|
+
- [breaking] `web_server` renamed to `auth_code`.
|
113
|
+
|
114
|
+
## [0.4.1] - 2011-04-20
|
115
|
+
|
116
|
+
## [0.4.0] - 2011-04-20
|
117
|
+
|
118
|
+
## [0.3.0] - 2011-04-08
|
119
|
+
|
120
|
+
## [0.2.0] - 2011-04-01
|
121
|
+
|
122
|
+
## [0.1.1] - 2011-01-12
|
123
|
+
|
124
|
+
## [0.1.0] - 2010-10-13
|
125
|
+
|
126
|
+
## [0.0.13] + [0.0.12] + [0.0.11] - 2010-08-17
|
127
|
+
|
128
|
+
## [0.0.10] - 2010-06-19
|
129
|
+
|
130
|
+
## [0.0.9] - 2010-06-18
|
131
|
+
|
132
|
+
## [0.0.8] + [0.0.7] - 2010-04-27
|
133
|
+
|
134
|
+
## [0.0.6] - 2010-04-25
|
135
|
+
|
136
|
+
## [0.0.5] - 2010-04-23
|
137
|
+
|
138
|
+
## [0.0.4] + [0.0.3] + [0.0.2] + [0.0.1] - 2010-04-22
|
139
|
+
|
140
|
+
|
141
|
+
[0.0.1]: https://github.com/oauth-xx/oauth2/compare/311d9f4...v0.0.1
|
142
|
+
[0.0.2]: https://github.com/oauth-xx/oauth2/compare/v0.0.1...v0.0.2
|
143
|
+
[0.0.3]: https://github.com/oauth-xx/oauth2/compare/v0.0.2...v0.0.3
|
144
|
+
[0.0.4]: https://github.com/oauth-xx/oauth2/compare/v0.0.3...v0.0.4
|
145
|
+
[0.0.5]: https://github.com/oauth-xx/oauth2/compare/v0.0.4...v0.0.5
|
146
|
+
[0.0.6]: https://github.com/oauth-xx/oauth2/compare/v0.0.5...v0.0.6
|
147
|
+
[0.0.7]: https://github.com/oauth-xx/oauth2/compare/v0.0.6...v0.0.7
|
148
|
+
[0.0.8]: https://github.com/oauth-xx/oauth2/compare/v0.0.7...v0.0.8
|
149
|
+
[0.0.9]: https://github.com/oauth-xx/oauth2/compare/v0.0.8...v0.0.9
|
150
|
+
[0.0.10]: https://github.com/oauth-xx/oauth2/compare/v0.0.9...v0.0.10
|
151
|
+
[0.0.11]: https://github.com/oauth-xx/oauth2/compare/v0.0.10...v0.0.11
|
152
|
+
[0.0.12]: https://github.com/oauth-xx/oauth2/compare/v0.0.11...v0.0.12
|
153
|
+
[0.0.13]: https://github.com/oauth-xx/oauth2/compare/v0.0.12...v0.0.13
|
154
|
+
[0.1.0]: https://github.com/oauth-xx/oauth2/compare/v0.0.13...v0.1.0
|
155
|
+
[0.1.1]: https://github.com/oauth-xx/oauth2/compare/v0.1.0...v0.1.1
|
156
|
+
[0.2.0]: https://github.com/oauth-xx/oauth2/compare/v0.1.1...v0.2.0
|
157
|
+
[0.3.0]: https://github.com/oauth-xx/oauth2/compare/v0.2.0...v0.3.0
|
158
|
+
[0.4.0]: https://github.com/oauth-xx/oauth2/compare/v0.3.0...v0.4.0
|
159
|
+
[0.4.1]: https://github.com/oauth-xx/oauth2/compare/v0.4.0...v0.4.1
|
160
|
+
[0.5.0]: https://github.com/oauth-xx/oauth2/compare/v0.4.1...v0.5.0
|
161
|
+
[1.0.0]: https://github.com/oauth-xx/oauth2/compare/v0.9.4...v1.0.0
|
162
|
+
[1.1.0]: https://github.com/oauth-xx/oauth2/compare/v1.0.0...v1.1.0
|
163
|
+
[1.2.0]: https://github.com/oauth-xx/oauth2/compare/v1.1.0...v1.2.0
|
164
|
+
[1.3.0]: https://github.com/oauth-xx/oauth2/compare/v1.2.0...v1.3.0
|
165
|
+
[1.3.1]: https://github.com/oauth-xx/oauth2/compare/v1.3.0...v1.3.1
|
166
|
+
[1.4.0]: https://github.com/oauth-xx/oauth2/compare/v1.3.1...v1.4.0
|
167
|
+
[1.4.1]: https://github.com/oauth-xx/oauth2/compare/v1.4.0...v1.4.1
|
168
|
+
[1.4.2]: https://github.com/oauth-xx/oauth2/compare/v1.4.1...v1.4.2
|
169
|
+
[1.4.3]: https://github.com/oauth-xx/oauth2/compare/v1.4.2...v1.4.3
|
170
|
+
[unreleased]: https://github.com/oauth-xx/oauth2/compare/v1.4.1...HEAD
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
|
2
|
+
# Contributor Covenant Code of Conduct
|
3
|
+
|
4
|
+
## Our Pledge
|
5
|
+
|
6
|
+
We as members, contributors, and leaders pledge to make participation in our
|
7
|
+
community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
9
|
+
identity and expression, level of experience, education, socio-economic status,
|
10
|
+
nationality, personal appearance, race, religion, or sexual identity
|
11
|
+
and orientation.
|
12
|
+
|
13
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
14
|
+
diverse, inclusive, and healthy community.
|
15
|
+
|
16
|
+
## Our Standards
|
17
|
+
|
18
|
+
Examples of behavior that contributes to a positive environment for our
|
19
|
+
community include:
|
20
|
+
|
21
|
+
* Demonstrating empathy and kindness toward other people
|
22
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
23
|
+
* Giving and gracefully accepting constructive feedback
|
24
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
25
|
+
and learning from the experience
|
26
|
+
* Focusing on what is best not just for us as individuals, but for the
|
27
|
+
overall community
|
28
|
+
|
29
|
+
Examples of unacceptable behavior include:
|
30
|
+
|
31
|
+
* The use of sexualized language or imagery, and sexual attention or
|
32
|
+
advances of any kind
|
33
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
34
|
+
* Public or private harassment
|
35
|
+
* Publishing others' private information, such as a physical or email
|
36
|
+
address, without their explicit permission
|
37
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
38
|
+
professional setting
|
39
|
+
|
40
|
+
## Enforcement Responsibilities
|
41
|
+
|
42
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
43
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
44
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
45
|
+
or harmful.
|
46
|
+
|
47
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
48
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
49
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
50
|
+
decisions when appropriate.
|
51
|
+
|
52
|
+
## Scope
|
53
|
+
|
54
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
55
|
+
an individual is officially representing the community in public spaces.
|
56
|
+
Examples of representing our community include using an official e-mail address,
|
57
|
+
posting via an official social media account, or acting as an appointed
|
58
|
+
representative at an online or offline event.
|
59
|
+
|
60
|
+
## Enforcement
|
61
|
+
|
62
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
63
|
+
reported to the community leaders responsible for enforcement at
|
64
|
+
[INSERT CONTACT METHOD].
|
65
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
66
|
+
|
67
|
+
All community leaders are obligated to respect the privacy and security of the
|
68
|
+
reporter of any incident.
|
69
|
+
|
70
|
+
## Enforcement Guidelines
|
71
|
+
|
72
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
73
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
74
|
+
|
75
|
+
### 1. Correction
|
76
|
+
|
77
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
78
|
+
unprofessional or unwelcome in the community.
|
79
|
+
|
80
|
+
**Consequence**: A private, written warning from community leaders, providing
|
81
|
+
clarity around the nature of the violation and an explanation of why the
|
82
|
+
behavior was inappropriate. A public apology may be requested.
|
83
|
+
|
84
|
+
### 2. Warning
|
85
|
+
|
86
|
+
**Community Impact**: A violation through a single incident or series
|
87
|
+
of actions.
|
88
|
+
|
89
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
90
|
+
interaction with the people involved, including unsolicited interaction with
|
91
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
92
|
+
includes avoiding interactions in community spaces as well as external channels
|
93
|
+
like social media. Violating these terms may lead to a temporary or
|
94
|
+
permanent ban.
|
95
|
+
|
96
|
+
### 3. Temporary Ban
|
97
|
+
|
98
|
+
**Community Impact**: A serious violation of community standards, including
|
99
|
+
sustained inappropriate behavior.
|
100
|
+
|
101
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
102
|
+
communication with the community for a specified period of time. No public or
|
103
|
+
private interaction with the people involved, including unsolicited interaction
|
104
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
105
|
+
Violating these terms may lead to a permanent ban.
|
106
|
+
|
107
|
+
### 4. Permanent Ban
|
108
|
+
|
109
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
110
|
+
standards, including sustained inappropriate behavior, harassment of an
|
111
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
112
|
+
|
113
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
114
|
+
the community.
|
115
|
+
|
116
|
+
## Attribution
|
117
|
+
|
118
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
119
|
+
version 2.0, available at
|
120
|
+
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
|
121
|
+
|
122
|
+
Community Impact Guidelines were inspired by
|
123
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
124
|
+
|
125
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
126
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
|
127
|
+
at [https://www.contributor-covenant.org/translations][translations].
|
128
|
+
|
129
|
+
[homepage]: https://www.contributor-covenant.org
|
130
|
+
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
|
131
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
132
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
133
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011 - 2013 Michael Bleigh and Intridea, Inc.
|
4
|
+
Copyright (c) 2017 - 2018 oauth-xx organization, https://github.com/oauth-xx
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,30 +1,78 @@
|
|
1
1
|
# OAuth2
|
2
2
|
|
3
|
+
If you need the readme for a released version of the gem please find it below:
|
4
|
+
|
5
|
+
| Version | Release Date | Readme |
|
6
|
+
|----------|--------------|----------------------------------------------------------|
|
7
|
+
| 1.4.7 | Mar 18, 2021 | https://github.com/oauth-xx/oauth2/blob/v1.4.7/README.md |
|
8
|
+
| 1.4.6 | Mar 18, 2021 | https://github.com/oauth-xx/oauth2/blob/v1.4.6/README.md |
|
9
|
+
| 1.4.5 | Mar 18, 2021 | https://github.com/oauth-xx/oauth2/blob/v1.4.5/README.md |
|
10
|
+
| 1.4.4 | Feb 12, 2020 | https://github.com/oauth-xx/oauth2/blob/v1.4.4/README.md |
|
11
|
+
| 1.4.3 | Jan 29, 2020 | https://github.com/oauth-xx/oauth2/blob/v1.4.3/README.md |
|
12
|
+
| 1.4.2 | Oct 1, 2019 | https://github.com/oauth-xx/oauth2/blob/v1.4.2/README.md |
|
13
|
+
| 1.4.1 | Oct 13, 2018 | https://github.com/oauth-xx/oauth2/blob/v1.4.1/README.md |
|
14
|
+
| 1.4.0 | Jun 9, 2017 | https://github.com/oauth-xx/oauth2/blob/v1.4.0/README.md |
|
15
|
+
| 1.3.1 | Mar 3, 2017 | https://github.com/oauth-xx/oauth2/blob/v1.3.1/README.md |
|
16
|
+
| 1.3.0 | Dec 27, 2016 | https://github.com/oauth-xx/oauth2/blob/v1.3.0/README.md |
|
17
|
+
| 1.2.0 | Jun 30, 2016 | https://github.com/oauth-xx/oauth2/blob/v1.2.0/README.md |
|
18
|
+
| 1.1.0 | Jan 30, 2016 | https://github.com/oauth-xx/oauth2/blob/v1.1.0/README.md |
|
19
|
+
| 1.0.0 | May 23, 2014 | https://github.com/oauth-xx/oauth2/blob/v1.0.0/README.md |
|
20
|
+
| < 1.0.0 | Find here | https://github.com/oauth-xx/oauth2/tags |
|
21
|
+
|
3
22
|
[][gem]
|
4
|
-
[][gem]
|
24
|
+
[][gem]
|
25
|
+
[][travis]
|
26
|
+
[][github-actions]
|
27
|
+
[][codeclimate-coverage]
|
28
|
+
[][codeclimate-maintainability]
|
29
|
+
[][depfu]
|
30
|
+
[][code-triage]
|
31
|
+
[](https://gitter.im/oauth-xx/oauth2)
|
32
|
+
[][source-license]
|
33
|
+
[][inch-ci]
|
8
34
|
|
9
35
|
[gem]: https://rubygems.org/gems/oauth2
|
10
|
-
[travis]: http://travis-ci.org/
|
11
|
-
[
|
12
|
-
[
|
13
|
-
[
|
36
|
+
[travis]: http://travis-ci.org/oauth-xx/oauth2
|
37
|
+
[github-actions]: https://actions-badge.atrox.dev/oauth-xx/oauth2/goto
|
38
|
+
[coveralls]: https://coveralls.io/r/oauth-xx/oauth2
|
39
|
+
[codeclimate-maintainability]: https://codeclimate.com/github/oauth-xx/oauth2/maintainability
|
40
|
+
[codeclimate-coverage]: https://codeclimate.com/github/oauth-xx/oauth2/test_coverage
|
41
|
+
[depfu]: https://depfu.com/github/oauth-xx/oauth2
|
42
|
+
[source-license]: https://opensource.org/licenses/MIT
|
43
|
+
[inch-ci]: http://inch-ci.org/github/oauth-xx/oauth2
|
44
|
+
[code-triage]: https://www.codetriage.com/oauth-xx/oauth2
|
45
|
+
[fossa1]: https://app.fossa.io/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2?ref=badge_shield
|
46
|
+
|
47
|
+
A Ruby wrapper for the [OAuth 2.0 specification][oauth2-spec].
|
14
48
|
|
15
|
-
|
49
|
+
[oauth2-spec]: https://oauth.net/2/
|
16
50
|
|
17
51
|
## Installation
|
18
|
-
|
52
|
+
|
53
|
+
Add this line to your application's Gemfile:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
gem 'oauth2'
|
57
|
+
```
|
58
|
+
|
59
|
+
And then execute:
|
60
|
+
|
61
|
+
$ bundle
|
62
|
+
|
63
|
+
Or install it yourself as:
|
64
|
+
|
65
|
+
$ gem install oauth2
|
19
66
|
|
20
67
|
## Resources
|
68
|
+
|
21
69
|
* [View Source on GitHub][code]
|
22
70
|
* [Report Issues on GitHub][issues]
|
23
71
|
* [Read More at the Wiki][wiki]
|
24
72
|
|
25
|
-
[code]: https://github.com/
|
26
|
-
[issues]: https://github.com/
|
27
|
-
[wiki]: https://wiki.github.com/
|
73
|
+
[code]: https://github.com/oauth-xx/oauth2
|
74
|
+
[issues]: https://github.com/oauth-xx/oauth2/issues
|
75
|
+
[wiki]: https://wiki.github.com/oauth-xx/oauth2
|
28
76
|
|
29
77
|
## Usage Examples
|
30
78
|
|
@@ -36,11 +84,12 @@ client.auth_code.authorize_url(:redirect_uri => 'http://localhost:8080/oauth2/ca
|
|
36
84
|
# => "https://example.org/oauth/authorization?response_type=code&client_id=client_id&redirect_uri=http://localhost:8080/oauth2/callback"
|
37
85
|
|
38
86
|
token = client.auth_code.get_token('authorization_code_value', :redirect_uri => 'http://localhost:8080/oauth2/callback', :headers => {'Authorization' => 'Basic some_password'})
|
39
|
-
response = token.get('/api/resource', :params => {
|
87
|
+
response = token.get('/api/resource', :params => {'query_foo' => 'bar'})
|
40
88
|
response.class.name
|
41
89
|
# => OAuth2::Response
|
42
90
|
```
|
43
91
|
## OAuth2::Response
|
92
|
+
|
44
93
|
The AccessToken methods #get, #post, #put and #delete and the generic #request
|
45
94
|
will return an instance of the #OAuth2::Response class.
|
46
95
|
|
@@ -53,12 +102,14 @@ The original response body, headers, and status can be accessed via their
|
|
53
102
|
respective methods.
|
54
103
|
|
55
104
|
## OAuth2::AccessToken
|
105
|
+
|
56
106
|
If you have an existing Access Token for a user, you can initialize an instance
|
57
107
|
using various class methods including the standard new, from_hash (if you have
|
58
108
|
a hash of the values), or from_kvform (if you have an
|
59
109
|
application/x-www-form-urlencoded encoded string of the values).
|
60
110
|
|
61
111
|
## OAuth2::Error
|
112
|
+
|
62
113
|
On 400+ status code responses, an OAuth2::Error will be raised. If it is a
|
63
114
|
standard OAuth2 error response, the body will be parsed and #code and #description will contain the values provided from the error and
|
64
115
|
error_description parameters. The #response property of OAuth2::Error will
|
@@ -70,6 +121,7 @@ instance will be returned as usual and on 400+ status code responses, the
|
|
70
121
|
Response instance will contain the OAuth2::Error instance.
|
71
122
|
|
72
123
|
## Authorization Grants
|
124
|
+
|
73
125
|
Currently the Authorization Code, Implicit, Resource Owner Password Credentials, Client Credentials, and Assertion
|
74
126
|
authentication grant types have helper strategy classes that simplify client
|
75
127
|
use. They are available via the #auth_code, #implicit, #password, #client_credentials, and #assertion methods respectively.
|
@@ -100,19 +152,38 @@ You can always use the #request method on the OAuth2::Client instance to make
|
|
100
152
|
requests for tokens for any Authentication grant type.
|
101
153
|
|
102
154
|
## Supported Ruby Versions
|
155
|
+
|
103
156
|
This library aims to support and is [tested against][travis] the following Ruby
|
104
157
|
implementations:
|
105
158
|
|
106
|
-
|
159
|
+
### Rubies with support ending at Oauth2 1.x
|
160
|
+
|
107
161
|
* Ruby 1.9.3
|
162
|
+
- [JRuby 1.7][jruby-1.7] (targets MRI v1.9)
|
163
|
+
|
108
164
|
* Ruby 2.0.0
|
165
|
+
- [JRuby 9.0][jruby-9.0] (targets MRI v2.0)
|
109
166
|
* Ruby 2.1
|
110
|
-
* Ruby 2.2
|
111
|
-
* Ruby 2.3
|
112
|
-
* Ruby 2.4
|
113
|
-
* [JRuby 9K][jruby]
|
114
167
|
|
115
|
-
|
168
|
+
---
|
169
|
+
|
170
|
+
### Rubies with continued support past Oauth2 2.x
|
171
|
+
|
172
|
+
* Ruby 2.2 - Support ends with version 2.x series
|
173
|
+
* Ruby 2.3 - Support ends with version 3.x series
|
174
|
+
- [JRuby 9.1][jruby-9.1] (targets MRI v2.3)
|
175
|
+
* Ruby 2.4 - Support ends with version 4.x series
|
176
|
+
* Ruby 2.5 - Support ends with version 5.x series
|
177
|
+
- [JRuby 9.2][jruby-9.2] (targets MRI v2.5)
|
178
|
+
- [truffleruby][truffleruby] (targets MRI 2.5)
|
179
|
+
* Ruby 2.6 - Support ends with version 6.x series
|
180
|
+
* Ruby 2.7 - Support ends with version 7.x series
|
181
|
+
|
182
|
+
[jruby-1.7]: https://www.jruby.org/2017/05/11/jruby-1-7-27.html
|
183
|
+
[jruby-9.0]: https://www.jruby.org/2016/01/26/jruby-9-0-5-0.html
|
184
|
+
[jruby-9.1]: https://www.jruby.org/2017/05/16/jruby-9-1-9-0.html
|
185
|
+
[jruby-9.2]: https://www.jruby.org/2018/05/24/jruby-9-2-0-0.html
|
186
|
+
[truffleruby]: https://github.com/oracle/truffleruby
|
116
187
|
|
117
188
|
If something doesn't work on one of these interpreters, it's a bug.
|
118
189
|
|
@@ -127,8 +198,51 @@ implementation, you will be responsible for providing patches in a timely
|
|
127
198
|
fashion. If critical issues for a particular implementation exist at the time
|
128
199
|
of a major release, support for that Ruby version may be dropped.
|
129
200
|
|
201
|
+
## Versioning
|
202
|
+
|
203
|
+
This library aims to adhere to [Semantic Versioning 2.0.0][semver].
|
204
|
+
Violations of this scheme should be reported as bugs. Specifically,
|
205
|
+
if a minor or patch version is released that breaks backward
|
206
|
+
compatibility, a new version should be immediately released that
|
207
|
+
restores compatibility. Breaking changes to the public API will
|
208
|
+
only be introduced with new major versions.
|
209
|
+
|
210
|
+
As a result of this policy, you can (and should) specify a
|
211
|
+
dependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision.
|
212
|
+
|
213
|
+
For example:
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
spec.add_dependency 'oauth2', '~> 1.4'
|
217
|
+
```
|
218
|
+
|
219
|
+
[semver]: http://semver.org/
|
220
|
+
[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
221
|
+
|
130
222
|
## License
|
131
|
-
Copyright (c) 2011-2013 Michael Bleigh and Intridea, Inc. See [LICENSE][] for
|
132
|
-
details.
|
133
223
|
|
134
|
-
[
|
224
|
+
[][source-license]
|
225
|
+
|
226
|
+
- Copyright (c) 2011-2013 Michael Bleigh and Intridea, Inc.
|
227
|
+
- Copyright (c) 2017-2018 [oauth-xx organization][oauth-xx]
|
228
|
+
- See [LICENSE][license] for details.
|
229
|
+
|
230
|
+
[][fossa2]
|
231
|
+
|
232
|
+
[license]: LICENSE
|
233
|
+
[oauth-xx]: https://github.com/oauth-xx
|
234
|
+
[fossa2]: https://app.fossa.io/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2?ref=badge_large
|
235
|
+
|
236
|
+
## Development
|
237
|
+
|
238
|
+
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.
|
239
|
+
|
240
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
241
|
+
|
242
|
+
## Contributing
|
243
|
+
|
244
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/oauth-xx/oauth2. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
245
|
+
|
246
|
+
## Code of Conduct
|
247
|
+
|
248
|
+
Everyone interacting in the OAuth2 project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/oauth-xx/oauth2/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/oauth2/access_token.rb
CHANGED
@@ -3,6 +3,7 @@ module OAuth2
|
|
3
3
|
attr_reader :client, :token, :expires_in, :expires_at, :params
|
4
4
|
attr_accessor :options, :refresh_token
|
5
5
|
|
6
|
+
# Should these methods be deprecated?
|
6
7
|
class << self
|
7
8
|
# Initializes an AccessToken from a Hash
|
8
9
|
#
|
@@ -46,11 +47,11 @@ module OAuth2
|
|
46
47
|
end
|
47
48
|
@expires_in ||= opts.delete('expires')
|
48
49
|
@expires_in &&= @expires_in.to_i
|
49
|
-
@expires_at &&= @expires_at
|
50
|
+
@expires_at &&= convert_expires_at(@expires_at)
|
50
51
|
@expires_at ||= Time.now.to_i + @expires_in if @expires_in
|
51
|
-
@options = {:mode
|
52
|
+
@options = {:mode => opts.delete(:mode) || :header,
|
52
53
|
:header_format => opts.delete(:header_format) || 'Bearer %s',
|
53
|
-
:param_name
|
54
|
+
:param_name => opts.delete(:param_name) || 'access_token'}
|
54
55
|
@params = opts
|
55
56
|
end
|
56
57
|
|
@@ -81,6 +82,7 @@ module OAuth2
|
|
81
82
|
# @note options should be carried over to the new AccessToken
|
82
83
|
def refresh!(params = {})
|
83
84
|
raise('A refresh_token is not available') unless refresh_token
|
85
|
+
|
84
86
|
params[:grant_type] = 'refresh_token'
|
85
87
|
params[:refresh_token] = refresh_token
|
86
88
|
new_token = @client.get_token(params)
|
@@ -149,7 +151,7 @@ module OAuth2
|
|
149
151
|
|
150
152
|
private
|
151
153
|
|
152
|
-
def configure_authentication!(opts) # rubocop:disable
|
154
|
+
def configure_authentication!(opts) # rubocop:disable Metrics/AbcSize
|
153
155
|
case options[:mode]
|
154
156
|
when :header
|
155
157
|
opts[:headers] ||= {}
|
@@ -169,5 +171,11 @@ module OAuth2
|
|
169
171
|
raise("invalid :mode option of #{options[:mode]}")
|
170
172
|
end
|
171
173
|
end
|
174
|
+
|
175
|
+
def convert_expires_at(expires_at)
|
176
|
+
Time.iso8601(expires_at.to_s).to_i
|
177
|
+
rescue ArgumentError
|
178
|
+
expires_at.to_i
|
179
|
+
end
|
172
180
|
end
|
173
181
|
end
|
data/lib/oauth2/authenticator.rb
CHANGED
@@ -25,6 +25,10 @@ module OAuth2
|
|
25
25
|
apply_basic_auth(params)
|
26
26
|
when :request_body
|
27
27
|
apply_params_auth(params)
|
28
|
+
when :tls_client_auth
|
29
|
+
apply_client_id(params)
|
30
|
+
when :private_key_jwt
|
31
|
+
params
|
28
32
|
else
|
29
33
|
raise NotImplementedError
|
30
34
|
end
|
@@ -42,6 +46,12 @@ module OAuth2
|
|
42
46
|
{'client_id' => id, 'client_secret' => secret}.merge(params)
|
43
47
|
end
|
44
48
|
|
49
|
+
# When using schemes that don't require the client_secret to be passed i.e TLS Client Auth,
|
50
|
+
# we don't want to send the secret
|
51
|
+
def apply_client_id(params)
|
52
|
+
{'client_id' => id}.merge(params)
|
53
|
+
end
|
54
|
+
|
45
55
|
# Adds an `Authorization` header with Basic Auth credentials if and only if
|
46
56
|
# it is not already set in the params.
|
47
57
|
def apply_basic_auth(params)
|