oauth2 1.4.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,51 +1,378 @@
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/master/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/master/docs/images/logo/ruby-logo-198px.svg?raw=true" alt="Yukihiro Matsumoto, Ruby Visual Identity Team, CC BY-SA 2.5">
7
+ </a>
8
+ </p>
9
+
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.
17
+
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://github.com/oauth-xx/oauth-ruby
25
+ [next-milestone-pct]: https://github.com/oauth-xx/oauth2/milestone/1
26
+ [next-milestone-pct-img]: https://img.shields.io/github/milestones/progress-percent/oauth-xx/oauth2/1
27
+
28
+ ## Release Documentation
29
+
30
+ ### Version 2.0.x
31
+
32
+ <details>
33
+ <summary>2.0.x Readmes</summary>
34
+
35
+ | Version | Release Date | Readme |
36
+ |---------|--------------|----------------------------------------------------------|
37
+ | 2.0.0 | Soon | https://github.com/oauth-xx/oauth2/blob/master/README.md |
38
+ </details>
39
+
40
+ ### Older Releases
41
+
42
+ <details>
43
+ <summary>1.4.x Readmes</summary>
44
+
45
+ | Version | Release Date | Readme |
46
+ |---------|--------------|----------------------------------------------------------|
47
+ | 1.4.9 | Feb 20, 2022 | https://github.com/oauth-xx/oauth2/blob/v1.4.9/README.md |
48
+ | 1.4.8 | Feb 18, 2022 | https://github.com/oauth-xx/oauth2/blob/v1.4.8/README.md |
49
+ | 1.4.7 | Mar 19, 2021 | https://github.com/oauth-xx/oauth2/blob/v1.4.7/README.md |
50
+ | 1.4.6 | Mar 19, 2021 | https://github.com/oauth-xx/oauth2/blob/v1.4.6/README.md |
51
+ | 1.4.5 | Mar 18, 2021 | https://github.com/oauth-xx/oauth2/blob/v1.4.5/README.md |
52
+ | 1.4.4 | Feb 12, 2020 | https://github.com/oauth-xx/oauth2/blob/v1.4.4/README.md |
53
+ | 1.4.3 | Jan 29, 2020 | https://github.com/oauth-xx/oauth2/blob/v1.4.3/README.md |
54
+ | 1.4.2 | Oct 1, 2019 | https://github.com/oauth-xx/oauth2/blob/v1.4.2/README.md |
55
+ | 1.4.1 | Oct 13, 2018 | https://github.com/oauth-xx/oauth2/blob/v1.4.1/README.md |
56
+ | 1.4.0 | Jun 9, 2017 | https://github.com/oauth-xx/oauth2/blob/v1.4.0/README.md |
57
+ </details>
58
+
59
+ <details>
60
+ <summary>1.3.x Readmes</summary>
61
+
62
+ | Version | Release Date | Readme |
63
+ |----------|--------------|----------------------------------------------------------|
64
+ | 1.3.1 | Mar 3, 2017 | https://github.com/oauth-xx/oauth2/blob/v1.3.1/README.md |
65
+ | 1.3.0 | Dec 27, 2016 | https://github.com/oauth-xx/oauth2/blob/v1.3.0/README.md |
66
+ </details>
67
+
68
+ <details>
69
+ <summary>&le;= 1.2.x Readmes (2016 and before)</summary>
70
+
71
+ | Version | Release Date | Readme |
72
+ |----------|--------------|----------------------------------------------------------|
73
+ | 1.2.0 | Jun 30, 2016 | https://github.com/oauth-xx/oauth2/blob/v1.2.0/README.md |
74
+ | 1.1.0 | Jan 30, 2016 | https://github.com/oauth-xx/oauth2/blob/v1.1.0/README.md |
75
+ | 1.0.0 | May 23, 2014 | https://github.com/oauth-xx/oauth2/blob/v1.0.0/README.md |
76
+ | < 1.0.0 | Find here | https://github.com/oauth-xx/oauth2/tags |
77
+ </details>
78
+
79
+ ## Status
80
+
81
+ <!--
82
+ Numbering rows and badges in each row as a visual "database" lookup,
83
+ as the table is extremely dense, and it can be very difficult to find anything
84
+ Putting one on each row here, to document the emoji that should be used, and for ease of copy/paste.
85
+
86
+ row #s:
87
+ 1️⃣
88
+ 2️⃣
89
+ 3️⃣
90
+ 4️⃣
91
+ 5️⃣
92
+ 6️⃣
93
+ 7️⃣
94
+
95
+ badge #s:
96
+ ⛳️
97
+ 🖇
98
+ 🏘
99
+ 🚎
100
+ 🖐
101
+ 🧮
102
+ 📗
103
+
104
+ appended indicators:
105
+ ♻️ - URL needs to be updated from SASS integration. Find / Replace is insufficient.
106
+ -->
107
+
108
+ | | Project | bundle add oauth2 |
109
+ |:----|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
110
+ | 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] |
111
+ | 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] |
112
+ | 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] |
113
+ | 4️⃣ | testing | [![Open Issues][⛳iss-o-img]][⛳iss-o] [![Closed Issues][🖇iss-c-img]][🖇iss-c] [![Supported][🏘sup-wf-img]][🏘sup-wf] [![Heads][🚎heads-wf-img]][🚎heads-wf] [![Unofficial Support][🖐uns-wf-img]][🖐uns-wf] [![MacOS][🧮mac-wf-img]][🧮mac-wf] [![Windows][📗win-wf-img]][📗win-wf] |
114
+ | 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] |
115
+ | 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] |
116
+ | 7️⃣ | spread 💖 | [![Liberapay Patrons][⛳liberapay-img]][⛳liberapay] [![Sponsor Me][🖇sponsor-img]][🖇sponsor] [![Tweet @ Peter][🏘tweet-img]][🏘tweet] [🌏][aboutme] [👼][angelme] [💻][coderme] [🌹][politicme] |
117
+
118
+ <!--
119
+ The link tokens in the following sections should be kept ordered by the row and badge numbering scheme
120
+ -->
121
+
122
+ <!-- 1️⃣ name, license, docs -->
123
+ [⛳️gem]: https://rubygems.org/gems/oauth2
124
+ [⛳️name-img]: https://img.shields.io/badge/name-oauth2-brightgreen.svg?style=flat
125
+ [🖇src-license]: https://opensource.org/licenses/MIT
126
+ [🖇src-license-img]: https://img.shields.io/badge/License-MIT-green.svg
127
+ [🏘fossa]: https://app.fossa.io/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2?ref=badge_shield
128
+ [🏘fossa-img]: https://app.fossa.io/api/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2.svg?type=shield
129
+ [🚎yard]: https://www.rubydoc.info/github/oauth-xx/oauth2
130
+ [🚎yard-img]: https://img.shields.io/badge/documentation-rubydoc-brightgreen.svg?style=flat
131
+ [🖐inch-ci-img]: http://inch-ci.org/github/oauth-xx/oauth2.png
132
+
133
+ <!-- 2️⃣ version & activity -->
134
+ [⛳️version-img]: http://img.shields.io/gem/v/oauth2.svg
135
+ [🖇DL-total-img]: https://img.shields.io/gem/dt/oauth2.svg
136
+ [🏘DL-rank-img]: https://img.shields.io/gem/rt/oauth2.svg
137
+ [🚎src-home]: https://github.com/oauth-xx/oauth2
138
+ [🚎src-home-img]: https://img.shields.io/badge/source-github-brightgreen.svg?style=flat
139
+ [🖐prs-o]: https://github.com/oauth-xx/oauth2/pulls
140
+ [🖐prs-o-img]: https://img.shields.io/github/issues-pr/oauth-xx/oauth2
141
+ [🧮prs-c]: https://github.com/oauth-xx/oauth2/pulls?q=is%3Apr+is%3Aclosed
142
+ [🧮prs-c-img]: https://img.shields.io/github/issues-pr-closed/oauth-xx/oauth2
143
+ [📗next]: https://github.com/oauth-xx/oauth2/milestone/1
144
+ [📗next-img]: https://img.shields.io/github/milestones/progress/oauth-xx/oauth2/1?label=Next%20Version
145
+
146
+ <!-- 3️⃣ maintanence & linting -->
147
+ [⛳cclim-maint]: https://codeclimate.com/github/oauth-xx/oauth2/maintainability
148
+ [⛳cclim-maint-img♻️]: https://api.codeclimate.com/v1/badges/688c612528ff90a46955/maintainability
149
+ [🖇triage-help]: https://www.codetriage.com/oauth-xx/oauth2
150
+ [🖇triage-help-img]: https://www.codetriage.com/oauth-xx/oauth2/badges/users.svg
151
+ [🏘depfu♻️]: https://depfu.com/github/oauth-xx/oauth2?project_id=4445
152
+ [🏘depfu-img♻️]: https://badges.depfu.com/badges/6d34dc1ba682bbdf9ae2a97848241743/count.svg
153
+ [🚎contributors]: https://github.com/oauth-xx/oauth2/graphs/contributors
154
+ [🚎contributors-img]: https://img.shields.io/github/contributors-anon/oauth-xx/oauth2
155
+ [🖐style-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/style.yml
156
+ [🖐style-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/style.yml/badge.svg
157
+ [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
158
+ [🧮kloc-img]: https://img.shields.io/tokei/lines/github.com/oauth-xx/oauth2
159
+
160
+ <!-- 4️⃣ testing -->
161
+ [⛳iss-o]: https://github.com/oauth-xx/oauth2/issues
162
+ [⛳iss-o-img]: https://img.shields.io/github/issues-raw/oauth-xx/oauth2
163
+ [🖇iss-c]: https://github.com/oauth-xx/oauth2/issues?q=is%3Aissue+is%3Aclosed
164
+ [🖇iss-c-img]: https://img.shields.io/github/issues-closed-raw/oauth-xx/oauth2
165
+ [🏘sup-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/supported.yml
166
+ [🏘sup-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/supported.yml/badge.svg
167
+ [🚎heads-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/heads.yml
168
+ [🚎heads-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/heads.yml/badge.svg
169
+ [🖐uns-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/unsupported.yml
170
+ [🖐uns-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/unsupported.yml/badge.svg
171
+ [🧮mac-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/macos.yml
172
+ [🧮mac-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/macos.yml/badge.svg
173
+ [📗win-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/windows.yml
174
+ [📗win-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/windows.yml/badge.svg
175
+
176
+ <!-- 5️⃣ coverage & security -->
177
+ [⛳cclim-cov]: https://codeclimate.com/github/oauth-xx/oauth2/test_coverage
178
+ [⛳cclim-cov-img♻️]: https://api.codeclimate.com/v1/badges/688c612528ff90a46955/test_coverage
179
+ [🖇codecov-img♻️]: https://codecov.io/gh/oauth-xx/oauth2/branch/master/graph/badge.svg?token=bNqSzNiuo2
180
+ [🖇codecov]: https://codecov.io/gh/oauth-xx/oauth2
181
+ [🏘coveralls]: https://coveralls.io/github/oauth-xx/oauth2?branch=master
182
+ [🏘coveralls-img]: https://coveralls.io/repos/github/oauth-xx/oauth2/badge.svg?branch=master
183
+ [🚎sec-pol]: https://github.com/oauth-xx/oauth2/blob/master/SECURITY.md
184
+ [🚎sec-pol-img]: https://img.shields.io/badge/security-policy-brightgreen.svg?style=flat
185
+ [🖐codeQL]: https://github.com/oauth-xx/oauth2/security/code-scanning
186
+ [🖐codeQL-img]: https://github.com/oauth-xx/oauth2/actions/workflows/codeql-analysis.yml/badge.svg
187
+ [🧮cov-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/coverage.yml
188
+ [🧮cov-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/coverage.yml/badge.svg
189
+
190
+ <!-- 6️⃣ resources -->
191
+ [⛳gh-discussions]: https://github.com/oauth-xx/oauth2/discussions
192
+ [⛳gh-discussions-img]: https://img.shields.io/github/discussions/oauth-xx/oauth2
193
+ [🖇codementor]: https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github
194
+ [🖇codementor-img]: https://cdn.codementor.io/badges/get_help_github.svg
195
+ [🏘chat]: https://gitter.im/oauth-xx/oauth2
196
+ [🏘chat-img]: https://img.shields.io/gitter/room/oauth-xx/oauth2.svg
197
+ [🚎blog]: http://www.railsbling.com/tags/oauth2/
198
+ [🚎blog-img]: https://img.shields.io/badge/blog-railsbling-brightgreen.svg?style=flat
199
+ [🖐wiki]: https://github.com/oauth-xx/oauth2/wiki
200
+ [🖐wiki-img]: https://img.shields.io/badge/wiki-examples-brightgreen.svg?style=flat
201
+
202
+ <!-- 7️⃣ spread 💖 -->
203
+ [⛳liberapay-img]: https://img.shields.io/liberapay/patrons/pboling.svg?logo=liberapay
204
+ [⛳liberapay]: https://liberapay.com/pboling/donate
205
+ [🖇sponsor-img]: https://img.shields.io/badge/sponsor-pboling.svg?style=social&logo=github
206
+ [🖇sponsor]: https://github.com/sponsors/pboling
207
+ [🏘tweet-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow
208
+ [🏘tweet]: http://twitter.com/galtzo
209
+
210
+ <!-- Maintainer Contact Links -->
211
+ [railsbling]: http://www.railsbling.com
212
+ [peterboling]: http://www.peterboling.com
213
+ [aboutme]: https://about.me/peter.boling
214
+ [angelme]: https://angel.co/peter-boling
215
+ [coderme]:http://coderwall.com/pboling
216
+ [politicme]: https://nationalprogressiveparty.org
2
217
 
3
- [![Gem Version](http://img.shields.io/gem/v/oauth2.svg)][gem]
4
- [![Build Status](http://img.shields.io/travis/intridea/oauth2.svg)][travis]
5
- [![Dependency Status](http://img.shields.io/gemnasium/intridea/oauth2.svg)][gemnasium]
6
- [![Code Climate](http://img.shields.io/codeclimate/github/intridea/oauth2.svg)][codeclimate]
7
- [![Coverage Status](http://img.shields.io/coveralls/intridea/oauth2.svg)][coveralls]
218
+ ## Installation
8
219
 
9
- [gem]: https://rubygems.org/gems/oauth2
10
- [travis]: http://travis-ci.org/intridea/oauth2
11
- [gemnasium]: https://gemnasium.com/intridea/oauth2
12
- [codeclimate]: https://codeclimate.com/github/intridea/oauth2
13
- [coveralls]: https://coveralls.io/r/intridea/oauth2
220
+ Install the gem and add to the application's Gemfile by executing:
14
221
 
15
- A Ruby wrapper for the OAuth 2.0 specification.
222
+ $ bundle add oauth2
16
223
 
17
- ## Installation
18
- gem install oauth2
224
+ If bundler is not being used to manage dependencies, install the gem by executing:
225
+
226
+ $ gem install oauth2
227
+
228
+ ## OAuth2 for Enterprise
229
+
230
+ Available as part of the Tidelift Subscription.
231
+
232
+ The maintainers of OAuth2 and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. [Learn more.](https://tidelift.com/subscription/pkg/rubygems-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 (unreleased, `master` branch)?
19
242
 
20
- ## Resources
21
- * [View Source on GitHub][code]
22
- * [Report Issues on GitHub][issues]
23
- * [Read More at the Wiki][wiki]
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
+ - [... A lot more](https://github.com/oauth-xx/oauth2/blob/master/CHANGELOG.md#unreleased)
24
257
 
25
- [code]: https://github.com/intridea/oauth2
26
- [issues]: https://github.com/intridea/oauth2/issues
27
- [wiki]: https://wiki.github.com/intridea/oauth2
258
+ ## Compatibility
259
+
260
+ Targeted ruby compatibility is non-EOL versions of Ruby, currently 2.7, 3.0 and
261
+ 3.1. Compatibility is further distinguished by supported and unsupported versions of Ruby.
262
+ Ruby is limited to 2.2+ for 2.x releases. See `1-4-stable` branch for older rubies.
263
+
264
+ <details>
265
+ <summary>Ruby Engine Compatibility Policy</summary>
266
+
267
+ This gem is tested against MRI, JRuby, and Truffleruby.
268
+ Each of those has varying versions that target a specific version of MRI Ruby.
269
+ This gem should work in the just-listed Ruby engines according to the targeted MRI compatibility in the table below.
270
+ If you would like to add support for additional engines,
271
+ first make sure Github Actions supports the engine,
272
+ then submit a PR to the correct maintenance branch as according to the table below.
273
+ </details>
274
+
275
+ <details>
276
+ <summary>Ruby Version Compatibility Policy</summary>
277
+
278
+ If something doesn't work on one of these interpreters, it's a bug.
279
+
280
+ This library may inadvertently work (or seem to work) on other Ruby
281
+ implementations, however support will only be provided for the versions listed
282
+ above.
283
+
284
+ If you would like this library to support another Ruby version, you may
285
+ volunteer to be a maintainer. Being a maintainer entails making sure all tests
286
+ run and pass on that implementation. When something breaks on your
287
+ implementation, you will be responsible for providing patches in a timely
288
+ fashion. If critical issues for a particular implementation exist at the time
289
+ of a major release, support for that Ruby version may be dropped.
290
+ </details>
291
+
292
+ | | Ruby OAuth 2 Version | Maintenance Branch | Supported Officially | Supported Unofficially | Supported Incidentally |
293
+ |:----|----------------------|--------------------|-------------------------|------------------------|------------------------|
294
+ | 1️⃣ | 2.0.x (unreleased) | `master` | 2.7, 3.0, 3.1 | 2.5, 2.6 | 2.2, 2.3, 2.4 |
295
+ | 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 |
296
+ | 3️⃣ | older | N/A | Best of luck to you! | Please upgrade! | |
297
+
298
+ NOTE: The 1.4 series will only receive critical bug and security updates.
299
+ See [SECURITY.md][🚎sec-pol]
28
300
 
29
301
  ## Usage Examples
30
302
 
303
+ ### `authorize_url` and `token_url` are on site root (Just Works!)
304
+
31
305
  ```ruby
32
306
  require 'oauth2'
33
- client = OAuth2::Client.new('client_id', 'client_secret', :site => 'https://example.org')
307
+ client = OAuth2::Client.new('client_id', 'client_secret', site: 'https://example.org')
308
+ # => #<OAuth2::Client:0x00000001204c8288 @id="client_id", @secret="client_sec...
309
+ client.auth_code.authorize_url(redirect_uri: 'http://localhost:8080/oauth2/callback')
310
+ # => "https://example.org/oauth/authorize?client_id=client_id&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Foauth2%2Fcallback&response_type=code"
34
311
 
35
- client.auth_code.authorize_url(:redirect_uri => 'http://localhost:8080/oauth2/callback')
36
- # => "https://example.org/oauth/authorization?response_type=code&client_id=client_id&redirect_uri=http://localhost:8080/oauth2/callback"
37
-
38
- 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 => { 'query_foo' => 'bar' })
312
+ token = client.auth_code.get_token('authorization_code_value', redirect_uri: 'http://localhost:8080/oauth2/callback', headers: {'Authorization' => 'Basic some_password'})
313
+ response = token.get('/api/resource', params: {'query_foo' => 'bar'})
40
314
  response.class.name
41
315
  # => OAuth2::Response
42
316
  ```
317
+
318
+ ### Relative `authorize_url` and `token_url` (Not on site root, Just Works!)
319
+
320
+ 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.
321
+
322
+ ```ruby
323
+ client = OAuth2::Client.new('client_id', 'client_secret', site: 'https://example.org/nested/directory/on/your/server')
324
+ # => #<OAuth2::Client:0x00000001204c8288 @id="client_id", @secret="client_sec...
325
+ client.auth_code.authorize_url(redirect_uri: 'http://localhost:8080/oauth2/callback')
326
+ # => "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"
327
+ ```
328
+
329
+ ### Customize `authorize_url` and `token_url`
330
+
331
+ You can specify custom URLs for authorization and access token, and when using a leading `/` they will _not be relative_, as shown below:
332
+
333
+ ```ruby
334
+ client = OAuth2::Client.new('client_id', 'client_secret',
335
+ site: 'https://example.org/nested/directory/on/your/server',
336
+ authorize_url: '/jaunty/authorize/',
337
+ token_url: '/stirrups/access_token')
338
+ # => #<OAuth2::Client:0x00000001204c8288 @id="client_id", @secret="client_sec...
339
+ client.auth_code.authorize_url(redirect_uri: 'http://localhost:8080/oauth2/callback')
340
+ # => "https://example.org/jaunty/authorize/?client_id=client_id&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Foauth2%2Fcallback&response_type=code"
341
+ client.class.name
342
+ # => OAuth2::Client
343
+ ```
344
+
345
+ <details>
346
+ <summary>Debugging</summary>
347
+
348
+ Set an environment variable, however you would [normally do that](https://github.com/bkeepers/dotenv).
349
+
350
+ ```ruby
351
+ # will log both request and response, including bodies
352
+ ENV['OAUTH_DEBUG'] = 'true'
353
+ ```
354
+
355
+ By default, debug output will go to `$stdout`. This can be overridden when
356
+ initializing your OAuth2::Client.
357
+
358
+ ```ruby
359
+ require 'oauth2'
360
+ client = OAuth2::Client.new(
361
+ 'client_id',
362
+ 'client_secret',
363
+ site: 'https://example.org',
364
+ logger: Logger.new('example.log', 'weekly')
365
+ )
366
+ ```
367
+ </details>
368
+
43
369
  ## OAuth2::Response
44
- The AccessToken methods #get, #post, #put and #delete and the generic #request
370
+
371
+ The `AccessToken` methods `#get`, `#post`, `#put` and `#delete` and the generic `#request`
45
372
  will return an instance of the #OAuth2::Response class.
46
373
 
47
- This instance contains a #parsed method that will parse the response body and
48
- return a Hash if the Content-Type is application/x-www-form-urlencoded or if
374
+ This instance contains a `#parsed` method that will parse the response body and
375
+ return a Hash if the `Content-Type` is `application/x-www-form-urlencoded` or if
49
376
  the body is a JSON object. It will return an Array if the body is a JSON
50
377
  array. Otherwise, it will return the original body string.
51
378
 
@@ -53,32 +380,35 @@ The original response body, headers, and status can be accessed via their
53
380
  respective methods.
54
381
 
55
382
  ## OAuth2::AccessToken
383
+
56
384
  If you have an existing Access Token for a user, you can initialize an instance
57
- using various class methods including the standard new, from_hash (if you have
58
- a hash of the values), or from_kvform (if you have an
59
- application/x-www-form-urlencoded encoded string of the values).
385
+ using various class methods including the standard new, `from_hash` (if you have
386
+ a hash of the values), or `from_kvform` (if you have an
387
+ `application/x-www-form-urlencoded` encoded string of the values).
60
388
 
61
389
  ## OAuth2::Error
62
- On 400+ status code responses, an OAuth2::Error will be raised. If it is a
63
- standard OAuth2 error response, the body will be parsed and #code and #description will contain the values provided from the error and
64
- error_description parameters. The #response property of OAuth2::Error will
65
- always contain the OAuth2::Response instance.
66
390
 
67
- If you do not want an error to be raised, you may use :raise_errors => false
68
- option on initialization of the client. In this case the OAuth2::Response
391
+ On 400+ status code responses, an `OAuth2::Error` will be raised. If it is a
392
+ standard OAuth2 error response, the body will be parsed and `#code` and `#description` will contain the values provided from the error and
393
+ `error_description` parameters. The `#response` property of `OAuth2::Error` will
394
+ always contain the `OAuth2::Response` instance.
395
+
396
+ If you do not want an error to be raised, you may use `:raise_errors => false`
397
+ option on initialization of the client. In this case the `OAuth2::Response`
69
398
  instance will be returned as usual and on 400+ status code responses, the
70
- Response instance will contain the OAuth2::Error instance.
399
+ Response instance will contain the `OAuth2::Error` instance.
71
400
 
72
401
  ## Authorization Grants
402
+
73
403
  Currently the Authorization Code, Implicit, Resource Owner Password Credentials, Client Credentials, and Assertion
74
404
  authentication grant types have helper strategy classes that simplify client
75
- use. They are available via the #auth_code, #implicit, #password, #client_credentials, and #assertion methods respectively.
405
+ use. They are available via the `#auth_code`, `#implicit`, `#password`, `#client_credentials`, and `#assertion` methods respectively.
76
406
 
77
407
  ```ruby
78
- auth_url = client.auth_code.authorize_url(:redirect_uri => 'http://localhost:8080/oauth/callback')
79
- token = client.auth_code.get_token('code_value', :redirect_uri => 'http://localhost:8080/oauth/callback')
408
+ auth_url = client.auth_code.authorize_url(redirect_uri: 'http://localhost:8080/oauth/callback')
409
+ token = client.auth_code.get_token('code_value', redirect_uri: 'http://localhost:8080/oauth/callback')
80
410
 
81
- auth_url = client.implicit.authorize_url(:redirect_uri => 'http://localhost:8080/oauth/callback')
411
+ auth_url = client.implicit.authorize_url(redirect_uri: 'http://localhost:8080/oauth/callback')
82
412
  # get the token params in the callback and
83
413
  token = OAuth2::AccessToken.from_kvform(client, query_string)
84
414
 
@@ -93,41 +423,57 @@ If you want to specify additional headers to be sent out with the
93
423
  request, add a 'headers' hash under 'params':
94
424
 
95
425
  ```ruby
96
- token = client.auth_code.get_token('code_value', :redirect_uri => 'http://localhost:8080/oauth/callback', :headers => {'Some' => 'Header'})
426
+ token = client.auth_code.get_token('code_value', redirect_uri: 'http://localhost:8080/oauth/callback', headers: {'Some' => 'Header'})
97
427
  ```
98
428
 
99
- You can always use the #request method on the OAuth2::Client instance to make
429
+ You can always use the `#request` method on the `OAuth2::Client` instance to make
100
430
  requests for tokens for any Authentication grant type.
101
431
 
102
- ## Supported Ruby Versions
103
- This library aims to support and is [tested against][travis] the following Ruby
104
- implementations:
432
+ ## Versioning
105
433
 
106
- * Ruby 1.9.3
107
- * Ruby 2.0.0
108
- * Ruby 2.1
109
- * Ruby 2.2
110
- * Ruby 2.3
111
- * Ruby 2.4
112
- * [JRuby 9K][jruby]
434
+ This library aims to adhere to [Semantic Versioning 2.0.0][semver].
435
+ Violations of this scheme should be reported as bugs. Specifically,
436
+ if a minor or patch version is released that breaks backward
437
+ compatibility, a new version should be immediately released that
438
+ restores compatibility. Breaking changes to the public API will
439
+ only be introduced with new major versions.
113
440
 
114
- [jruby]: http://jruby.org/
441
+ As a result of this policy, you can (and should) specify a
442
+ dependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision.
115
443
 
116
- If something doesn't work on one of these interpreters, it's a bug.
444
+ For example:
117
445
 
118
- This library may inadvertently work (or seem to work) on other Ruby
119
- implementations, however support will only be provided for the versions listed
120
- above.
446
+ ```ruby
447
+ spec.add_dependency 'oauth2', '~> 2.0'
448
+ ```
121
449
 
122
- If you would like this library to support another Ruby version, you may
123
- volunteer to be a maintainer. Being a maintainer entails making sure all tests
124
- run and pass on that implementation. When something breaks on your
125
- implementation, you will be responsible for providing patches in a timely
126
- fashion. If critical issues for a particular implementation exist at the time
127
- of a major release, support for that Ruby version may be dropped.
450
+ [semver]: http://semver.org/
451
+ [pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
128
452
 
129
453
  ## License
130
- Copyright (c) 2011-2013 Michael Bleigh and Intridea, Inc. See [LICENSE][] for
131
- details.
132
454
 
133
- [license]: LICENSE.md
455
+ [![License: MIT][🖇src-license-img]][🖇src-license]
456
+
457
+ - Copyright (c) 2011-2013 Michael Bleigh and Intridea, Inc.
458
+ - Copyright (c) 2017-2022 [oauth-xx organization][oauth-xx]
459
+ - See [LICENSE][license] for details.
460
+
461
+ [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2.svg?type=large)][fossa2]
462
+
463
+ [license]: https://github.com/oauth-xx/oauth2/blob/master/LICENSE
464
+ [oauth-xx]: https://github.com/oauth-xx
465
+ [fossa2]: https://app.fossa.io/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2?ref=badge_large
466
+
467
+ ## Development
468
+
469
+ 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.
470
+
471
+ 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).
472
+
473
+ ## Contributing
474
+
475
+ 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.
476
+
477
+ ## Code of Conduct
478
+
479
+ 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/SECURITY.md ADDED
@@ -0,0 +1,14 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ |--------------|-----------|
7
+ | 2.0.<latest> | ✅ |
8
+ | 1.4.<latest> | ✅ |
9
+ | older | ⛔️ |
10
+
11
+ ## Reporting a Vulnerability
12
+
13
+ To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
14
+ Tidelift will coordinate the fix and disclosure.