oauth2 1.4.7 → 2.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,100 +1,421 @@
1
- # OAuth2
1
+ <p align="center">
2
+ <a href="http://oauth.net/2/" target="_blank" rel="noopener">
3
+ <img src="https://github.com/oauth-xx/oauth2/raw/main/docs/images/logo/oauth2-logo-124px.png?raw=true" alt="OAuth 2.0 Logo by Chris Messina, CC BY-SA 3.0">
4
+ </a>
5
+ <a href="https://www.ruby-lang.org/" target="_blank" rel="noopener">
6
+ <img width="124px" src="https://github.com/oauth-xx/oauth2/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
+ ## What
11
+
12
+ OAuth 2.0 is the industry-standard protocol for authorization.
13
+ OAuth 2.0 focuses on client developer simplicity while providing specific authorization flows for web applications,
14
+ desktop applications, mobile phones, and living room devices.
15
+ This is a RubyGem for implementing OAuth 2.0 clients and servers in Ruby applications.
16
+ See the sibling `oauth` gem for OAuth 1.0 implementations in Ruby.
2
17
 
3
- If you need the readme for a released version of the gem please find it below:
18
+ ---
19
+
20
+ * [OAuth 2.0 Spec][oauth2-spec]
21
+ * [oauth sibling gem][sibling-gem] for OAuth 1.0 implementations in Ruby.
22
+
23
+ [oauth2-spec]: https://oauth.net/2/
24
+ [sibling-gem]: https://gitlab.com/oauth-xx/oauth
25
+
26
+ ## Release Documentation
27
+
28
+ ### Version 2.0.x
29
+
30
+ <details>
31
+ <summary>2.0.x Readmes</summary>
32
+
33
+ | Version | Release Date | Readme |
34
+ |---------|--------------|----------------------------------------------------------|
35
+ | 2.0.9 | 2022-09-16 | https://gitlab.com/oauth-xx/oauth2/-/blob/v2.0.9/README.md |
36
+ | 2.0.8 | 2022-09-01 | https://gitlab.com/oauth-xx/oauth2/-/blob/v2.0.8/README.md |
37
+ | 2.0.7 | 2022-08-22 | https://gitlab.com/oauth-xx/oauth2/-/blob/v2.0.7/README.md |
38
+ | 2.0.6 | 2022-07-13 | https://gitlab.com/oauth-xx/oauth2/-/blob/v2.0.6/README.md |
39
+ | 2.0.5 | 2022-07-07 | https://gitlab.com/oauth-xx/oauth2/-/blob/v2.0.5/README.md |
40
+ | 2.0.4 | 2022-07-01 | https://gitlab.com/oauth-xx/oauth2/-/blob/v2.0.4/README.md |
41
+ | 2.0.3 | 2022-06-28 | https://gitlab.com/oauth-xx/oauth2/-/blob/v2.0.3/README.md |
42
+ | 2.0.2 | 2022-06-24 | https://gitlab.com/oauth-xx/oauth2/-/blob/v2.0.2/README.md |
43
+ | 2.0.1 | 2022-06-22 | https://gitlab.com/oauth-xx/oauth2/-/blob/v2.0.1/README.md |
44
+ | 2.0.0 | 2022-06-21 | https://gitlab.com/oauth-xx/oauth2/-/blob/v2.0.0/README.md |
45
+ </details>
46
+
47
+ ### Older Releases
48
+
49
+ <details>
50
+ <summary>1.4.x Readmes</summary>
51
+
52
+ | Version | Release Date | Readme |
53
+ |---------|--------------|-------------------------------------------------------------|
54
+ | 1.4.11 | Sep 16, 2022 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.4.11/README.md |
55
+ | 1.4.10 | Jul 1, 2022 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.4.10/README.md |
56
+ | 1.4.9 | Feb 20, 2022 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.4.9/README.md |
57
+ | 1.4.8 | Feb 18, 2022 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.4.8/README.md |
58
+ | 1.4.7 | Mar 19, 2021 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.4.7/README.md |
59
+ | 1.4.6 | Mar 19, 2021 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.4.6/README.md |
60
+ | 1.4.5 | Mar 18, 2021 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.4.5/README.md |
61
+ | 1.4.4 | Feb 12, 2020 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.4.4/README.md |
62
+ | 1.4.3 | Jan 29, 2020 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.4.3/README.md |
63
+ | 1.4.2 | Oct 1, 2019 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.4.2/README.md |
64
+ | 1.4.1 | Oct 13, 2018 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.4.1/README.md |
65
+ | 1.4.0 | Jun 9, 2017 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.4.0/README.md |
66
+ </details>
67
+
68
+ <details>
69
+ <summary>1.3.x Readmes</summary>
4
70
 
5
71
  | Version | Release Date | Readme |
