oauth2 1.4.7 → 1.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -2
- data/LICENSE +1 -1
- data/README.md +276 -116
- data/lib/oauth2/client.rb +4 -7
- data/lib/oauth2/error.rb +1 -1
- data/lib/oauth2/mac_token.rb +16 -18
- data/lib/oauth2/version.rb +1 -1
- data/spec/helper.rb +6 -13
- data/spec/oauth2/client_spec.rb +27 -3
- data/spec/oauth2/mac_token_spec.rb +3 -0
- data/spec/oauth2/strategy/assertion_spec.rb +2 -1
- data/spec/oauth2/strategy/client_credentials_spec.rb +1 -1
- data/spec/oauth2/strategy/password_spec.rb +2 -1
- metadata +15 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9cd34855e4a7388c32053dbf97a38dafc04685818b1de1244a5782944ba742d
|
4
|
+
data.tar.gz: e763de5d77201cfb9661458882d4a52a87268804a7455207b72f997815abba74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b0ee6b53136ba7ef8cb6614eba4bd8af80dfc274dfc0cc857e07edfcfe8a3e6f6f59e38144581c4509c3a674e7f8a6ce7389e7f2f27dae02536b07e63815bb6
|
7
|
+
data.tar.gz: 0ad35386515cdca17ef71ad5a7e6c98851532ea6549de173b6131289147f0745f8ae992b5d0ff49fb300125873495c81eb81f4fd48b1d0898e88f94e57bb33f1
|
data/CHANGELOG.md
CHANGED
@@ -3,11 +3,21 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
|
4
4
|
## unreleased
|
5
5
|
|
6
|
-
## [1.4.
|
6
|
+
## [1.4.8] - 2022-02-18
|
7
|
+
|
8
|
+
- MFA is now required to push new gem versions (@pboling)
|
9
|
+
- README overhaul w/ new Ruby Verion and Engine compatibility policies (@pboling)
|
10
|
+
- [#569](https://github.com/oauth-xx/oauth2/pull/569) Backport fixes ([#561](https://github.com/oauth-xx/oauth2/pull/561) by @ryogift), and add more fixes, to allow faraday 1.x and 2.x (@jrochkind)
|
11
|
+
- Improve Code Coverage tracking (Coveralls, CodeCov, CodeClimate), and enable branch coverage (@pboling)
|
12
|
+
- Add CodeQL, Security Policy, Funding info (@pboling)
|
13
|
+
- Added Ruby 3.1, jruby, jruby-head, truffleruby, truffleruby-head to build matrix (@pboling)
|
14
|
+
- [#543](https://github.com/oauth-xx/oauth2/pull/543) - Support for more modern Open SSL libraries (@pboling)
|
15
|
+
|
16
|
+
## [1.4.7] - 2021-03-19
|
7
17
|
|
8
18
|
- [#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
19
|
|
10
|
-
## [1.4.6] - 2021-03-
|
20
|
+
## [1.4.6] - 2021-03-19
|
11
21
|
|
12
22
|
- [#540](https://github.com/oauth-xx/oauth2/pull/540) - Add VERSION constant (@pboling)
|
13
23
|
- [#537](https://github.com/oauth-xx/oauth2/pull/537) - Fix crash in OAuth2::Client#get_token (@anderscarling)
|
@@ -17,6 +27,8 @@ All notable changes to this project will be documented in this file.
|
|
17
27
|
|
18
28
|
- [#535](https://github.com/oauth-xx/oauth2/pull/535) - Compatibility with range of supported Ruby OpenSSL versions, Rubocop updates, Github Actions (@pboling)
|
19
29
|
- [#518](https://github.com/oauth-xx/oauth2/pull/518) - Add extract_access_token option to OAuth2::Client (@jonspalmer)
|
30
|
+
- [#507](https://github.com/oauth-xx/oauth2/pull/507) - Fix camel case content type, response keys (@anvox)
|
31
|
+
- [#500](https://github.com/oauth-xx/oauth2/pull/500) - Fix YARD documentation formatting (@olleolleolle)
|
20
32
|
|
21
33
|
## [1.4.4] - 2020-02-12
|
22
34
|
|
@@ -167,4 +179,9 @@ All notable changes to this project will be documented in this file.
|
|
167
179
|
[1.4.1]: https://github.com/oauth-xx/oauth2/compare/v1.4.0...v1.4.1
|
168
180
|
[1.4.2]: https://github.com/oauth-xx/oauth2/compare/v1.4.1...v1.4.2
|
169
181
|
[1.4.3]: https://github.com/oauth-xx/oauth2/compare/v1.4.2...v1.4.3
|
182
|
+
[1.4.4]: https://github.com/oauth-xx/oauth2/compare/v1.4.3...v1.4.4
|
183
|
+
[1.4.5]: https://github.com/oauth-xx/oauth2/compare/v1.4.4...v1.4.5
|
184
|
+
[1.4.6]: https://github.com/oauth-xx/oauth2/compare/v1.4.5...v1.4.6
|
185
|
+
[1.4.7]: https://github.com/oauth-xx/oauth2/compare/v1.4.6...v1.4.7
|
186
|
+
[1.4.8]: https://github.com/oauth-xx/oauth2/compare/v1.4.7...v1.4.8
|
170
187
|
[unreleased]: https://github.com/oauth-xx/oauth2/compare/v1.4.1...HEAD
|
data/LICENSE
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
3
|
Copyright (c) 2011 - 2013 Michael Bleigh and Intridea, Inc.
|
4
|
-
Copyright (c) 2017 -
|
4
|
+
Copyright (c) 2017 - 2022 oauth-xx organization, https://github.com/oauth-xx
|
5
5
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,78 +1,260 @@
|
|
1
|
-
|
1
|
+
<p align="center">
|
2
|
+
<a href="http://oauth.net/2/" target="_blank" rel="noopener noreferrer">
|
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 noreferrer">
|
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
|
+
⚠️ **_WARNING_**: You are viewing the `README` of the soon-to-be-deprecated `1-4-stable`
|
19
|
+
branch which for version 1.4.x releases. Version 2.0 is coming! ⚠️
|
2
20
|
|
3
|
-
|
21
|
+
---
|
22
|
+
|
23
|
+
* [OAuth 2.0 Spec][oauth2-spec]
|
24
|
+
* [OAuth 1.0 sibling gem][sibling-gem]
|
25
|
+
* Help us finish release [![2.0.0 release milestone][next-milestone-pct-img]][next-milestone-pct] by submitting or reviewing PRs and issues.
|
26
|
+
* Oauth2 gem is _always_ looking for additional maintainers. See [#307][maintainers-discussion].
|
27
|
+
|
28
|
+
[oauth2-spec]: https://oauth.net/2/
|
29
|
+
[sibling-gem]: https://github.com/oauth-xx/oauth-ruby
|
30
|
+
[next-milestone-pct]: https://github.com/oauth-xx/oauth2/milestone/1
|
31
|
+
[next-milestone-pct-img]: https://img.shields.io/github/milestones/progress-percent/oauth-xx/oauth2/1
|
32
|
+
[maintainers-discussion]: https://github.com/oauth-xx/oauth2/issues/307
|
33
|
+
|
34
|
+
## Release Documentation
|
35
|
+
|
36
|
+
<details>
|
37
|
+
<summary>1.4.x Readmes</summary>
|
38
|
+
|
39
|
+
| Version | Release Date | Readme |
|
40
|
+
|---------|--------------|----------------------------------------------------------|
|
41
|
+
| 1.4.8 | Feb 18, 2022 | https://github.com/oauth-xx/oauth2/blob/v1.4.8/README.md |
|
42
|
+
| 1.4.7 | Mar 18, 2021 | https://github.com/oauth-xx/oauth2/blob/v1.4.7/README.md |
|
43
|
+
| 1.4.6 | Mar 18, 2021 | https://github.com/oauth-xx/oauth2/blob/v1.4.6/README.md |
|
44
|
+
| 1.4.5 | Mar 18, 2021 | https://github.com/oauth-xx/oauth2/blob/v1.4.5/README.md |
|
45
|
+
| 1.4.4 | Feb 12, 2020 | https://github.com/oauth-xx/oauth2/blob/v1.4.4/README.md |
|
46
|
+
| 1.4.3 | Jan 29, 2020 | https://github.com/oauth-xx/oauth2/blob/v1.4.3/README.md |
|
47
|
+
| 1.4.2 | Oct 1, 2019 | https://github.com/oauth-xx/oauth2/blob/v1.4.2/README.md |
|
48
|
+
| 1.4.1 | Oct 13, 2018 | https://github.com/oauth-xx/oauth2/blob/v1.4.1/README.md |
|
49
|
+
| 1.4.0 | Jun 9, 2017 | https://github.com/oauth-xx/oauth2/blob/v1.4.0/README.md |
|
50
|
+
</details>
|
51
|
+
|
52
|
+
<details>
|
53
|
+
<summary>1.3.x Readmes</summary>
|
4
54
|
|
5
55
|
| Version | Release Date | Readme |
|
6
56
|
|----------|--------------|----------------------------------------------------------|
|
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
57
|
| 1.3.1 | Mar 3, 2017 | https://github.com/oauth-xx/oauth2/blob/v1.3.1/README.md |
|
16
58
|
| 1.3.0 | Dec 27, 2016 | https://github.com/oauth-xx/oauth2/blob/v1.3.0/README.md |
|
59
|
+
</details>
|
60
|
+
|
61
|
+
<details>
|
62
|
+
<summary>≤= 1.2.x Readmes (2016 and before)</summary>
|
63
|
+
|
64
|
+
| Version | Release Date | Readme |
|
65
|
+
|----------|--------------|----------------------------------------------------------|
|
17
66
|
| 1.2.0 | Jun 30, 2016 | https://github.com/oauth-xx/oauth2/blob/v1.2.0/README.md |
|
18
67
|
| 1.1.0 | Jan 30, 2016 | https://github.com/oauth-xx/oauth2/blob/v1.1.0/README.md |
|
19
68
|
| 1.0.0 | May 23, 2014 | https://github.com/oauth-xx/oauth2/blob/v1.0.0/README.md |
|
20
69
|
| < 1.0.0 | Find here | https://github.com/oauth-xx/oauth2/tags |
|
70
|
+
</details>
|
71
|
+
|
72
|
+
<!--
|
73
|
+
Numbering rows and badges in each row as a visual "database" lookup,
|
74
|
+
as the table is extremely dense, and it can be very difficult to find anything
|
75
|
+
Putting one on each row here, to document the emoji that should be used, and for ease of copy/paste.
|
76
|
+
|
77
|
+
row #s:
|
78
|
+
1️⃣
|
79
|
+
2️⃣
|
80
|
+
3️⃣
|
81
|
+
4️⃣
|
82
|
+
5️⃣
|
83
|
+
6️⃣
|
84
|
+
7️⃣
|
85
|
+
|
86
|
+
badge #s:
|
87
|
+
⛳️
|
88
|
+
🖇
|
89
|
+
🏘
|
90
|
+
🚎
|
91
|
+
🖐
|
92
|
+
🧮
|
93
|
+
📗
|
94
|
+
-->
|
95
|
+
|
96
|
+
| | Project | oauth2 |
|
97
|
+
|:----|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
98
|
+
| 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] |
|
99
|
+
| 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-open-img]][🖐prs-open] [![Closed PRs][🧮prs-closed-img]][🧮prs-closed] |
|
100
|
+
| 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] |
|
101
|
+
| 4️⃣ | testing | [![Build][⛳️tot-bld-img]][⛳️tot-bld] [![supported][🖇supported-wf-img]][🖇supported-wf] [![EOL & Code Coverage Build][🏘eol-wf-img]][🏘eol-wf] [![unsupported][🚎unsupported-wf-img]][🚎unsupported-wf] |
|
102
|
+
| 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] |
|
103
|
+
| 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] |
|
104
|
+
| 7️⃣ | spread 💖 | [![Liberapay Patrons][⛳liberapay-img]][⛳liberapay] [![Sponsor Me][🖇sponsor-img]][🖇sponsor] [![Tweet @ Peter][🏘tweet-img]][🏘tweet] [🌏][aboutme] [👼][angelme] [💻][coderme] [🌹][politicme] |
|
105
|
+
|
106
|
+
<!--
|
107
|
+
The link tokens in the following sections should be kept ordered by the row and badge numbering scheme
|
108
|
+
-->
|
109
|
+
|
110
|
+
<!-- 1️⃣ name, license, docs -->
|
111
|
+
[⛳️gem]: https://rubygems.org/gems/oauth2
|
112
|
+
[⛳️name-img]: https://img.shields.io/badge/name-oauth2-brightgreen.svg?style=flat
|
113
|
+
[🖇src-license]: https://opensource.org/licenses/MIT
|
114
|
+
[🖇src-license-img]: https://img.shields.io/badge/License-MIT-green.svg
|
115
|
+
[🏘fossa]: https://app.fossa.io/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2?ref=badge_shield
|
116
|
+
[🏘fossa-img]: https://app.fossa.io/api/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2.svg?type=shield
|
117
|
+
[🚎yard]: https://www.rubydoc.info/github/oauth-xx/oauth2
|
118
|
+
[🚎yard-img]: https://img.shields.io/badge/documentation-rubydoc-brightgreen.svg?style=flat
|
119
|
+
[🖐inch-ci-img]: http://inch-ci.org/github/oauth-xx/oauth2.png
|
120
|
+
|
121
|
+
<!-- 2️⃣ version & activity -->
|
122
|
+
[⛳️version-img]: http://img.shields.io/gem/v/oauth2.svg
|
123
|
+
[🖇DL-total-img]: https://img.shields.io/gem/dt/oauth2.svg
|
124
|
+
[🏘DL-rank-img]: https://img.shields.io/gem/rt/oauth2.svg
|
125
|
+
[🚎src-home]: https://github.com/oauth-xx/oauth2
|
126
|
+
[🚎src-home-img]: https://img.shields.io/badge/source-github-brightgreen.svg?style=flat
|
127
|
+
[🖐prs-open]: https://github.com/oauth-xx/oauth2/pulls
|
128
|
+
[🖐prs-open-img]: https://img.shields.io/github/issues-pr/oauth-xx/oauth2
|
129
|
+
[🧮prs-closed]: https://github.com/oauth-xx/oauth2/pulls?q=is%3Apr+is%3Aclosed
|
130
|
+
[🧮prs-closed-img]: https://img.shields.io/github/issues-pr-closed/oauth-xx/oauth2
|
131
|
+
|
132
|
+
<!-- 3️⃣ maintanence & linting -->
|
133
|
+
[⛳cclim-maint]: https://codeclimate.com/github/oauth-xx/oauth2/maintainability
|
134
|
+
[⛳cclim-maint-img]: https://api.codeclimate.com/v1/badges/688c612528ff90a46955/maintainability
|
135
|
+
[🖇triage-help]: https://www.codetriage.com/oauth-xx/oauth2
|
136
|
+
[🖇triage-help-img]: https://www.codetriage.com/oauth-xx/oauth2/badges/users.svg
|
137
|
+
[🏘depfu]: https://depfu.com/github/oauth-xx/oauth2?project_id=4445
|
138
|
+
[🏘depfu-img]: https://badges.depfu.com/badges/6d34dc1ba682bbdf9ae2a97848241743/count.svg
|
139
|
+
[🚎contributors]: https://github.com/oauth-xx/oauth2/graphs/contributors
|
140
|
+
[🚎contributors-img]: https://img.shields.io/github/contributors-anon/oauth-xx/oauth2
|
141
|
+
[🖐style-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/style.yml
|
142
|
+
[🖐style-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/style.yml/badge.svg
|
143
|
+
[🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
|
144
|
+
[🧮kloc-img]: https://img.shields.io/tokei/lines/github.com/oauth-xx/oauth2
|
145
|
+
|
146
|
+
<!-- 4️⃣ testing -->
|
147
|
+
[⛳️tot-bld]: https://actions-badge.atrox.dev/oauth-xx/oauth2/goto
|
148
|
+
[⛳️tot-bld-img]: https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Foauth-xx%2Foauth2%2Fbadge&style=flat
|
149
|
+
[🖇supported-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/supported.yml
|
150
|
+
[🖇supported-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/supported.yml/badge.svg
|
151
|
+
[🏘eol-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/coverage.yml
|
152
|
+
[🏘eol-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/coverage.yml/badge.svg
|
153
|
+
[🚎unsupported-wf]: https://github.com/oauth-xx/oauth2/actions/workflows/unsupported.yml
|
154
|
+
[🚎unsupported-wf-img]: https://github.com/oauth-xx/oauth2/actions/workflows/unsupported.yml/badge.svg
|
155
|
+
[🖐issues]: https://github.com/oauth-xx/oauth2/issues
|
156
|
+
[🖐issues-img]: https://github.com/oauth-xx/oauth2/issues
|
157
|
+
|
158
|
+
<!-- 5️⃣ coverage & security -->
|
159
|
+
[⛳cclim-cov]: https://codeclimate.com/github/oauth-xx/oauth2/test_coverage
|
160
|
+
[⛳cclim-cov-img]: https://api.codeclimate.com/v1/badges/688c612528ff90a46955/test_coverage
|
161
|
+
[🖇codecov-img]: https://codecov.io/gh/oauth-xx/oauth2/branch/1-4-stable/graph/badge.svg?token=bNqSzNiuo2
|
162
|
+
[🖇codecov]: https://codecov.io/gh/oauth-xx/oauth2
|
163
|
+
[🏘coveralls]: https://coveralls.io/github/oauth-xx/oauth2?branch=1-4-stable
|
164
|
+
[🏘coveralls-img]: https://coveralls.io/repos/github/oauth-xx/oauth2/badge.svg?branch=1-4-stable
|
165
|
+
[🚎sec-pol]: https://github.com/oauth-xx/oauth2/blob/master/SECURITY.md
|
166
|
+
[🚎sec-pol-img]: https://img.shields.io/badge/security-policy-brightgreen.svg?style=flat
|
167
|
+
[🖐codeQL]: https://github.com/oauth-xx/oauth2/security/code-scanning
|
168
|
+
[🖐codeQL-img]: https://github.com/oauth-xx/oauth2/actions/workflows/codeql-analysis.yml/badge.svg
|
169
|
+
|
170
|
+
<!-- 6️⃣ resources -->
|
171
|
+
[⛳gh-discussions]: https://github.com/oauth-xx/oauth2/discussions
|
172
|
+
[⛳gh-discussions-img]: https://img.shields.io/github/discussions/oauth-xx/oauth2
|
173
|
+
[🖇codementor]: https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github
|
174
|
+
[🖇codementor-img]: https://cdn.codementor.io/badges/get_help_github.svg
|
175
|
+
[🏘chat]: https://gitter.im/oauth-xx/oauth2
|
176
|
+
[🏘chat-img]: https://img.shields.io/gitter/room/oauth-xx/oauth2.svg
|
177
|
+
[🚎blog]: http://www.railsbling.com/tags/oauth2/
|
178
|
+
[🚎blog-img]: https://img.shields.io/badge/blog-railsbling-brightgreen.svg?style=flat
|
179
|
+
[🖐wiki]: https://github.com/oauth-xx/oauth2/wiki
|
180
|
+
[🖐wiki-img]: https://img.shields.io/badge/wiki-examples-brightgreen.svg?style=flat
|
181
|
+
|
182
|
+
<!-- 7️⃣ spread 💖 -->
|
183
|
+
[⛳liberapay-img]: https://img.shields.io/liberapay/patrons/pboling.svg?logo=liberapay
|
184
|
+
[⛳liberapay]: https://liberapay.com/pboling/donate
|
185
|
+
[🖇sponsor-img]: https://img.shields.io/badge/sponsor-pboling.svg?style=social&logo=github
|
186
|
+
[🖇sponsor]: https://github.com/sponsors/pboling
|
187
|
+
[🏘tweet-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow
|
188
|
+
[🏘tweet]: http://twitter.com/galtzo
|
189
|
+
|
190
|
+
<!-- Maintainer Contact Links -->
|
191
|
+
[railsbling]: http://www.railsbling.com
|
192
|
+
[peterboling]: http://www.peterboling.com
|
193
|
+
[aboutme]: https://about.me/peter.boling
|
194
|
+
[angelme]: https://angel.co/peter-boling
|
195
|
+
[coderme]:http://coderwall.com/pboling
|
196
|
+
[politicme]: https://nationalprogressiveparty.org
|
21
197
|
|
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].
|
48
|
-
|
49
|
-
[oauth2-spec]: https://oauth.net/2/
|
50
198
|
|
51
199
|
## Installation
|
52
200
|
|
53
|
-
|
201
|
+
```shell
|
202
|
+
gem install oauth2
|
203
|
+
```
|
204
|
+
|
205
|
+
Or inside a `Gemfile`
|
54
206
|
|
55
207
|
```ruby
|
56
208
|
gem 'oauth2'
|
57
209
|
```
|
210
|
+
And then execute in a shell:
|
211
|
+
```shell
|
212
|
+
bundle
|
213
|
+
```
|
58
214
|
|
59
|
-
And then execute:
|
60
215
|
|
61
|
-
|
216
|
+
## Compatibility
|
62
217
|
|
63
|
-
|
218
|
+
Targeted ruby compatibility is non-EOL versions of Ruby, currently 2.7, 3.0 and
|
219
|
+
3.1. Compatibility is further distinguished by supported and unsupported versions of Ruby.
|
220
|
+
Ruby is limited to 1.9+ in the gemspec for the 1.4.x series and will be 2.2+ for 2.x releases (see `master` branch).
|
64
221
|
|
65
|
-
|
222
|
+
<details>
|
223
|
+
<summary>Ruby Engine Compatibility Policy</summary>
|
66
224
|
|
67
|
-
|
225
|
+
This gem is tested against MRI, JRuby, and Truffleruby.
|
226
|
+
Each of those has varying versions that target a specific version of MRI Ruby.
|
227
|
+
This gem should work in the just-listed Ruby engines according to the targeted MRI compatibility in the table below.
|
228
|
+
If you would like to add support for additional engines,
|
229
|
+
first make sure Github Actions supports the engine,
|
230
|
+
then submit a PR to the correct maintenance branch as according to the table below.
|
231
|
+
</details>
|
68
232
|
|
69
|
-
|
70
|
-
|
71
|
-
* [Read More at the Wiki][wiki]
|
233
|
+
<details>
|
234
|
+
<summary>Ruby Version Compatibility Policy</summary>
|
72
235
|
|
73
|
-
|
74
|
-
|
75
|
-
|
236
|
+
If something doesn't work on one of these interpreters, it's a bug.
|
237
|
+
|
238
|
+
This library may inadvertently work (or seem to work) on other Ruby
|
239
|
+
implementations, however support will only be provided for the versions listed
|
240
|
+
above.
|
241
|
+
|
242
|
+
If you would like this library to support another Ruby version, you may
|
243
|
+
volunteer to be a maintainer. Being a maintainer entails making sure all tests
|
244
|
+
run and pass on that implementation. When something breaks on your
|
245
|
+
implementation, you will be responsible for providing patches in a timely
|
246
|
+
fashion. If critical issues for a particular implementation exist at the time
|
247
|
+
of a major release, support for that Ruby version may be dropped.
|
248
|
+
</details>
|
249
|
+
|
250
|
+
| | Ruby OAuth 2 Version | Maintenance Branch | Supported Officially | Supported Unofficially | Supported Incidentally |
|
251
|
+
|:----|----------------------|--------------------|-------------------------|------------------------|------------------------|
|
252
|
+
| 1️⃣ | 2.0.x (unreleased) | `master` | 2.7, 3.0, 3.1 | 2.6, 2.5 | 2.4, 2.3, 2.2 |
|
253
|
+
| 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 | 2.0, 1.9 |
|
254
|
+
| 3️⃣ | older | N/A | Best of luck to you! | Please upgrade! | |
|
255
|
+
|
256
|
+
NOTE: Once 2.0 is released, the 1.4 series will only receive critical bug and security updates.
|
257
|
+
See [SECURITY.md][🚎sec-pol]
|
76
258
|
|
77
259
|
## Usage Examples
|
78
260
|
|
@@ -88,13 +270,38 @@ response = token.get('/api/resource', :params => {'query_foo' => 'bar'})
|
|
88
270
|
response.class.name
|
89
271
|
# => OAuth2::Response
|
90
272
|
```
|
273
|
+
|
274
|
+
<details>
|
275
|
+
<summary>Debugging</summary>
|
276
|
+
|
277
|
+
Set an environment variable, however you would [normally do that](https://github.com/bkeepers/dotenv).
|
278
|
+
|
279
|
+
```ruby
|
280
|
+
# will log both request and response, including bodies
|
281
|
+
ENV['OAUTH_DEBUG'] = 'true'
|
282
|
+
```
|
283
|
+
|
284
|
+
By default, debug output will go to `$stdout`. This can be overridden when
|
285
|
+
initializing your OAuth2::Client.
|
286
|
+
|
287
|
+
```ruby
|
288
|
+
require 'oauth2'
|
289
|
+
client = OAuth2::Client.new(
|
290
|
+
'client_id',
|
291
|
+
'client_secret',
|
292
|
+
:site => 'https://example.org',
|
293
|
+
:logger => Logger.new('example.log', 'weekly')
|
294
|
+
)
|
295
|
+
```
|
296
|
+
</details>
|
297
|
+
|
91
298
|
## OAuth2::Response
|
92
299
|
|
93
|
-
The AccessToken methods
|
300
|
+
The `AccessToken` methods `#get`, `#post`, `#put` and `#delete` and the generic `#request`
|
94
301
|
will return an instance of the #OAuth2::Response class.
|
95
302
|
|
96
|
-
This instance contains a
|
97
|
-
return a Hash if the Content-Type is application/x-www-form-urlencoded or if
|
303
|
+
This instance contains a `#parsed` method that will parse the response body and
|
304
|
+
return a Hash if the `Content-Type` is `application/x-www-form-urlencoded` or if
|
98
305
|
the body is a JSON object. It will return an Array if the body is a JSON
|
99
306
|
array. Otherwise, it will return the original body string.
|
100
307
|
|
@@ -104,27 +311,27 @@ respective methods.
|
|
104
311
|
## OAuth2::AccessToken
|
105
312
|
|
106
313
|
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).
|
314
|
+
using various class methods including the standard new, `from_hash` (if you have
|
315
|
+
a hash of the values), or `from_kvform` (if you have an
|
316
|
+
`application/x-www-form-urlencoded` encoded string of the values).
|
110
317
|
|
111
318
|
## OAuth2::Error
|
112
319
|
|
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
|
115
|
-
error_description parameters. The
|
116
|
-
always contain the OAuth2::Response instance.
|
320
|
+
On 400+ status code responses, an `OAuth2::Error` will be raised. If it is a
|
321
|
+
standard OAuth2 error response, the body will be parsed and `#code` and `#description` will contain the values provided from the error and
|
322
|
+
`error_description` parameters. The `#response` property of `OAuth2::Error` will
|
323
|
+
always contain the `OAuth2::Response` instance.
|
117
324
|
|
118
|
-
If you do not want an error to be raised, you may use
|
119
|
-
option on initialization of the client. In this case the OAuth2::Response
|
325
|
+
If you do not want an error to be raised, you may use `:raise_errors => false`
|
326
|
+
option on initialization of the client. In this case the `OAuth2::Response`
|
120
327
|
instance will be returned as usual and on 400+ status code responses, the
|
121
|
-
Response instance will contain the OAuth2::Error instance.
|
328
|
+
Response instance will contain the `OAuth2::Error` instance.
|
122
329
|
|
123
330
|
## Authorization Grants
|
124
331
|
|
125
332
|
Currently the Authorization Code, Implicit, Resource Owner Password Credentials, Client Credentials, and Assertion
|
126
333
|
authentication grant types have helper strategy classes that simplify client
|
127
|
-
use.
|
334
|
+
use. They are available via the `#auth_code`, `#implicit`, `#password`, `#client_credentials`, and `#assertion` methods respectively.
|
128
335
|
|
129
336
|
```ruby
|
130
337
|
auth_url = client.auth_code.authorize_url(:redirect_uri => 'http://localhost:8080/oauth/callback')
|
@@ -148,56 +355,9 @@ request, add a 'headers' hash under 'params':
|
|
148
355
|
token = client.auth_code.get_token('code_value', :redirect_uri => 'http://localhost:8080/oauth/callback', :headers => {'Some' => 'Header'})
|
149
356
|
```
|
150
357
|
|
151
|
-
You can always use the
|
358
|
+
You can always use the `#request` method on the `OAuth2::Client` instance to make
|
152
359
|
requests for tokens for any Authentication grant type.
|
153
360
|
|
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
361
|
## Versioning
|
202
362
|
|
203
363
|
This library aims to adhere to [Semantic Versioning 2.0.0][semver].
|
@@ -221,21 +381,21 @@ spec.add_dependency 'oauth2', '~> 1.4'
|
|
221
381
|
|
222
382
|
## License
|
223
383
|
|
224
|
-
[![License: MIT]
|
384
|
+
[![License: MIT][🖇src-license-img]][🖇src-license]
|
225
385
|
|
226
386
|
- Copyright (c) 2011-2013 Michael Bleigh and Intridea, Inc.
|
227
|
-
- Copyright (c) 2017-
|
387
|
+
- Copyright (c) 2017-2022 [oauth-xx organization][oauth-xx]
|
228
388
|
- See [LICENSE][license] for details.
|
229
389
|
|
230
390
|
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2.svg?type=large)][fossa2]
|
231
391
|
|
232
|
-
[license]: LICENSE
|
392
|
+
[license]: https://github.com/oauth-xx/oauth2/blob/master/LICENSE
|
233
393
|
[oauth-xx]: https://github.com/oauth-xx
|
234
394
|
[fossa2]: https://app.fossa.io/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2?ref=badge_large
|
235
395
|
|
236
396
|
## Development
|
237
397
|
|
238
|
-
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.
|
398
|
+
After checking out the repo, run `bundle install` to install dependencies. Then, run `bundle excec rake spec` to run the tests.
|
239
399
|
|
240
400
|
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
401
|
|
data/lib/oauth2/client.rb
CHANGED
@@ -59,15 +59,12 @@ module OAuth2
|
|
59
59
|
|
60
60
|
# The Faraday connection object
|
61
61
|
def connection
|
62
|
-
@connection ||=
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
options[:connection_build].call(b)
|
62
|
+
@connection ||=
|
63
|
+
Faraday.new(site, options[:connection_opts]) do |builder|
|
64
|
+
if options[:connection_build]
|
65
|
+
options[:connection_build].call(builder)
|
67
66
|
end
|
68
67
|
end
|
69
|
-
conn
|
70
|
-
end
|
71
68
|
end
|
72
69
|
|
73
70
|
# The authorize endpoint URL of the OAuth2 provider
|
data/lib/oauth2/error.rb
CHANGED
@@ -23,7 +23,7 @@ module OAuth2
|
|
23
23
|
def error_message(response_body, opts = {})
|
24
24
|
message = []
|
25
25
|
|
26
|
-
opts[:error_description] && message << opts[:error_description]
|
26
|
+
opts[:error_description] && (message << opts[:error_description])
|
27
27
|
|
28
28
|
error_message = if opts[:error_description] && opts[:error_description].respond_to?(:encoding)
|
29
29
|
script_encoding = opts[:error_description].encoding
|
data/lib/oauth2/mac_token.rb
CHANGED
@@ -95,24 +95,22 @@ module OAuth2
|
|
95
95
|
#
|
96
96
|
# @param [String] alg the algorithm to use (one of 'hmac-sha-1', 'hmac-sha-256')
|
97
97
|
def algorithm=(alg)
|
98
|
-
@algorithm =
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
end
|
115
|
-
end
|
98
|
+
@algorithm = case alg.to_s
|
99
|
+
when 'hmac-sha-1'
|
100
|
+
begin
|
101
|
+
OpenSSL::Digest('SHA1').new
|
102
|
+
rescue StandardError
|
103
|
+
OpenSSL::Digest.new('SHA1')
|
104
|
+
end
|
105
|
+
when 'hmac-sha-256'
|
106
|
+
begin
|
107
|
+
OpenSSL::Digest('SHA256').new
|
108
|
+
rescue StandardError
|
109
|
+
OpenSSL::Digest.new('SHA256')
|
110
|
+
end
|
111
|
+
else
|
112
|
+
raise(ArgumentError, 'Unsupported algorithm')
|
113
|
+
end
|
116
114
|
end
|
117
115
|
|
118
116
|
private
|
data/lib/oauth2/version.rb
CHANGED
data/spec/helper.rb
CHANGED
@@ -1,25 +1,18 @@
|
|
1
1
|
DEBUG = ENV['DEBUG'] == 'true'
|
2
2
|
|
3
3
|
ruby_version = Gem::Version.new(RUBY_VERSION)
|
4
|
+
minimum_version = ->(version) { ruby_version >= Gem::Version.new(version) && RUBY_ENGINE == 'ruby' }
|
5
|
+
coverage = minimum_version.call('2.7')
|
6
|
+
debug = minimum_version.call('2.5')
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
require 'coveralls'
|
8
|
-
|
9
|
-
SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
|
10
|
-
|
11
|
-
SimpleCov.start do
|
12
|
-
add_filter '/spec'
|
13
|
-
minimum_coverage(95)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
require 'byebug' if DEBUG && ruby_version >= Gem::Version.new('2.4')
|
8
|
+
require 'simplecov' if coverage
|
9
|
+
require 'byebug' if DEBUG && debug
|
18
10
|
|
19
11
|
require 'oauth2'
|
20
12
|
require 'addressable/uri'
|
21
13
|
require 'rspec'
|
22
14
|
require 'rspec/stubbed_env'
|
15
|
+
require 'rspec/pending_for'
|
23
16
|
require 'silent_stream'
|
24
17
|
|
25
18
|
RSpec.configure do |config|
|
data/spec/oauth2/client_spec.rb
CHANGED
@@ -46,7 +46,7 @@ describe OAuth2::Client do
|
|
46
46
|
it 'is able to pass a block to configure the connection' do
|
47
47
|
connection = double('connection')
|
48
48
|
builder = double('builder')
|
49
|
-
allow(
|
49
|
+
allow(Faraday).to receive(:new).and_yield(builder)
|
50
50
|
allow(Faraday::Connection).to receive(:new).and_return(connection)
|
51
51
|
|
52
52
|
expect(builder).to receive(:adapter).with(:test)
|
@@ -403,10 +403,11 @@ describe OAuth2::Client do
|
|
403
403
|
describe ':raise_errors flag' do
|
404
404
|
let(:options) { {} }
|
405
405
|
let(:token_response) { nil }
|
406
|
+
let(:post_args) { [] }
|
406
407
|
|
407
408
|
let(:client) do
|
408
409
|
stubbed_client(options.merge(:raise_errors => raise_errors)) do |stub|
|
409
|
-
stub.post('/oauth/token') do
|
410
|
+
stub.post('/oauth/token', *post_args) do
|
410
411
|
# stub 200 response so that we're testing the get_token handling of :raise_errors flag not request
|
411
412
|
[200, {'Content-Type' => 'application/json'}, token_response]
|
412
413
|
end
|
@@ -430,6 +431,29 @@ describe OAuth2::Client do
|
|
430
431
|
end
|
431
432
|
end
|
432
433
|
|
434
|
+
context 'when the request body has an access token' do
|
435
|
+
let(:token_response) { MultiJson.encode('access_token' => 'the-token') }
|
436
|
+
|
437
|
+
it 'returns the parsed :access_token from body' do
|
438
|
+
token = client.get_token({})
|
439
|
+
expect(token).to be_a OAuth2::AccessToken
|
440
|
+
expect(token.token).to eq('the-token')
|
441
|
+
end
|
442
|
+
|
443
|
+
context 'when :auth_scheme => :request_body' do
|
444
|
+
context 'when arbitrary params are present' do
|
445
|
+
let(:post_args) { ['arbitrary' => 'parameter', 'client_id' => 'abc', 'client_secret' => 'def'] }
|
446
|
+
let(:options) { {:auth_scheme => :request_body} }
|
447
|
+
|
448
|
+
it 'does not affect access token' do
|
449
|
+
token = client.get_token(*post_args)
|
450
|
+
expect(token).to be_a OAuth2::AccessToken
|
451
|
+
expect(token.token).to eq('the-token')
|
452
|
+
end
|
453
|
+
end
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
433
457
|
context 'when extract_access_token raises an exception' do
|
434
458
|
let(:options) do
|
435
459
|
{
|
@@ -493,7 +517,7 @@ describe OAuth2::Client do
|
|
493
517
|
context 'with SSL options' do
|
494
518
|
subject do
|
495
519
|
cli = described_class.new('abc', 'def', :site => 'https://api.example.com', :ssl => {:ca_file => 'foo.pem'})
|
496
|
-
cli.connection.
|
520
|
+
cli.connection = Faraday.new(cli.site, cli.options[:connection_opts]) do |b|
|
497
521
|
b.adapter :test
|
498
522
|
end
|
499
523
|
cli
|
@@ -24,15 +24,18 @@ describe OAuth2::MACToken do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'defaults algorithm to hmac-sha-256' do
|
27
|
+
pending_for(:engine => 'ruby', :versions => '1.9.3', :reason => "Ruby 1.9's OpenSSL uses instance of OpenSSL::Digest")
|
27
28
|
expect(subject.algorithm).to be_instance_of(OpenSSL::Digest::SHA256)
|
28
29
|
end
|
29
30
|
|
30
31
|
it 'handles hmac-sha-256' do
|
32
|
+
pending_for(:engine => 'ruby', :versions => '1.9.3', :reason => "Ruby 1.9's OpenSSL uses instance of OpenSSL::Digest")
|
31
33
|
mac = described_class.new(client, token, 'abc123', :algorithm => 'hmac-sha-256')
|
32
34
|
expect(mac.algorithm).to be_instance_of(OpenSSL::Digest::SHA256)
|
33
35
|
end
|
34
36
|
|
35
37
|
it 'handles hmac-sha-1' do
|
38
|
+
pending_for(:engine => 'ruby', :versions => '1.9.3', :reason => "Ruby 1.9's OpenSSL uses instance of OpenSSL::Digest")
|
36
39
|
mac = described_class.new(client, token, 'abc123', :algorithm => 'hmac-sha-1')
|
37
40
|
expect(mac.algorithm).to be_instance_of(OpenSSL::Digest::SHA1)
|
38
41
|
end
|
@@ -3,7 +3,8 @@ describe OAuth2::Strategy::Assertion do
|
|
3
3
|
|
4
4
|
let(:client) do
|
5
5
|
cli = OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com')
|
6
|
-
cli.connection.
|
6
|
+
cli.connection = Faraday.new(cli.site, cli.options[:connection_opts]) do |b|
|
7
|
+
b.request :url_encoded
|
7
8
|
b.adapter :test do |stub|
|
8
9
|
stub.post('/oauth/token') do |env|
|
9
10
|
case @mode
|
@@ -9,7 +9,7 @@ describe OAuth2::Strategy::ClientCredentials do
|
|
9
9
|
builder.adapter :test do |stub|
|
10
10
|
stub.post('/oauth/token', 'grant_type' => 'client_credentials') do |env|
|
11
11
|
client_id, client_secret = Base64.decode64(env[:request_headers]['Authorization'].split(' ', 2)[1]).split(':', 2)
|
12
|
-
client_id == 'abc' && client_secret == 'def' || raise(Faraday::Adapter::Test::Stubs::NotFound)
|
12
|
+
(client_id == 'abc' && client_secret == 'def') || raise(Faraday::Adapter::Test::Stubs::NotFound)
|
13
13
|
case @mode
|
14
14
|
when 'formencoded'
|
15
15
|
[200, {'Content-Type' => 'application/x-www-form-urlencoded'}, kvform_token]
|
@@ -3,7 +3,8 @@ describe OAuth2::Strategy::Password do
|
|
3
3
|
|
4
4
|
let(:client) do
|
5
5
|
cli = OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com')
|
6
|
-
cli.connection.
|
6
|
+
cli.connection = Faraday.new(cli.site, cli.options[:connection_opts]) do |b|
|
7
|
+
b.request :url_encoded
|
7
8
|
b.adapter :test do |stub|
|
8
9
|
stub.post('/oauth/token') do |env|
|
9
10
|
case @mode
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Boling
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-02-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0.8'
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '
|
24
|
+
version: '3.0'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
version: '0.8'
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '3.0'
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: jwt
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,20 +142,6 @@ dependencies:
|
|
142
142
|
- - ">="
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '1.16'
|
145
|
-
- !ruby/object:Gem::Dependency
|
146
|
-
name: coveralls
|
147
|
-
requirement: !ruby/object:Gem::Requirement
|
148
|
-
requirements:
|
149
|
-
- - "~>"
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version: '0.8'
|
152
|
-
type: :development
|
153
|
-
prerelease: false
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
requirements:
|
156
|
-
- - "~>"
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: '0.8'
|
159
145
|
- !ruby/object:Gem::Dependency
|
160
146
|
name: rake
|
161
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -318,10 +304,11 @@ licenses:
|
|
318
304
|
- MIT
|
319
305
|
metadata:
|
320
306
|
bug_tracker_uri: https://github.com/oauth-xx/oauth2/issues
|
321
|
-
changelog_uri: https://github.com/oauth-xx/oauth2/blob/v1.4.
|
322
|
-
documentation_uri: https://www.rubydoc.info/gems/oauth2/1.4.
|
323
|
-
source_code_uri: https://github.com/oauth-xx/oauth2/tree/v1.4.
|
307
|
+
changelog_uri: https://github.com/oauth-xx/oauth2/blob/v1.4.8/CHANGELOG.md
|
308
|
+
documentation_uri: https://www.rubydoc.info/gems/oauth2/1.4.8
|
309
|
+
source_code_uri: https://github.com/oauth-xx/oauth2/tree/v1.4.8
|
324
310
|
wiki_uri: https://github.com/oauth-xx/oauth2/wiki
|
311
|
+
rubygems_mfa_required: 'true'
|
325
312
|
post_install_message:
|
326
313
|
rdoc_options: []
|
327
314
|
require_paths:
|
@@ -337,21 +324,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
337
324
|
- !ruby/object:Gem::Version
|
338
325
|
version: 1.3.5
|
339
326
|
requirements: []
|
340
|
-
rubygems_version: 3.
|
327
|
+
rubygems_version: 3.3.7
|
341
328
|
signing_key:
|
342
329
|
specification_version: 4
|
343
330
|
summary: A Ruby wrapper for the OAuth 2.0 protocol.
|
344
331
|
test_files:
|
345
332
|
- spec/helper.rb
|
346
|
-
- spec/oauth2/
|
347
|
-
- spec/oauth2/version_spec.rb
|
333
|
+
- spec/oauth2/access_token_spec.rb
|
348
334
|
- spec/oauth2/authenticator_spec.rb
|
335
|
+
- spec/oauth2/client_spec.rb
|
349
336
|
- spec/oauth2/mac_token_spec.rb
|
350
|
-
- spec/oauth2/access_token_spec.rb
|
351
337
|
- spec/oauth2/response_spec.rb
|
352
|
-
- spec/oauth2/strategy/password_spec.rb
|
353
|
-
- spec/oauth2/strategy/client_credentials_spec.rb
|
354
338
|
- spec/oauth2/strategy/assertion_spec.rb
|
355
|
-
- spec/oauth2/strategy/implicit_spec.rb
|
356
339
|
- spec/oauth2/strategy/auth_code_spec.rb
|
357
340
|
- spec/oauth2/strategy/base_spec.rb
|
341
|
+
- spec/oauth2/strategy/client_credentials_spec.rb
|
342
|
+
- spec/oauth2/strategy/implicit_spec.rb
|
343
|
+
- spec/oauth2/strategy/password_spec.rb
|
344
|
+
- spec/oauth2/version_spec.rb
|