6
72
  |----------|--------------|----------------------------------------------------------|
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
-
22
- [![Gem Version](http://img.shields.io/gem/v/oauth2.svg)][gem]
23
- [![Total Downloads](https://img.shields.io/gem/dt/oauth2.svg)][gem]
24
- [![Downloads Today](https://img.shields.io/gem/rt/oauth2.svg)][gem]
25
- [![Build Status](https://travis-ci.org/oauth-xx/oauth2.svg?branch=1-4-stable)][travis]
26
- [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Foauth-xx%2Foauth2%2Fbadge&style=flat)][github-actions]
27
- [![Test Coverage](https://api.codeclimate.com/v1/badges/688c612528ff90a46955/test_coverage)][codeclimate-coverage]
28
- [![Maintainability](https://api.codeclimate.com/v1/badges/688c612528ff90a46955/maintainability)][codeclimate-maintainability]
29
- [![Depfu](https://badges.depfu.com/badges/6d34dc1ba682bbdf9ae2a97848241743/count.svg)][depfu]
30
- [![Open Source Helpers](https://www.codetriage.com/oauth-xx/oauth2/badges/users.svg)][code-triage]
31
- [![Chat](https://img.shields.io/gitter/room/oauth-xx/oauth2.svg)](https://gitter.im/oauth-xx/oauth2)
32
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)][source-license]
33
- [![Documentation](http://inch-ci.org/github/oauth-xx/oauth2.png)][inch-ci]
34
-
35
- [gem]: https://rubygems.org/gems/oauth2
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].
73
+ | 1.3.1 | Mar 3, 2017 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.3.1/README.md |
74
+ | 1.3.0 | Dec 27, 2016 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.3.0/README.md |
75
+ </details>
48
76
 
49
- [oauth2-spec]: https://oauth.net/2/
77
+ <details>
78
+ <summary>&le;= 1.2.x Readmes (2016 and before)</summary>
79
+
80
+ | Version | Release Date | Readme |
81
+ |----------|--------------|----------------------------------------------------------|
82
+ | 1.2.0 | Jun 30, 2016 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.2.0/README.md |
83
+ | 1.1.0 | Jan 30, 2016 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.1.0/README.md |
84
+ | 1.0.0 | May 23, 2014 | https://gitlab.com/oauth-xx/oauth2/-/blob/v1.0.0/README.md |
85
+ | < 1.0.0 | Find here | https://gitlab.com/oauth-xx/oauth2/-/tags |
86
+ </details>
87
+
88
+ ## Status
89
+
90
+ <!--
91
+ Numbering rows and badges in each row as a visual "database" lookup,
92
+ as the table is extremely dense, and it can be very difficult to find anything
93
+ Putting one on each row here, to document the emoji that should be used, and for ease of copy/paste.
94
+
95
+ row #s:
96
+ 1️⃣
97
+ 2️⃣
98
+ 3️⃣
99
+ 4️⃣
100
+ 5️⃣
101
+ 6️⃣
102
+ 7️⃣
103
+
104
+ badge #s:
105
+ ⛳️
106
+ 🖇
107
+ 🏘
108
+ 🚎
109
+ 🖐
110
+ 🧮
111
+ 📗
112
+
113
+ appended indicators:
114
+ ♻️ - URL needs to be updated from SASS integration. Find / Replace is insufficient.
115
+ -->
116
+
117
+ | | Project | bundle add oauth2 |
118
+ |:----|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
119
+ | 1️⃣ | name, license, docs | [![RubyGems.org][⛳️name-img]][⛳️gem] [![License: MIT][🖇src-license-img]][🖇src-license] [![FOSSA][🏘fossa-img]][🏘fossa] [![RubyDoc.info][🚎yard-img]][🚎yard] [![InchCI][🖐inch-ci-img]][🚎yard] |
120
+ | 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] |
121
+ | 3️⃣ | maintanence & 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] |
122
+ | 4️⃣ | testing | [![Supported][🏘sup-wf-img]][🏘sup-wf] [![Heads][🚎heads-wf-img]][🚎heads-wf] [![Unofficial Support][🖐uns-wf-img]][🖐uns-wf] [![MacOS][🧮mac-wf-img]][🧮mac-wf] [![Windows][📗win-wf-img]][📗win-wf] |
123
+ | 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] |
124
+ | 6️⃣ | resources | [![Discussion][⛳gg-discussions-img]][⛳gg-discussions] [![Get help on Codementor][🖇codementor-img]][🖇codementor] [![Chat][🏘chat-img]][🏘chat] [![Blog][🚎blog-img]][🚎blog] [![Blog][🖐wiki-img]][🖐wiki] |
125
+ | 7️⃣ | spread 💖 | [![Liberapay Patrons][⛳liberapay-img]][⛳liberapay] [![Sponsor Me][🖇sponsor-img]][🖇sponsor] [![Tweet @ Peter][🏘tweet-img]][🏘tweet] [🌏][aboutme] [👼][angelme] [💻][coderme] |
126
+
127
+ <!--
128
+ The link tokens in the following sections should be kept ordered by the row and badge numbering scheme
129
+ -->
130
+
131
+ <!-- 1️⃣ name, license, docs -->
132
+ [⛳️gem]: https://rubygems.org/gems/oauth2
133
+ [⛳️name-img]: https://img.shields.io/badge/name-oauth2-brightgreen.svg?style=flat
134
+ [🖇src-license]: https://opensource.org/licenses/MIT
135
+ [🖇src-license-img]: https://img.shields.io/badge/License-MIT-green.svg
136
+ [🏘fossa]: https://app.fossa.io/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2?ref=badge_shield
137
+ [🏘fossa-img]: https://app.fossa.io/api/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2.svg?type=shield
138
+ [🚎yard]: https://www.rubydoc.info/github/oauth-xx/oauth2
139
+ [🚎yard-img]: https://img.shields.io/badge/documentation-rubydoc-brightgreen.svg?style=flat
140
+ [🖐inch-ci-img]: http://inch-ci.org/github/oauth-xx/oauth2.png
141
+
142
+ <!-- 2️⃣ version & activity -->
143
+ [⛳️version-img]: http://img.shields.io/gem/v/oauth2.svg
144
+ [🖇DL-total-img]: https://img.shields.io/gem/dt/oauth2.svg
145
+ [🏘DL-rank-img]: https://img.shields.io/gem/rt/oauth2.svg
146
+ [🚎src-home]: https://gitlab.com/oauth-xx/oauth2/
147
+ [🚎src-home-img]: https://img.shields.io/badge/source-gitlab-blue.svg?style=flat
148
+
149
+ <!-- 3️⃣ maintenance & linting -->
150
+ [⛳cclim-maint]: https://codeclimate.com/github/oauth-xx/oauth2/maintainability
151
+ [⛳cclim-maint-img♻️]: https://api.codeclimate.com/v1/badges/688c612528ff90a46955/maintainability
152
+ [🖇triage-help]: https://www.codetriage.com/oauth-xx/oauth2
153
+ [🖇triage-help-img]: https://www.codetriage.com/oauth-xx/oauth2/badges/users.svg
154
+ [🏘depfu♻️]: https://depfu.com/github/oauth-xx/oauth2?project_id=4445
155
+ [🏘depfu-img♻️]: https://badges.depfu.com/badges/6d34dc1ba682bbdf9ae2a97848241743/count.svg
156
+ [🚎contributors]: https://gitlab.com/oauth-xx/oauth2/-/graphs/main
157
+ [🚎contributors-img]: https://img.shields.io/github/contributors-anon/oauth-xx/oauth2
158
+ [🖐style-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/style.yml
159
+ [🖐style-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/style.yml/badge.svg
160
+ [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
161
+ [🧮kloc-img]: https://img.shields.io/tokei/lines/github.com/oauth-xx/oauth2
162
+
163
+ <!-- 4️⃣ testing -->
164
+ [🏘sup-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/supported.yml
165
+ [🏘sup-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/supported.yml/badge.svg
166
+ [🚎heads-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/heads.yml
167
+ [🚎heads-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/heads.yml/badge.svg
168
+ [🖐uns-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/unsupported.yml
169
+ [🖐uns-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/unsupported.yml/badge.svg
170
+ [🧮mac-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/macos.yml
171
+ [🧮mac-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/macos.yml/badge.svg
172
+ [📗win-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/windows.yml
173
+ [📗win-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/windows.yml/badge.svg
174
+
175
+ <!-- 5️⃣ coverage & security -->
176
+ [⛳cclim-cov]: https://codeclimate.com/github/oauth-xx/oauth2/test_coverage
177
+ [⛳cclim-cov-img♻️]: https://api.codeclimate.com/v1/badges/688c612528ff90a46955/test_coverage
178
+ [🖇codecov-img♻️]: https://codecov.io/gh/oauth-xx/oauth2/branch/main/graph/badge.svg?token=bNqSzNiuo2
179
+ [🖇codecov]: https://codecov.io/gh/oauth-xx/oauth2
180
+ [🏘coveralls]: https://coveralls.io/github/oauth-xx/oauth2?branch=main
181
+ [🏘coveralls-img]: https://coveralls.io/repos/github/oauth-xx/oauth2/badge.svg?branch=main
182
+ [🚎sec-pol]: https://gitlab.com/oauth-xx/oauth2/-/blob/main/SECURITY.md
183
+ [🚎sec-pol-img]: https://img.shields.io/badge/security-policy-brightgreen.svg?style=flat
184
+ [🖐codeQL]: https://github.com/oauth-xx/oauth2/security/code-scanning
185
+ [🖐codeQL-img]: https://github.com/oauth-xx/oauth2/actions/workflows/codeql-analysis.yml/badge.svg
186
+ [🧮cov-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/coverage.yml
187
+ [🧮cov-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/coverage.yml/badge.svg
188
+
189
+ <!-- 6️⃣ resources -->
190
+ [⛳gg-discussions]: https://groups.google.com/g/oauth-ruby
191
+ [⛳gg-discussions-img]: https://img.shields.io/badge/google-group-purple.svg?style=flat
192
+ [🖇codementor]: https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github
193
+ [🖇codementor-img]: https://cdn.codementor.io/badges/get_help_github.svg
194
+ [🏘chat]: https://gitter.im/oauth-xx/oauth2
195
+ [🏘chat-img]: https://img.shields.io/gitter/room/oauth-xx/oauth2.svg
196
+ [🚎blog]: http://www.railsbling.com/tags/oauth2/
197
+ [🚎blog-img]: https://img.shields.io/badge/blog-railsbling-brightgreen.svg?style=flat
198
+ [🖐wiki]: https://gitlab.com/oauth-xx/oauth2/-/wikis/home
199
+ [🖐wiki-img]: https://img.shields.io/badge/wiki-examples-brightgreen.svg?style=flat
200
+
201
+ <!-- 7️⃣ spread 💖 -->
202
+ [⛳liberapay-img]: https://img.shields.io/liberapay/patrons/pboling.svg?logo=liberapay
203
+ [⛳liberapay]: https://liberapay.com/pboling/donate
204
+ [🖇sponsor-img]: https://img.shields.io/badge/sponsor-pboling.svg?style=social&logo=github
205
+ [🖇sponsor]: https://github.com/sponsors/pboling
206
+ [🏘tweet-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow
207
+ [🏘tweet]: http://twitter.com/galtzo
208
+
209
+ <!-- Maintainer Contact Links -->
210
+ [railsbling]: http://www.railsbling.com
211
+ [peterboling]: http://www.peterboling.com
212
+ [aboutme]: https://about.me/peter.boling
213
+ [angelme]: https://angel.co/peter-boling
214
+ [coderme]:http://coderwall.com/pboling
50
215
 
51
216
  ## Installation
52
217
 
53
- Add this line to your application's Gemfile:
218
+ Install the gem and add to the application's Gemfile by executing:
54
219
 
55
- ```ruby
56
- gem 'oauth2'
57
- ```
220
+ $ bundle add oauth2
58
221
 
59
- And then execute:
222
+ If bundler is not being used to manage dependencies, install the gem by executing:
60
223
 
61
- $ bundle
224
+ $ gem install oauth2
62
225
 
63
- Or install it yourself as:
226
+ ## OAuth2 for Enterprise
64
227
 
65
- $ gem install oauth2
228
+ Available as part of the Tidelift Subscription.
229
+
230
+ 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.][tidelift-ref]
231
+
232
+ [tidelift-ref]: https://tidelift.com/subscription/pkg/rubygems-oauth2?utm_source=rubygems-oauth2&utm_medium=referral&utm_campaign=enterprise
233
+
234
+ ## Security contact information
235
+
236
+ To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
237
+ Tidelift will coordinate the fix and disclosure.
238
+
239
+ For more see [SECURITY.md][🚎sec-pol].
240
+
241
+ ## What is new for v2.0?
242
+
243
+ - Officially support Ruby versions >= 2.7
244
+ - Unofficially support Ruby versions >= 2.5
245
+ - Incidentally support Ruby versions >= 2.2
246
+ - Drop support for the expired MAC Draft (all versions)
247
+ - Support IETF rfc7523 JWT Bearer Tokens
248
+ - Support IETF rfc7231 Relative Location in Redirect
249
+ - Support IETF rfc6749 Don't set oauth params when nil
250
+ - Support [OIDC 1.0 Private Key JWT](https://openid.net/specs/openid-connect-core-1_0.html#ClientAuthentication); based on the OAuth JWT assertion specification [(RFC 7523)](https://tools.ietf.org/html/rfc7523)
251
+ - Support new formats, including from [jsonapi.org](http://jsonapi.org/format/): `application/vdn.api+json`, `application/vnd.collection+json`, `application/hal+json`, `application/problem+json`
252
+ - Adds new option to `OAuth2::Client#get_token`:
253
+ - `:access_token_class` (`AccessToken`); user specified class to use for all calls to `get_token`
254
+ - Adds new option to `OAuth2::AccessToken#initialize`:
255
+ - `:expires_latency` (`nil`); number of seconds by which AccessToken validity will be reduced to offset latency
256
+ - By default, keys are transformed to camel case.
257
+ - Original keys will still work as previously, in most scenarios, thanks to `rash_alt` gem.
258
+ - However, this is a _breaking_ change if you rely on `response.parsed.to_h`, as the keys in the result will be camel case.
259
+ - As of version 2.0.4 you can turn key transformation off with the `snaky: false` option.
260
+ - By default, the `:auth_scheme` is now `:basic_auth` (instead of `:request_body`)
261
+ - Third-party strategies and gems may need to be updated if a provider was requiring client id/secret in the request body
262
+ - [... A lot more](https://gitlab.com/oauth-xx/oauth2/-/blob/main/CHANGELOG.md#2.0.0)
263
+
264
+ ## Compatibility
265
+
266
+ Targeted ruby compatibility is non-EOL versions of Ruby, currently 2.7, 3.0 and
267
+ 3.1. Compatibility is further distinguished by supported and unsupported versions of Ruby.
268
+ Ruby is limited to 2.2+ for 2.x releases. See `1-4-stable` branch for older rubies.
269
+
270
+ <details>
271
+ <summary>Ruby Engine Compatibility Policy</summary>
272
+
273
+ This gem is tested against MRI, JRuby, and Truffleruby.
274
+ Each of those has varying versions that target a specific version of MRI Ruby.
275
+ This gem should work in the just-listed Ruby engines according to the targeted MRI compatibility in the table below.
276
+ If you would like to add support for additional engines,
277
+ see `gemfiles/README.md`, then submit a PR to the correct maintenance branch as according to the table below.
278
+ </details>
279
+
280
+ <details>
281
+ <summary>Ruby Version Compatibility Policy</summary>
282
+
283
+ If something doesn't work on one of these interpreters, it's a bug.
66
284
 
67
- ## Resources
285
+ This library may inadvertently work (or seem to work) on other Ruby
286
+ implementations, however support will only be provided for the versions listed
287
+ above.
68
288
 
69
- * [View Source on GitHub][code]
70
- * [Report Issues on GitHub][issues]
71
- * [Read More at the Wiki][wiki]
289
+ If you would like this library to support another Ruby version, you may
290
+ volunteer to be a maintainer. Being a maintainer entails making sure all tests
291
+ run and pass on that implementation. When something breaks on your
292
+ implementation, you will be responsible for providing patches in a timely
293
+ fashion. If critical issues for a particular implementation exist at the time
294
+ of a major release, support for that Ruby version may be dropped.
295
+ </details>
296
+
297
+ | | Ruby OAuth2 Version | Maintenance Branch | Supported Officially | Supported Unofficially | Supported Incidentally |
298
+ |:----|---------------------|--------------------|-------------------------|------------------------|------------------------|
299
+ | 1️⃣ | 2.0.x | `main` | 2.7, 3.0, 3.1 | 2.5, 2.6 | 2.2, 2.3, 2.4 |
300
+ | 2️⃣ | 1.4.x | `1-4-stable` | 2.5, 2.6, 2.7, 3.0, 3.1 | 2.1, 2.2, 2.3, 2.4 | 1.9, 2.0 |
301
+ | 3️⃣ | older | N/A | Best of luck to you! | Please upgrade! | |
72
302
 
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
303
+ NOTE: The 1.4 series will only receive critical security updates.
304
+ See [SECURITY.md][🚎sec-pol]
76
305
 
77
306
  ## Usage Examples
78
307
 
308
+ ### Global Configuration
309
+
310
+ If you started seeing this warning, but everything it working fine, you can now silence it.
311
+ ```log
312
+ OAuth2::AccessToken.from_hash: `hash` contained more than one 'token' key
313
+ ```
314
+
79
315
  ```ruby
80
- require 'oauth2'
81
- client = OAuth2::Client.new('client_id', 'client_secret', :site => 'https://example.org')
316
+ OAuth2.configure do |config|
317
+ config.silence_extra_tokens_warning = true # default: false
318
+ end
319
+ ```
82
320
 
83
- client.auth_code.authorize_url(:redirect_uri => 'http://localhost:8080/oauth2/callback')
84
- # => "https://example.org/oauth/authorization?response_type=code&client_id=client_id&redirect_uri=http://localhost:8080/oauth2/callback"
321
+ ### `authorize_url` and `token_url` are on site root (Just Works!)
85
322
 
86
- token = client.auth_code.get_token('authorization_code_value', :redirect_uri => 'http://localhost:8080/oauth2/callback', :headers => {'Authorization' => 'Basic some_password'})
87
- response = token.get('/api/resource', :params => {'query_foo' => 'bar'})
323
+ ```ruby
324
+ require 'oauth2'
325
+ client = OAuth2::Client.new('client_id', 'client_secret', site: 'https://example.org')
326
+ # => #<OAuth2::Client:0x00000001204c8288 @id="client_id", @secret="client_sec...
327
+ client.auth_code.authorize_url(redirect_uri: 'http://localhost:8080/oauth2/callback')
328
+ # => "https://example.org/oauth/authorize?client_id=client_id&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Foauth2%2Fcallback&response_type=code"
329
+
330
+ access = client.auth_code.get_token('authorization_code_value', redirect_uri: 'http://localhost:8080/oauth2/callback', headers: {'Authorization' => 'Basic some_password'})
331
+ response = access.get('/api/resource', params: {'query_foo' => 'bar'})
88
332
  response.class.name
89
333
  # => OAuth2::Response
90
334
  ```
335
+
336
+ ### Relative `authorize_url` and `token_url` (Not on site root, Just Works!)
337
+
338
+ In above example, the default Authorization URL is `oauth/authorize` and default Access Token URL is `oauth/token`, and, as they are missing a leading `/`, both are relative.
339
+
340
+ ```ruby
341
+ client = OAuth2::Client.new('client_id', 'client_secret', site: 'https://example.org/nested/directory/on/your/server')
342
+ # => #<OAuth2::Client:0x00000001204c8288 @id="client_id", @secret="client_sec...
343
+ client.auth_code.authorize_url(redirect_uri: 'http://localhost:8080/oauth2/callback')
344
+ # => "https://example.org/nested/directory/on/your/server/oauth/authorize?client_id=client_id&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Foauth2%2Fcallback&response_type=code"
345
+ ```
346
+
347
+ ### Customize `authorize_url` and `token_url`
348
+
349
+ You can specify custom URLs for authorization and access token, and when using a leading `/` they will _not be relative_, as shown below:
350
+
351
+ ```ruby
352
+ client = OAuth2::Client.new('client_id', 'client_secret',
353
+ site: 'https://example.org/nested/directory/on/your/server',
354
+ authorize_url: '/jaunty/authorize/',
355
+ token_url: '/stirrups/access_token')
356
+ # => #<OAuth2::Client:0x00000001204c8288 @id="client_id", @secret="client_sec...
357
+ client.auth_code.authorize_url(redirect_uri: 'http://localhost:8080/oauth2/callback')
358
+ # => "https://example.org/jaunty/authorize/?client_id=client_id&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Foauth2%2Fcallback&response_type=code"
359
+ client.class.name
360
+ # => OAuth2::Client
361
+ ```
362
+
363
+ ### snake_case and indifferent access in Response#parsed
364
+
365
+ ```ruby
366
+ response = access.get('/api/resource', params: {'query_foo' => 'bar'})
367
+ # Even if the actual response is CamelCase. it will be made available as snaky:
368
+ JSON.parse(response.body) # => {"accessToken"=>"aaaaaaaa", "additionalData"=>"additional"}
369
+ response.parsed # => {"access_token"=>"aaaaaaaa", "additional_data"=>"additional"}
370
+ response.parsed.access_token # => "aaaaaaaa"
371
+ response.parsed[:access_token] # => "aaaaaaaa"
372
+ response.parsed.additional_data # => "additional"
373
+ response.parsed[:additional_data] # => "additional"
374
+ response.parsed.class.name # => OAuth2::SnakyHash (subclass of Hashie::Mash::Rash, from `rash_alt` gem)
375
+ ```
376
+
377
+ #### What if I hate snakes and/or indifference?
378
+
379
+ ```ruby
380
+ response = access.get('/api/resource', params: {'query_foo' => 'bar'}, snaky: false)
381
+ JSON.parse(response.body) # => {"accessToken"=>"aaaaaaaa", "additionalData"=>"additional"}
382
+ response.parsed # => {"accessToken"=>"aaaaaaaa", "additionalData"=>"additional"}
383
+ response.parsed['accessToken'] # => "aaaaaaaa"
384
+ response.parsed['additionalData'] # => "additional"
385
+ response.parsed.class.name # => Hash (just, regular old Hash)
386
+ ```
387
+
388
+ <details>
389
+ <summary>Debugging</summary>
390
+
391
+ Set an environment variable, however you would [normally do that](https://github.com/bkeepers/dotenv).
392
+
393
+ ```ruby
394
+ # will log both request and response, including bodies
395
+ ENV['OAUTH_DEBUG'] = 'true'
396
+ ```
397
+
398
+ By default, debug output will go to `$stdout`. This can be overridden when
399
+ initializing your OAuth2::Client.
400
+
401
+ ```ruby
402
+ require 'oauth2'
403
+ client = OAuth2::Client.new(
404
+ 'client_id',
405
+ 'client_secret',
406
+ site: 'https://example.org',
407
+ logger: Logger.new('example.log', 'weekly')
408
+ )
409
+ ```
410
+ </details>
411
+
91
412
  ## OAuth2::Response
92
413
 
93
- The AccessToken methods #get, #post, #put and #delete and the generic #request
414
+ The `AccessToken` methods `#get`, `#post`, `#put` and `#delete` and the generic `#request`
94
415
  will return an instance of the #OAuth2::Response class.
95
416
 
96
- This instance contains a #parsed method that will parse the response body and
97
- return a Hash if the Content-Type is application/x-www-form-urlencoded or if
417
+ This instance contains a `#parsed` method that will parse the response body and
418
+ return a Hash-like [`OAuth2::SnakyHash`](https://gitlab.com/oauth-xx/oauth2/-/blob/main/lib/oauth2/snaky_hash.rb) if the `Content-Type` is `application/x-www-form-urlencoded` or if
98
419
  the body is a JSON object. It will return an Array if the body is a JSON
99
420
  array. Otherwise, it will return the original body string.
100
421
 
@@ -104,100 +425,71 @@ respective methods.
104
425
  ## OAuth2::AccessToken
105
426
 
106
427
  If you have an existing Access Token for a user, you can initialize an instance
107
- using various class methods including the standard new, from_hash (if you have
108
- a hash of the values), or from_kvform (if you have an
109
- application/x-www-form-urlencoded encoded string of the values).
428
+ using various class methods including the standard new, `from_hash` (if you have
429
+ a hash of the values), or `from_kvform` (if you have an
430
+ `application/x-www-form-urlencoded` encoded string of the values).
110
431
 
111
432
  ## OAuth2::Error
112
433
 
113
- On 400+ status code responses, an OAuth2::Error will be raised. If it is a
114
- standard OAuth2 error response, the body will be parsed and #code and #description will contain the values provided from the error and
115
- error_description parameters. The #response property of OAuth2::Error will
116
- always contain the OAuth2::Response instance.
434
+ On 400+ status code responses, an `OAuth2::Error` will be raised. If it is a
435
+ standard OAuth2 error response, the body will be parsed and `#code` and `#description` will contain the values provided from the error and
436
+ `error_description` parameters. The `#response` property of `OAuth2::Error` will
437
+ always contain the `OAuth2::Response` instance.
117
438
 
118
- If you do not want an error to be raised, you may use :raise_errors => false
119
- option on initialization of the client. In this case the OAuth2::Response
439
+ If you do not want an error to be raised, you may use `:raise_errors => false`
440
+ option on initialization of the client. In this case the `OAuth2::Response`
120
441
  instance will be returned as usual and on 400+ status code responses, the
121
- Response instance will contain the OAuth2::Error instance.
442
+ Response instance will contain the `OAuth2::Error` instance.
122
443
 
123
444
  ## Authorization Grants
124
445
 
125
446
  Currently the Authorization Code, Implicit, Resource Owner Password Credentials, Client Credentials, and Assertion
126
447
  authentication grant types have helper strategy classes that simplify client
127
- use. They are available via the #auth_code, #implicit, #password, #client_credentials, and #assertion methods respectively.
448
+ use. They are available via the [`#auth_code`](https://gitlab.com/oauth-xx/oauth2/-/blob/main/lib/oauth2/strategy/auth_code.rb),
449
+ [`#implicit`](https://gitlab.com/oauth-xx/oauth2/-/blob/main/lib/oauth2/strategy/implicit.rb),
450
+ [`#password`](https://gitlab.com/oauth-xx/oauth2/-/blob/main/lib/oauth2/strategy/password.rb),
451
+ [`#client_credentials`](https://gitlab.com/oauth-xx/oauth2/-/blob/main/lib/oauth2/strategy/client_credentials.rb), and
452
+ [`#assertion`](https://gitlab.com/oauth-xx/oauth2/-/blob/main/lib/oauth2/strategy/assertion.rb) methods respectively.
128
453
 
454
+ These aren't full examples, but demonstrative of the differences between usage for each strategy.
129
455
  ```ruby
130
- auth_url = client.auth_code.authorize_url(:redirect_uri => 'http://localhost:8080/oauth/callback')
131
- token = client.auth_code.get_token('code_value', :redirect_uri => 'http://localhost:8080/oauth/callback')
456
+ auth_url = client.auth_code.authorize_url(redirect_uri: 'http://localhost:8080/oauth/callback')
457
+ access = client.auth_code.get_token('code_value', redirect_uri: 'http://localhost:8080/oauth/callback')
132
458
 
133
- auth_url = client.implicit.authorize_url(:redirect_uri => 'http://localhost:8080/oauth/callback')
459
+ auth_url = client.implicit.authorize_url(redirect_uri: 'http://localhost:8080/oauth/callback')
134
460
  # get the token params in the callback and
135
- token = OAuth2::AccessToken.from_kvform(client, query_string)
136
-
137
- token = client.password.get_token('username', 'password')
138
-
139
- token = client.client_credentials.get_token
140
-
141
- token = client.assertion.get_token(assertion_params)
461
+ access = OAuth2::AccessToken.from_kvform(client, query_string)
462
+
463
+ access = client.password.get_token('username', 'password')
464
+
465
+ access = client.client_credentials.get_token
466
+
467
+ # Client Assertion Strategy
468
+ # see: https://tools.ietf.org/html/rfc7523
469
+ claimset = {
470
+ iss: 'http://localhost:3001',
471
+ aud: 'http://localhost:8080/oauth2/token',
472
+ sub: 'me@example.com',
473
+ exp: Time.now.utc.to_i + 3600,
474
+ }
475
+ assertion_params = [claimset, 'HS256', 'secret_key']
476
+ access = client.assertion.get_token(assertion_params)
477
+
478
+ # The `access` (i.e. access token) is then used like so:
479
+ access.token # actual access_token string, if you need it somewhere
480
+ access.get('/api/stuff') # making api calls with access token
142
481
  ```
143
482
 
144
483
  If you want to specify additional headers to be sent out with the
145
484
  request, add a 'headers' hash under 'params':
146
485
 
147
486
  ```ruby
148
- token = client.auth_code.get_token('code_value', :redirect_uri => 'http://localhost:8080/oauth/callback', :headers => {'Some' => 'Header'})
487
+ access = client.auth_code.get_token('code_value', redirect_uri: 'http://localhost:8080/oauth/callback', headers: {'Some' => 'Header'})
149
488
  ```
150
489
 
151
- You can always use the #request method on the OAuth2::Client instance to make
490
+ You can always use the `#request` method on the `OAuth2::Client` instance to make
152
491
  requests for tokens for any Authentication grant type.
153
492
 
154
- ## Supported Ruby Versions
155
-
156
- This library aims to support and is [tested against][travis] the following Ruby
157
- implementations:
158
-
159
- ### Rubies with support ending at Oauth2 1.x
160
-
161
- * Ruby 1.9.3
162
- - [JRuby 1.7][jruby-1.7] (targets MRI v1.9)
163
-
164
- * Ruby 2.0.0
165
- - [JRuby 9.0][jruby-9.0] (targets MRI v2.0)
166
- * Ruby 2.1
167
-
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
187
-
188
- If something doesn't work on one of these interpreters, it's a bug.
189
-
190
- This library may inadvertently work (or seem to work) on other Ruby
191
- implementations, however support will only be provided for the versions listed
192
- above.
193
-
194
- If you would like this library to support another Ruby version, you may
195
- volunteer to be a maintainer. Being a maintainer entails making sure all tests
196
- run and pass on that implementation. When something breaks on your
197
- implementation, you will be responsible for providing patches in a timely
198
- fashion. If critical issues for a particular implementation exist at the time
199
- of a major release, support for that Ruby version may be dropped.
200
-
201
493
  ## Versioning
202
494
 
203
495
  This library aims to adhere to [Semantic Versioning 2.0.0][semver].
@@ -213,7 +505,7 @@ dependency on this gem using the [Pessimistic Version Constraint][pvc] with two
213
505
  For example:
214
506
 
215
507
  ```ruby
216
- spec.add_dependency 'oauth2', '~> 1.4'
508
+ spec.add_dependency 'oauth2', '~> 2.0'
217
509
  ```
218
510
 
219
511
  [semver]: http://semver.org/
@@ -221,28 +513,36 @@ spec.add_dependency 'oauth2', '~> 1.4'
221
513
 
222
514
  ## License
223
515
 
224
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)][source-license]
516
+ [![License: MIT][🖇src-license-img]][🖇src-license]
225
517
 
226
518
  - Copyright (c) 2011-2013 Michael Bleigh and Intridea, Inc.
227
- - Copyright (c) 2017-2018 [oauth-xx organization][oauth-xx]
519
+ - Copyright (c) 2017-2022 [oauth-xx organization][oauth-xx]
228
520
  - See [LICENSE][license] for details.
229
521
 
230
522
  [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2.svg?type=large)][fossa2]
231
523
 
232
- [license]: LICENSE
233
- [oauth-xx]: https://github.com/oauth-xx
524
+ [license]: https://gitlab.com/oauth-xx/oauth2/-/blob/main/LICENSE
525
+ [oauth-xx]: https://gitlab.com/oauth-xx
234
526
  [fossa2]: https://app.fossa.io/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2?ref=badge_large
235
527
 
236
528
  ## Development
237
529
 
238
- After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.
530
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
239
531
 
240
532
  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
533
 
242
534
  ## Contributing
243
535
 
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.
536
+ See [CONTRIBUTING.md][contributing]
537
+
538
+ [contributing]: https://gitlab.com/oauth-xx/oauth2/-/blob/main/CONTRIBUTING.md
539
+
540
+ ## Contributors
541
+
542
+ [![Contributors](https://contrib.rocks/image?repo=oauth-xx/oauth2)]("https://gitlab.com/oauth-xx/oauth2/-/graphs/main")
543
+
544
+ Made with [contributors-img](https://contrib.rocks).
245
545
 
246
546
  ## Code of Conduct
247
547
 
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).
548
+ Everyone interacting in the OAuth2 project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/oauth-xx/oauth2/-/blob/main/CODE_OF_CONDUCT.md).