oauth2 1.4.7 → 2.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +811 -76
- data/CITATION.cff +20 -0
- data/CODE_OF_CONDUCT.md +24 -23
- data/CONTRIBUTING.md +221 -0
- data/FUNDING.md +74 -0
- data/IRP.md +107 -0
- data/{LICENSE → LICENSE.txt} +2 -2
- data/OIDC.md +167 -0
- data/README.md +1468 -166
- data/REEK +2 -0
- data/RUBOCOP.md +71 -0
- data/SECURITY.md +24 -0
- data/THREAT_MODEL.md +94 -0
- data/lib/oauth2/access_token.rb +276 -40
- data/lib/oauth2/auth_sanitizer.rb +36 -0
- data/lib/oauth2/authenticator.rb +51 -10
- data/lib/oauth2/client.rb +444 -124
- data/lib/oauth2/error.rb +63 -24
- data/lib/oauth2/filtered_attributes.rb +10 -0
- data/lib/oauth2/response.rb +138 -43
- data/lib/oauth2/strategy/assertion.rb +71 -41
- data/lib/oauth2/strategy/auth_code.rb +28 -5
- data/lib/oauth2/strategy/base.rb +2 -0
- data/lib/oauth2/strategy/client_credentials.rb +6 -4
- data/lib/oauth2/strategy/implicit.rb +20 -3
- data/lib/oauth2/strategy/password.rb +17 -5
- data/lib/oauth2/version.rb +2 -59
- data/lib/oauth2.rb +103 -12
- data/sig/oauth2/access_token.rbs +25 -0
- data/sig/oauth2/authenticator.rbs +22 -0
- data/sig/oauth2/client.rbs +52 -0
- data/sig/oauth2/error.rbs +8 -0
- data/sig/oauth2/filtered_attributes.rbs +11 -0
- data/sig/oauth2/response.rbs +18 -0
- data/sig/oauth2/sanitized_logger.rbs +32 -0
- data/sig/oauth2/strategy.rbs +34 -0
- data/sig/oauth2/thing_filter.rbs +10 -0
- data/sig/oauth2/version.rbs +5 -0
- data/sig/oauth2.rbs +9 -0
- data.tar.gz.sig +0 -0
- metadata +293 -102
- metadata.gz.sig +4 -0
- data/lib/oauth2/mac_token.rb +0 -130
- data/spec/helper.rb +0 -37
- data/spec/oauth2/access_token_spec.rb +0 -216
- data/spec/oauth2/authenticator_spec.rb +0 -84
- data/spec/oauth2/client_spec.rb +0 -506
- data/spec/oauth2/mac_token_spec.rb +0 -117
- data/spec/oauth2/response_spec.rb +0 -90
- data/spec/oauth2/strategy/assertion_spec.rb +0 -58
- data/spec/oauth2/strategy/auth_code_spec.rb +0 -107
- data/spec/oauth2/strategy/base_spec.rb +0 -5
- data/spec/oauth2/strategy/client_credentials_spec.rb +0 -69
- data/spec/oauth2/strategy/implicit_spec.rb +0 -26
- data/spec/oauth2/strategy/password_spec.rb +0 -55
- data/spec/oauth2/version_spec.rb +0 -23
data/README.md
CHANGED
|
@@ -1,248 +1,1550 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
If you need the readme for a released version of the gem please find it below:
|
|
4
|
-
|
|
5
|
-
| Version | Release Date | Readme |
|
|
6
|
-
|----------|--------------|----------------------------------------------------------|
|
|
7
|
-
| 1.4.7 | Mar 18, 2021 | https://github.com/oauth-xx/oauth2/blob/v1.4.7/README.md |
|
|
8
|
-
| 1.4.6 | Mar 18, 2021 | https://github.com/oauth-xx/oauth2/blob/v1.4.6/README.md |
|
|
9
|
-
| 1.4.5 | Mar 18, 2021 | https://github.com/oauth-xx/oauth2/blob/v1.4.5/README.md |
|
|
10
|
-
| 1.4.4 | Feb 12, 2020 | https://github.com/oauth-xx/oauth2/blob/v1.4.4/README.md |
|
|
11
|
-
| 1.4.3 | Jan 29, 2020 | https://github.com/oauth-xx/oauth2/blob/v1.4.3/README.md |
|
|
12
|
-
| 1.4.2 | Oct 1, 2019 | https://github.com/oauth-xx/oauth2/blob/v1.4.2/README.md |
|
|
13
|
-
| 1.4.1 | Oct 13, 2018 | https://github.com/oauth-xx/oauth2/blob/v1.4.1/README.md |
|
|
14
|
-
| 1.4.0 | Jun 9, 2017 | https://github.com/oauth-xx/oauth2/blob/v1.4.0/README.md |
|
|
15
|
-
| 1.3.1 | Mar 3, 2017 | https://github.com/oauth-xx/oauth2/blob/v1.3.1/README.md |
|
|
16
|
-
| 1.3.0 | Dec 27, 2016 | https://github.com/oauth-xx/oauth2/blob/v1.3.0/README.md |
|
|
17
|
-
| 1.2.0 | Jun 30, 2016 | https://github.com/oauth-xx/oauth2/blob/v1.2.0/README.md |
|
|
18
|
-
| 1.1.0 | Jan 30, 2016 | https://github.com/oauth-xx/oauth2/blob/v1.1.0/README.md |
|
|
19
|
-
| 1.0.0 | May 23, 2014 | https://github.com/oauth-xx/oauth2/blob/v1.0.0/README.md |
|
|
20
|
-
| < 1.0.0 | Find here | https://github.com/oauth-xx/oauth2/tags |
|
|
21
|
-
|
|
22
|
-
[][gem]
|
|
23
|
-
[][gem]
|
|
24
|
-
[][gem]
|
|
25
|
-
[][travis]
|
|
26
|
-
[][github-actions]
|
|
27
|
-
[][codeclimate-coverage]
|
|
28
|
-
[][codeclimate-maintainability]
|
|
29
|
-
[][depfu]
|
|
30
|
-
[][code-triage]
|
|
31
|
-
[](https://gitter.im/oauth-xx/oauth2)
|
|
32
|
-
[][source-license]
|
|
33
|
-
[][inch-ci]
|
|
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].
|
|
1
|
+
[![Galtzo FLOSS Logo by Aboling0, CC BY-SA 4.0][🖼️galtzo-i]][🖼️galtzo-discord] [![ruby-lang Logo, Yukihiro Matsumoto, Ruby Visual Identity Team, CC BY-SA 2.5][🖼️ruby-lang-i]][🖼️ruby-lang] [![oauth2 Logo by Chris Messina, CC BY-SA 3.0][🖼️oauth2-i]][🖼️oauth2]
|
|
48
2
|
|
|
49
|
-
[
|
|
3
|
+
[🖼️galtzo-i]: https://logos.galtzo.com/assets/images/galtzo-floss/avatar-192px.svg
|
|
4
|
+
[🖼️galtzo-discord]: https://discord.gg/3qme4XHNKN
|
|
5
|
+
[🖼️ruby-lang-i]: https://logos.galtzo.com/assets/images/ruby-lang/avatar-192px.svg
|
|
6
|
+
[🖼️ruby-lang]: https://www.ruby-lang.org/
|
|
7
|
+
[🖼️oauth2-i]: https://logos.galtzo.com/assets/images/oauth/oauth2/avatar-192px.svg
|
|
8
|
+
[🖼️oauth2]: https://github.com/ruby-oauth/oauth2
|
|
9
|
+
|
|
10
|
+
# 🔐 OAuth 2.0 Authorization Framework
|
|
11
|
+
|
|
12
|
+
[![Version][👽versioni]][👽version] [![GitHub tag (latest SemVer)][⛳️tag-img]][⛳️tag] [![License: MIT][📄license-img]][📄license-ref] [![Downloads Rank][👽dl-ranki]][👽dl-rank] [![CodeCov Test Coverage][🏀codecovi]][🏀codecov] [![Coveralls Test Coverage][🏀coveralls-img]][🏀coveralls] [![QLTY Test Coverage][🏀qlty-covi]][🏀qlty-cov] [![QLTY Maintainability][🏀qlty-mnti]][🏀qlty-mnt] [![CI Heads][🚎3-hd-wfi]][🚎3-hd-wf] [![CI Runtime Dependencies @ HEAD][🚎12-crh-wfi]][🚎12-crh-wf] [![CI Current][🚎11-c-wfi]][🚎11-c-wf] [![CI JRuby][🚎10-j-wfi]][🚎10-j-wf] [![Deps Locked][🚎13-🔒️-wfi]][🚎13-🔒️-wf] [![Deps Unlocked][🚎14-🔓️-wfi]][🚎14-🔓️-wf] [![CI Supported][🚎6-s-wfi]][🚎6-s-wf] [![CI Legacy][🚎4-lg-wfi]][🚎4-lg-wf] [![CI Unsupported][🚎7-us-wfi]][🚎7-us-wf] [![CI Ancient][🚎1-an-wfi]][🚎1-an-wf] [![CI Test Coverage][🚎2-cov-wfi]][🚎2-cov-wf] [![CI Style][🚎5-st-wfi]][🚎5-st-wf] [![CodeQL][🖐codeQL-img]][🖐codeQL] [![Apache SkyWalking Eyes License Compatibility Check][🚎15-🪪-wfi]][🚎15-🪪-wf]
|
|
13
|
+
|
|
14
|
+
`if ci_badges.map(&:color).detect { it != "green"}` ☝️ [let me know][🖼️galtzo-discord], as I may have missed the [discord notification][🖼️galtzo-discord].
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
`if ci_badges.map(&:color).all? { it == "green"}` 👇️ send money so I can do more of this. FLOSS maintenance is now my full-time job.
|
|
19
|
+
|
|
20
|
+
[![OpenCollective Backers][🖇osc-backers-i]][🖇osc-backers] [![OpenCollective Sponsors][🖇osc-sponsors-i]][🖇osc-sponsors] [![Sponsor Me on Github][🖇sponsor-img]][🖇sponsor] [![Liberapay Goal Progress][⛳liberapay-img]][⛳liberapay] [![Donate on PayPal][🖇paypal-img]][🖇paypal] [![Buy me a coffee][🖇buyme-small-img]][🖇buyme] [![Donate on Polar][🖇polar-img]][🖇polar] [![Donate at ko-fi.com][🖇kofi-img]][🖇kofi]
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>👣 How will this project approach the September 2025 hostile takeover of RubyGems? 🚑️</summary>
|
|
24
|
+
|
|
25
|
+
I've summarized my thoughts in [this blog post](https://dev.to/galtzo/hostile-takeover-of-rubygems-my-thoughts-5hlo).
|
|
26
|
+
|
|
27
|
+
</details>
|
|
50
28
|
|
|
51
|
-
##
|
|
29
|
+
## 🌻 Synopsis
|
|
52
30
|
|
|
53
|
-
|
|
31
|
+
OAuth 2.0 is the industry-standard protocol for authorization.
|
|
32
|
+
This is a RubyGem for implementing OAuth 2.0 clients (not servers) in Ruby applications.
|
|
33
|
+
|
|
34
|
+
⭐️ including OAuth 2.1 draft spec & OpenID Connect (OIDC)
|
|
35
|
+
|
|
36
|
+
### Quick Examples
|
|
37
|
+
|
|
38
|
+
<details markdown="1">
|
|
39
|
+
<summary>Convert the following `curl` command into a token request using this gem...</summary>
|
|
40
|
+
|
|
41
|
+
```shell
|
|
42
|
+
curl --request POST \
|
|
43
|
+
--url 'https://login.microsoftonline.com/REDMOND_REDACTED/oauth2/token' \
|
|
44
|
+
--header 'content-type: application/x-www-form-urlencoded' \
|
|
45
|
+
--data grant_type=client_credentials \
|
|
46
|
+
--data client_id=REDMOND_CLIENT_ID \
|
|
47
|
+
--data client_secret=REDMOND_CLIENT_SECRET \
|
|
48
|
+
--data resource=REDMOND_RESOURCE_UUID
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
NOTE: In the ruby version below, certain params are passed to the `get_token` call, instead of the client creation.
|
|
54
52
|
|
|
55
53
|
```ruby
|
|
56
|
-
|
|
54
|
+
client = OAuth2::Client.new(
|
|
55
|
+
"REDMOND_CLIENT_ID", # client_id
|
|
56
|
+
"REDMOND_CLIENT_SECRET", # client_secret
|
|
57
|
+
auth_scheme: :request_body, # Other modes are supported: :basic_auth, :tls_client_auth, :private_key_jwt
|
|
58
|
+
token_url: "oauth2/token", # relative path, except with leading `/`, then absolute path
|
|
59
|
+
site: "https://login.microsoftonline.com/REDMOND_REDACTED",
|
|
60
|
+
)
|
|
61
|
+
client.
|
|
62
|
+
client_credentials. # There are many other types to choose from!
|
|
63
|
+
get_token(resource: "REDMOND_RESOURCE_UUID")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
NOTE: `header` - The content type specified in the `curl` is already the default!
|
|
67
|
+
|
|
68
|
+
</details>
|
|
69
|
+
|
|
70
|
+
<details markdown="1">
|
|
71
|
+
<summary>Complete E2E single file script against mock-oauth2-server</summary>
|
|
72
|
+
|
|
73
|
+
- E2E example uses [navikt/mock-oauth2-server](https://github.com/navikt/mock-oauth2-server), which was added in v2.0.11
|
|
74
|
+
- E2E example does not ship with the released gem, so clone the source to play with it.
|
|
75
|
+
|
|
76
|
+
```console
|
|
77
|
+
docker compose -f docker-compose-ssl.yml up -d --wait
|
|
78
|
+
ruby examples/e2e.rb
|
|
79
|
+
# If your machine is slow or Docker pulls are cold, increase the wait:
|
|
80
|
+
E2E_WAIT_TIMEOUT=120 ruby examples/e2e.rb
|
|
81
|
+
# The mock server serves HTTP on 8080; the example points to http://localhost:8080 by default.
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The output should be something like this:
|
|
85
|
+
|
|
86
|
+
```console
|
|
87
|
+
➜ ruby examples/e2e.rb
|
|
88
|
+
Access token (truncated): eyJraWQiOiJkZWZhdWx0...
|
|
89
|
+
userinfo status: 200
|
|
90
|
+
userinfo body: {"sub" => "demo-sub", "aud" => ["demo-aud"], "nbf" => 1757816758000, "iss" => "http://localhost:8080/default", "exp" => 1757820358000, "iat" => 1757816758000, "jti" => "d63b97a7-ebe5-4dea-93e6-d542caba6104"}
|
|
91
|
+
E2E complete
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Make sure to shut down the mock server when you are done:
|
|
95
|
+
|
|
96
|
+
```console
|
|
97
|
+
docker compose -f docker-compose-ssl.yml down
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Troubleshooting: validate connectivity to the mock server
|
|
101
|
+
|
|
102
|
+
- Check container status and port mapping:
|
|
103
|
+
- `docker compose -f docker-compose-ssl.yml ps`
|
|
104
|
+
- From the host, try the discovery URL directly (this is what the example uses by default):
|
|
105
|
+
- `curl -v http://localhost:8080/default/.well-known/openid-configuration`
|
|
106
|
+
- If that fails immediately, also try: `curl -v --connect-timeout 2 http://127.0.0.1:8080/default/.well-known/openid-configuration`
|
|
107
|
+
- From inside the container (to distinguish container vs. host networking):
|
|
108
|
+
- `docker exec -it oauth2-mock-oauth2-server-1 curl -v http://127.0.0.1:8080/default/.well-known/openid-configuration`
|
|
109
|
+
- Simple TCP probe from the host:
|
|
110
|
+
- `nc -vz localhost 8080 # or: ruby -rsocket -e 'TCPSocket.new("localhost",8080).close; puts "tcp ok"'`
|
|
111
|
+
- Inspect which host port 8080 is bound to (should be 8080):
|
|
112
|
+
- `docker inspect -f '{{ (index (index .NetworkSettings.Ports "8080/tcp") 0).HostPort }}' oauth2-mock-oauth2-server-1`
|
|
113
|
+
- Look at server logs for readiness/errors:
|
|
114
|
+
- `docker logs -n 200 oauth2-mock-oauth2-server-1`
|
|
115
|
+
- On Linux, ensure nothing else is bound to 8080 and that firewall/SELinux aren’t blocking:
|
|
116
|
+
- `ss -ltnp | grep :8080`
|
|
117
|
+
|
|
118
|
+
Notes
|
|
119
|
+
|
|
120
|
+
- Discovery URL pattern is: `http://localhost:8080/<realm>/.well-known/openid-configuration`, where `<realm>` defaults to `default`.
|
|
121
|
+
- You can change these with env vars when running the example:
|
|
122
|
+
- `E2E_ISSUER_BASE` (default: http://localhost:8080)
|
|
123
|
+
- `E2E_REALM` (default: default)
|
|
124
|
+
|
|
125
|
+
</details>
|
|
126
|
+
|
|
127
|
+
If it seems like you are in the wrong place, you might try one of these:
|
|
128
|
+
|
|
129
|
+
* [OAuth 2.0 Spec][oauth2-spec]
|
|
130
|
+
* [doorkeeper gem][doorkeeper-gem] for OAuth 2.0 server/provider implementation.
|
|
131
|
+
* [oauth sibling gem][sibling-gem] for OAuth 1.0a implementations in Ruby.
|
|
132
|
+
|
|
133
|
+
[oauth2-spec]: https://oauth.net/2/
|
|
134
|
+
[sibling-gem]: https://gitlab.com/ruby-oauth/oauth
|
|
135
|
+
[doorkeeper-gem]: https://github.com/doorkeeper-gem/doorkeeper
|
|
136
|
+
|
|
137
|
+
## 💡 Info you can shake a stick at
|
|
138
|
+
|
|
139
|
+
| Tokens to Remember | [![Gem name][⛳️name-img]][⛳️gem-name] [![Gem namespace][⛳️namespace-img]][⛳️gem-namespace] |
|
|
140
|
+
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
141
|
+
| Works with JRuby | ![JRuby 9.1 Compat][💎jruby-9.1i] ![JRuby 9.2 Compat][💎jruby-9.2i] ![JRuby 9.3 Compat][💎jruby-9.3i] <br/> [![JRuby 9.4 Compat][💎jruby-9.4i]][🚎10-j-wf] [![JRuby 10.0 Compat][💎jruby-c-i]][🚎11-c-wf] [![JRuby HEAD Compat][💎jruby-headi]][🚎3-hd-wf] |
|
|
142
|
+
| Works with Truffle Ruby | ![Truffle Ruby 22.3 Compat][💎truby-22.3i] ![Truffle Ruby 23.0 Compat][💎truby-23.0i] ![Truffle Ruby 23.1 Compat][💎truby-23.1i] <br/> [![Truffle Ruby 24.1 Compat][💎truby-c-i]][🚎11-c-wf] |
|
|
143
|
+
| Works with MRI Ruby 3 | [![Ruby 3.0 Compat][💎ruby-3.0i]][🚎4-lg-wf] [![Ruby 3.1 Compat][💎ruby-3.1i]][🚎6-s-wf] [![Ruby 3.2 Compat][💎ruby-3.2i]][🚎6-s-wf] [![Ruby 3.3 Compat][💎ruby-3.3i]][🚎6-s-wf] [![Ruby 3.4 Compat][💎ruby-c-i]][🚎11-c-wf] [![Ruby HEAD Compat][💎ruby-headi]][🚎3-hd-wf] |
|
|
144
|
+
| Works with MRI Ruby 2 | ![Ruby 2.2 Compat][💎ruby-2.2i] <br/> [![Ruby 2.3 Compat][💎ruby-2.3i]][🚎1-an-wf] [![Ruby 2.4 Compat][💎ruby-2.4i]][🚎1-an-wf] [![Ruby 2.5 Compat][💎ruby-2.5i]][🚎1-an-wf] [![Ruby 2.6 Compat][💎ruby-2.6i]][🚎7-us-wf] [![Ruby 2.7 Compat][💎ruby-2.7i]][🚎7-us-wf] |
|
|
145
|
+
| Support & Community | [![Join Me on Daily.dev's RubyFriends][✉️ruby-friends-img]][✉️ruby-friends] [![Live Chat on Discord][✉️discord-invite-img-ftb]][✉️discord-invite] [![Get help from me on Upwork][👨🏼🏫expsup-upwork-img]][👨🏼🏫expsup-upwork] [![Get help from me on Codementor][👨🏼🏫expsup-codementor-img]][👨🏼🏫expsup-codementor] |
|
|
146
|
+
| Source | [![Source on GitLab.com][📜src-gl-img]][📜src-gl] [![Source on CodeBerg.org][📜src-cb-img]][📜src-cb] [![Source on Github.com][📜src-gh-img]][📜src-gh] [![The best SHA: dQw4w9WgXcQ!][🧮kloc-img]][🧮kloc] |
|
|
147
|
+
| Documentation | [![Current release on RubyDoc.info][📜docs-cr-rd-img]][🚎yard-current] [![YARD on Galtzo.com][📜docs-head-rd-img]][🚎yard-head] [![Maintainer Blog][🚂maint-blog-img]][🚂maint-blog] [![GitLab Wiki][📜gl-wiki-img]][📜gl-wiki] [![GitHub Wiki][📜gh-wiki-img]][📜gh-wiki] |
|
|
148
|
+
| Compliance | [![License: MIT][📄license-img]][📄license-ref] [![Compatible with Apache Software Projects: Verified by SkyWalking Eyes][📄license-compat-img]][📄license-compat] [![📄ilo-declaration-img]][📄ilo-declaration] [![Security Policy][🔐security-img]][🔐security] [![Contributor Covenant 2.1][🪇conduct-img]][🪇conduct] [![SemVer 2.0.0][📌semver-img]][📌semver] |
|
|
149
|
+
| Style | [![Enforced Code Style Linter][💎rlts-img]][💎rlts] [![Keep-A-Changelog 1.0.0][📗keep-changelog-img]][📗keep-changelog] [![Gitmoji Commits][📌gitmoji-img]][📌gitmoji] [![Compatibility appraised by: appraisal2][💎appraisal2-img]][💎appraisal2] |
|
|
150
|
+
| Maintainer 🎖️ | [![Follow Me on LinkedIn][💖🖇linkedin-img]][💖🖇linkedin] [![Follow Me on Ruby.Social][💖🐘ruby-mast-img]][💖🐘ruby-mast] [![Follow Me on Bluesky][💖🦋bluesky-img]][💖🦋bluesky] [![Contact Maintainer][🚂maint-contact-img]][🚂maint-contact] [![My technical writing][💖💁🏼♂️devto-img]][💖💁🏼♂️devto] |
|
|
151
|
+
| `...` 💖 | [![Find Me on WellFound:][💖✌️wellfound-img]][💖✌️wellfound] [![Find Me on CrunchBase][💖💲crunchbase-img]][💖💲crunchbase] [![My LinkTree][💖🌳linktree-img]][💖🌳linktree] [![More About Me][💖💁🏼♂️aboutme-img]][💖💁🏼♂️aboutme] [🧊][💖🧊berg] [🐙][💖🐙hub] [🛖][💖🛖hut] [🧪][💖🧪lab] |
|
|
152
|
+
|
|
153
|
+
### Compatibility
|
|
154
|
+
|
|
155
|
+
Compatible with MRI Ruby 2.2.0+, and concordant releases of JRuby, and TruffleRuby.
|
|
156
|
+
|
|
157
|
+
| 🚚 _Amazing_ test matrix was brought to you by | 🔎 appraisal2 🔎 and the color 💚 green 💚 |
|
|
158
|
+
|------------------------------------------------|--------------------------------------------------------|
|
|
159
|
+
| 👟 Check it out! | ✨ [github.com/appraisal-rb/appraisal2][💎appraisal2] ✨ |
|
|
160
|
+
|
|
161
|
+
### Federated DVCS
|
|
162
|
+
|
|
163
|
+
<details markdown="1">
|
|
164
|
+
<summary>Find this repo on federated forges (Coming soon!)</summary>
|
|
165
|
+
|
|
166
|
+
| Federated [DVCS][💎d-in-dvcs] Repository | Status | Issues | PRs | Wiki | CI | Discussions |
|
|
167
|
+
|-------------------------------------------------|-----------------------------------------------------------------------|---------------------------|--------------------------|---------------------------|--------------------------|------------------------------|
|
|
168
|
+
| 🧪 [ruby-oauth/oauth2 on GitLab][📜src-gl] | The Truth | [💚][🤝gl-issues] | [💚][🤝gl-pulls] | [💚][📜gl-wiki] | 🐭 Tiny Matrix | ➖ |
|
|
169
|
+
| 🧊 [ruby-oauth/oauth2 on CodeBerg][📜src-cb] | An Ethical Mirror ([Donate][🤝cb-donate]) | [💚][🤝cb-issues] | [💚][🤝cb-pulls] | ➖ | ⭕️ No Matrix | ➖ |
|
|
170
|
+
| 🐙 [ruby-oauth/oauth2 on GitHub][📜src-gh] | Another Mirror | [💚][🤝gh-issues] | [💚][🤝gh-pulls] | [💚][📜gh-wiki] | 💯 Full Matrix | [💚][gh-discussions] |
|
|
171
|
+
| 🎮️ [Discord Server][✉️discord-invite] | [![Live Chat on Discord][✉️discord-invite-img-ftb]][✉️discord-invite] | [Let's][✉️discord-invite] | [talk][✉️discord-invite] | [about][✉️discord-invite] | [this][✉️discord-invite] | [library!][✉️discord-invite] |
|
|
172
|
+
|
|
173
|
+
</details>
|
|
174
|
+
|
|
175
|
+
[gh-discussions]: https://github.com/ruby-oauth/oauth2/discussions
|
|
176
|
+
|
|
177
|
+
### Enterprise Support [](https://tidelift.com/subscription/pkg/rubygems-oauth2?utm_source=rubygems-oauth2&utm_medium=referral&utm_campaign=readme)
|
|
178
|
+
|
|
179
|
+
Available as part of the Tidelift Subscription.
|
|
180
|
+
|
|
181
|
+
<details markdown="1">
|
|
182
|
+
<summary>Need enterprise-level guarantees?</summary>
|
|
183
|
+
|
|
184
|
+
The maintainers of this 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.
|
|
185
|
+
|
|
186
|
+
[![Get help from me on Tidelift][🏙️entsup-tidelift-img]][🏙️entsup-tidelift]
|
|
187
|
+
|
|
188
|
+
- 💡Subscribe for support guarantees covering _all_ your FLOSS dependencies
|
|
189
|
+
- 💡Tidelift is part of [Sonar][🏙️entsup-tidelift-sonar]
|
|
190
|
+
- 💡Tidelift pays maintainers to maintain the software you depend on!<br/>📊`@`Pointy Haired Boss: An [enterprise support][🏙️entsup-tidelift] subscription is "[never gonna let you down][🧮kloc]", and *supports* open source maintainers
|
|
191
|
+
|
|
192
|
+
Alternatively:
|
|
193
|
+
|
|
194
|
+
- [![Live Chat on Discord][✉️discord-invite-img-ftb]][✉️discord-invite]
|
|
195
|
+
- [![Get help from me on Upwork][👨🏼🏫expsup-upwork-img]][👨🏼🏫expsup-upwork]
|
|
196
|
+
- [![Get help from me on Codementor][👨🏼🏫expsup-codementor-img]][👨🏼🏫expsup-codementor]
|
|
197
|
+
|
|
198
|
+
</details>
|
|
199
|
+
|
|
200
|
+
## ✨ Installation
|
|
201
|
+
|
|
202
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
203
|
+
|
|
204
|
+
```console
|
|
205
|
+
bundle add oauth2
|
|
57
206
|
```
|
|
58
207
|
|
|
59
|
-
|
|
208
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
209
|
+
|
|
210
|
+
```console
|
|
211
|
+
gem install oauth2
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### 🔒 Secure Installation
|
|
215
|
+
|
|
216
|
+
<details markdown="1">
|
|
217
|
+
<summary>For Medium or High Security Installations</summary>
|
|
218
|
+
|
|
219
|
+
This gem is cryptographically signed, and has verifiable [SHA-256 and SHA-512][💎SHA_checksums] checksums by
|
|
220
|
+
[stone_checksums][💎stone_checksums]. Be sure the gem you install hasn’t been tampered with
|
|
221
|
+
by following the instructions below.
|
|
222
|
+
|
|
223
|
+
Add my public key (if you haven’t already, expires 2045-04-29) as a trusted certificate:
|
|
224
|
+
|
|
225
|
+
```console
|
|
226
|
+
gem cert --add <(curl -Ls https://raw.github.com/galtzo-floss/certs/main/pboling.pem)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
You only need to do that once. Then proceed to install with:
|
|
230
|
+
|
|
231
|
+
```console
|
|
232
|
+
gem install oauth2 -P MediumSecurity
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
The `MediumSecurity` trust profile will verify signed gems, but allow the installation of unsigned dependencies.
|
|
236
|
+
|
|
237
|
+
This is necessary because not all of `oauth2`’s dependencies are signed, so we cannot use `HighSecurity`.
|
|
238
|
+
|
|
239
|
+
If you want to up your security game full-time:
|
|
240
|
+
|
|
241
|
+
```console
|
|
242
|
+
bundle config set --global trust-policy MediumSecurity
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
`MediumSecurity` instead of `HighSecurity` is necessary if not all the gems you use are signed.
|
|
246
|
+
|
|
247
|
+
NOTE: Be prepared to track down certs for signed gems and add them the same way you added mine.
|
|
248
|
+
|
|
249
|
+
</details>
|
|
250
|
+
|
|
251
|
+
## What is new for v2.0?
|
|
252
|
+
|
|
253
|
+
- Works with Ruby versions >= 2.2
|
|
254
|
+
- Drop support for the expired MAC Draft (all versions)
|
|
255
|
+
- Support IETF rfc7515 JSON Web Signature - JWS (since v2.0.12)
|
|
256
|
+
- Support JWT `kid` for key discovery and management
|
|
257
|
+
- Support IETF rfc7523 JWT Bearer Tokens (since v2.0.0)
|
|
258
|
+
- Support IETF rfc7231 Relative Location in Redirect (since v2.0.0)
|
|
259
|
+
- Support IETF rfc6749 Don't set oauth params when nil (since v2.0.0)
|
|
260
|
+
- Support IETF rfc7009 Token Revocation (since v2.0.10, updated in v2.0.13 to support revocation via URL-encoded parameters)
|
|
261
|
+
- 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)
|
|
262
|
+
- 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`
|
|
263
|
+
- Adds option to `OAuth2::Client#get_token`:
|
|
264
|
+
- `:access_token_class` (`AccessToken`); user specified class to use for all calls to `get_token`
|
|
265
|
+
- Adds option to `OAuth2::AccessToken#initialize`:
|
|
266
|
+
- `:expires_latency` (`nil`); number of seconds by which AccessToken validity will be reduced to offset latency
|
|
267
|
+
- By default, keys are transformed to snake case.
|
|
268
|
+
- Original keys will still work as previously, in most scenarios, thanks to [snaky_hash][snaky_hash] gem.
|
|
269
|
+
- However, this is a _breaking_ change if you rely on `response.parsed.to_h` to retain the original case, and the original wasn't snake case, as the keys in the result will be snake case.
|
|
270
|
+
- As of version 2.0.4 you can turn key transformation off with the `snaky: false` option.
|
|
271
|
+
- By default, the `:auth_scheme` is now `:basic_auth` (instead of `:request_body`)
|
|
272
|
+
- Third-party strategies and gems may need to be updated if a provider was requiring client id/secret in the request body
|
|
273
|
+
- [... A lot more](https://gitlab.com/ruby-oauth/oauth2/-/blob/main/CHANGELOG.md#200-2022-06-21-tag)
|
|
60
274
|
|
|
61
|
-
|
|
275
|
+
[snaky_hash]: https://gitlab.com/ruby-oauth/snaky_hash
|
|
62
276
|
|
|
63
|
-
|
|
277
|
+
## Compatibility
|
|
64
278
|
|
|
65
|
-
|
|
279
|
+
Targeted ruby compatibility is non-EOL versions of Ruby, currently 3.2, 3.3, and 3.4.
|
|
280
|
+
Compatibility is further distinguished as "Best Effort Support" or "Incidental Support" for older versions of Ruby.
|
|
281
|
+
This gem will install on Ruby versions >= v2.2 for 2.x releases.
|
|
282
|
+
See `1-4-stable` branch for older rubies.
|
|
66
283
|
|
|
67
|
-
|
|
284
|
+
<details markdown="1">
|
|
285
|
+
<summary>Ruby Engine Compatibility Policy</summary>
|
|
68
286
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
287
|
+
This gem is tested against MRI, JRuby, and Truffleruby.
|
|
288
|
+
Each of those has varying versions that target a specific version of MRI Ruby.
|
|
289
|
+
This gem should work in the just-listed Ruby engines according to the targeted MRI compatibility in the table below.
|
|
290
|
+
If you would like to add support for additional engines,
|
|
291
|
+
see [gemfiles/README.md](gemfiles/README.md), then submit a PR to the correct maintenance branch as according to the table below.
|
|
72
292
|
|
|
73
|
-
|
|
74
|
-
[issues]: https://github.com/oauth-xx/oauth2/issues
|
|
75
|
-
[wiki]: https://wiki.github.com/oauth-xx/oauth2
|
|
293
|
+
</details>
|
|
76
294
|
|
|
77
|
-
|
|
295
|
+
<details markdown="1">
|
|
296
|
+
<summary>Ruby Version Compatibility Policy</summary>
|
|
297
|
+
|
|
298
|
+
If something doesn't work on one of these interpreters, it's a bug.
|
|
299
|
+
|
|
300
|
+
This library may inadvertently work (or seem to work) on other Ruby
|
|
301
|
+
implementations; however, support will only be provided for the versions listed
|
|
302
|
+
above.
|
|
303
|
+
|
|
304
|
+
If you would like this library to support another Ruby version, you may
|
|
305
|
+
volunteer to be a maintainer. Being a maintainer entails making sure all tests
|
|
306
|
+
run and pass on that implementation. When something breaks on your
|
|
307
|
+
implementation, you will be responsible for providing patches in a timely
|
|
308
|
+
fashion. If critical issues for a particular implementation exist at the time
|
|
309
|
+
of a major release, support for that Ruby version may be dropped.
|
|
310
|
+
|
|
311
|
+
</details>
|
|
312
|
+
|
|
313
|
+
| | Ruby OAuth2 Version | Maintenance Branch | Targeted Support | Best Effort Support | Incidental Support |
|
|
314
|
+
|:----|---------------------|--------------------|----------------------|-------------------------|------------------------------|
|
|
315
|
+
| 1️⃣ | 2.0.x | `main` | 3.2, 3.3, 3.4 | 2.5, 2.6, 2.7, 3.0, 3.1 | 2.2, 2.3, 2.4 |
|
|
316
|
+
| 2️⃣ | 1.4.x | `1-4-stable` | 3.2, 3.3, 3.4 | 2.5, 2.6, 2.7, 3.0, 3.1 | 1.9, 2.0, 2.1, 2.2, 2.3, 2.4 |
|
|
317
|
+
| 3️⃣ | older | N/A | Best of luck to you! | Please upgrade! | |
|
|
318
|
+
|
|
319
|
+
NOTE: The 1.4 series will only receive critical security updates.
|
|
320
|
+
See [SECURITY.md][🔐security] and [IRP.md][🔐irp].
|
|
321
|
+
|
|
322
|
+
## ⚙️ Configuration
|
|
323
|
+
|
|
324
|
+
Global settings for the library:
|
|
78
325
|
|
|
79
326
|
```ruby
|
|
80
|
-
|
|
81
|
-
|
|
327
|
+
OAuth2.configure do |config|
|
|
328
|
+
config.silence_extra_tokens_warning = false # default: true
|
|
329
|
+
config.silence_no_tokens_warning = false # default: true
|
|
330
|
+
end
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Filtering-related settings:
|
|
82
334
|
|
|
83
|
-
|
|
84
|
-
|
|
335
|
+
```ruby
|
|
336
|
+
OAuth2.configure do |config|
|
|
337
|
+
config.filtered_label = "[REDACTED]" # default: "[FILTERED]"
|
|
338
|
+
config.filtered_debug_keys += ["client_assertion"]
|
|
339
|
+
end
|
|
340
|
+
```
|
|
85
341
|
|
|
86
|
-
|
|
87
|
-
|
|
342
|
+
- `filtered_label` controls the placeholder used when sensitive values are filtered from inspected objects and debug logging output.
|
|
343
|
+
- `filtered_debug_keys` controls which key names have their values redacted from debug logging output when `OAUTH_DEBUG=true`.
|
|
344
|
+
- Debug logging remains opt-in and should still be used cautiously in production environments.
|
|
345
|
+
|
|
346
|
+
## 🔧 Basic Usage
|
|
347
|
+
|
|
348
|
+
### Client Initialization Options
|
|
349
|
+
|
|
350
|
+
`OAuth2::Client.new` accepts several options:
|
|
351
|
+
|
|
352
|
+
- `:site`: The base URL for the OAuth 2.0 provider.
|
|
353
|
+
- `:authorize_url`: The authorization endpoint (default: `"oauth/authorize"`).
|
|
354
|
+
- `:token_url`: The token endpoint (default: `"oauth/token"`).
|
|
355
|
+
- `:auth_scheme`: The authentication scheme (`:basic_auth`, `:request_body`, `:tls_client_auth`, `:private_key_jwt`). Default is `:basic_auth`.
|
|
356
|
+
- `:connection_opts`: Options for the underlying Faraday connection (timeouts, proxy, etc.).
|
|
357
|
+
- `:raise_errors`: Whether to raise `OAuth2::Error` on 400+ responses (default: `true`).
|
|
358
|
+
|
|
359
|
+
<details markdown="1">
|
|
360
|
+
<summary><em>authorize_url</em> and <em>token_url</em></summary>
|
|
361
|
+
|
|
362
|
+
### `authorize_url` and `token_url` are on site root (Just Works!)
|
|
363
|
+
|
|
364
|
+
```ruby
|
|
365
|
+
require "oauth2"
|
|
366
|
+
client = OAuth2::Client.new("client_id", "client_secret", site: "https://example.org")
|
|
367
|
+
# => #<OAuth2::Client:0x00000001204c8288 @id="client_id", @secret="client_sec...
|
|
368
|
+
client.auth_code.authorize_url(redirect_uri: "http://localhost:8080/oauth2/callback")
|
|
369
|
+
# => "https://example.org/oauth/authorize?client_id=client_id&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Foauth2%2Fcallback&response_type=code"
|
|
370
|
+
|
|
371
|
+
access = client.auth_code.get_token("authorization_code_value", redirect_uri: "http://localhost:8080/oauth2/callback", headers: {"Authorization" => "Basic some_password"})
|
|
372
|
+
response = access.get("/api/resource", params: {"query_foo" => "bar"})
|
|
88
373
|
response.class.name
|
|
89
374
|
# => OAuth2::Response
|
|
90
375
|
```
|
|
91
|
-
## OAuth2::Response
|
|
92
376
|
|
|
93
|
-
|
|
94
|
-
|
|
377
|
+
### Relative `authorize_url` and `token_url` (Not on site root, Just Works!)
|
|
378
|
+
|
|
379
|
+
In the 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.
|
|
380
|
+
|
|
381
|
+
```ruby
|
|
382
|
+
client = OAuth2::Client.new("client_id", "client_secret", site: "https://example.org/nested/directory/on/your/server")
|
|
383
|
+
# => #<OAuth2::Client:0x00000001204c8288 @id="client_id", @secret="client_sec...
|
|
384
|
+
client.auth_code.authorize_url(redirect_uri: "http://localhost:8080/oauth2/callback")
|
|
385
|
+
# => "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"
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Customize `authorize_url` and `token_url`
|
|
389
|
+
|
|
390
|
+
You can specify custom URLs for authorization and access token, and when using a leading `/` they will _not be relative_, as shown below:
|
|
391
|
+
|
|
392
|
+
```ruby
|
|
393
|
+
client = OAuth2::Client.new(
|
|
394
|
+
"client_id",
|
|
395
|
+
"client_secret",
|
|
396
|
+
site: "https://example.org/nested/directory/on/your/server",
|
|
397
|
+
authorize_url: "/jaunty/authorize/",
|
|
398
|
+
token_url: "/stirrups/access_token",
|
|
399
|
+
)
|
|
400
|
+
# => #<OAuth2::Client:0x00000001204c8288 @id="client_id", @secret="client_sec...
|
|
401
|
+
client.auth_code.authorize_url(redirect_uri: "http://localhost:8080/oauth2/callback")
|
|
402
|
+
# => "https://example.org/jaunty/authorize/?client_id=client_id&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Foauth2%2Fcallback&response_type=code"
|
|
403
|
+
client.class.name
|
|
404
|
+
# => OAuth2::Client
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
</details>
|
|
408
|
+
|
|
409
|
+
### Advanced Initializers
|
|
410
|
+
|
|
411
|
+
```ruby
|
|
412
|
+
client = OAuth2::Client.new(id, secret, site: site) do |faraday|
|
|
413
|
+
faraday.request(:url_encoded)
|
|
414
|
+
faraday.adapter(:net_http_persistent)
|
|
415
|
+
end
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### AccessToken Features
|
|
419
|
+
|
|
420
|
+
Instances of `OAuth2::AccessToken` handle request signing and token expiration.
|
|
421
|
+
|
|
422
|
+
- **Snake Case & Indifferent Access**: `response.parsed` returns a `SnakyHash` allowing access via string/symbol and snake_case keys even if the provider returns CamelCase.
|
|
423
|
+
- **Auto-Refresh**: You can manually check `token.expired?` and call `token.refresh`.
|
|
424
|
+
- **Serialization**: Persist tokens using `token.to_hash` and restore via `OAuth2::AccessToken.from_hash(client, hash)`.
|
|
425
|
+
|
|
426
|
+
### snake_case and indifferent access in Response#parsed
|
|
427
|
+
|
|
428
|
+
```ruby
|
|
429
|
+
response = access.get("/api/resource", params: {"query_foo" => "bar"})
|
|
430
|
+
# Even if the actual response is CamelCase. it will be made available as snaky:
|
|
431
|
+
JSON.parse(response.body) # => {"accessToken"=>"aaaaaaaa", "additionalData"=>"additional"}
|
|
432
|
+
response.parsed # => {"access_token"=>"aaaaaaaa", "additional_data"=>"additional"}
|
|
433
|
+
response.parsed.access_token # => "aaaaaaaa"
|
|
434
|
+
response.parsed[:access_token] # => "aaaaaaaa"
|
|
435
|
+
response.parsed.additional_data # => "additional"
|
|
436
|
+
response.parsed[:additional_data] # => "additional"
|
|
437
|
+
response.parsed.class.name # => SnakyHash::StringKeyed (from snaky_hash gem)
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
#### Serialization
|
|
441
|
+
|
|
442
|
+
As of v2.0.11, if you need to serialize the parsed result, you can!
|
|
443
|
+
|
|
444
|
+
There are two ways to do this, globally, or discretely. The discrete way is recommended.
|
|
445
|
+
|
|
446
|
+
##### Global Serialization Config
|
|
447
|
+
|
|
448
|
+
Globally configure `SnakyHash::StringKeyed` to use the serializer. Put this in your code somewhere reasonable (like an initializer for Rails).
|
|
449
|
+
|
|
450
|
+
```ruby
|
|
451
|
+
SnakyHash::StringKeyed.class_eval do
|
|
452
|
+
extend SnakyHash::Serializer
|
|
453
|
+
end
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
##### Discrete Serialization Config
|
|
457
|
+
|
|
458
|
+
Discretely configure a custom Snaky Hash class to use the serializer.
|
|
459
|
+
|
|
460
|
+
```ruby
|
|
461
|
+
class MySnakyHash < SnakyHash::StringKeyed
|
|
462
|
+
# Give this hash class `dump` and `load` abilities!
|
|
463
|
+
extend SnakyHash::Serializer
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
# And tell your client to use the custom class in each call:
|
|
467
|
+
client = OAuth2::Client.new("client_id", "client_secret", site: "https://example.org/oauth2")
|
|
468
|
+
token = client.get_token({snaky_hash_klass: MySnakyHash})
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
##### Serialization Extensions
|
|
472
|
+
|
|
473
|
+
These extensions work regardless of whether you used the global or discrete config above.
|
|
474
|
+
|
|
475
|
+
There are a few hacks you may need in your class to support Ruby < 2.4.2 or < 2.6.
|
|
476
|
+
They are likely not needed if you are on a newer Ruby.
|
|
477
|
+
Expand the examples below, or the [ruby-oauth/snaky_hash](https://gitlab.com/ruby-oauth/snaky_hash) gem,
|
|
478
|
+
or [response_spec.rb](https://github.com/ruby-oauth/oauth2/blob/main/spec/oauth2/response_spec.rb), for more ideas, especially if you need to study the hacks for older Rubies.
|
|
479
|
+
|
|
480
|
+
<details markdown="1">
|
|
481
|
+
<summary>See Examples</summary>
|
|
482
|
+
|
|
483
|
+
```ruby
|
|
484
|
+
class MySnakyHash < SnakyHash::StringKeyed
|
|
485
|
+
# Give this hash class `dump` and `load` abilities!
|
|
486
|
+
extend SnakyHash::Serializer
|
|
487
|
+
|
|
488
|
+
#### Serialization Extentions
|
|
489
|
+
#
|
|
490
|
+
# Act on the non-hash values (including the values of hashes) as they are dumped to JSON
|
|
491
|
+
# In other words, this retains nested hashes, and only the deepest leaf nodes become bananas.
|
|
492
|
+
# WARNING: This is a silly example!
|
|
493
|
+
dump_value_extensions.add(:to_fruit) do |value|
|
|
494
|
+
"banana" # => Make values "banana" on dump
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
# Act on the non-hash values (including the values of hashes) as they are loaded from the JSON dump
|
|
498
|
+
# In other words, this retains nested hashes, and only the deepest leaf nodes become ***.
|
|
499
|
+
# WARNING: This is a silly example!
|
|
500
|
+
load_value_extensions.add(:to_stars) do |value|
|
|
501
|
+
"***" # Turn dumped bananas into *** when they are loaded
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
# Act on the entire hash as it is prepared for dumping to JSON
|
|
505
|
+
# WARNING: This is a silly example!
|
|
506
|
+
dump_hash_extensions.add(:to_cheese) do |value|
|
|
507
|
+
if value.is_a?(Hash)
|
|
508
|
+
value.transform_keys do |key|
|
|
509
|
+
split = key.split("_")
|
|
510
|
+
first_word = split[0]
|
|
511
|
+
key.sub(first_word, "cheese")
|
|
512
|
+
end
|
|
513
|
+
else
|
|
514
|
+
value
|
|
515
|
+
end
|
|
516
|
+
end
|
|
517
|
+
|
|
518
|
+
# Act on the entire hash as it is loaded from the JSON dump
|
|
519
|
+
# WARNING: This is a silly example!
|
|
520
|
+
load_hash_extensions.add(:to_pizza) do |value|
|
|
521
|
+
if value.is_a?(Hash)
|
|
522
|
+
res = klass.new
|
|
523
|
+
value.keys.each_with_object(res) do |key, result|
|
|
524
|
+
split = key.split("_")
|
|
525
|
+
last_word = split[-1]
|
|
526
|
+
new_key = key.sub(last_word, "pizza")
|
|
527
|
+
result[new_key] = value[key]
|
|
528
|
+
end
|
|
529
|
+
res
|
|
530
|
+
else
|
|
531
|
+
value
|
|
532
|
+
end
|
|
533
|
+
end
|
|
534
|
+
end
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
</details>
|
|
538
|
+
|
|
539
|
+
#### Prefer camelCase over snake_case? => snaky: false
|
|
540
|
+
|
|
541
|
+
```ruby
|
|
542
|
+
response = access.get("/api/resource", params: {"query_foo" => "bar"}, snaky: false)
|
|
543
|
+
JSON.parse(response.body) # => {"accessToken"=>"aaaaaaaa", "additionalData"=>"additional"}
|
|
544
|
+
response.parsed # => {"accessToken"=>"aaaaaaaa", "additionalData"=>"additional"}
|
|
545
|
+
response.parsed["accessToken"] # => "aaaaaaaa"
|
|
546
|
+
response.parsed["additionalData"] # => "additional"
|
|
547
|
+
response.parsed.class.name # => Hash (just, regular old Hash)
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
<details markdown="1">
|
|
551
|
+
<summary>Debugging & Logging</summary>
|
|
552
|
+
|
|
553
|
+
Set an environment variable as per usual (e.g. with [dotenv](https://github.com/bkeepers/dotenv)).
|
|
554
|
+
|
|
555
|
+
```ruby
|
|
556
|
+
# will log both request and response, including bodies
|
|
557
|
+
ENV["OAUTH_DEBUG"] = "true"
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
By default, debug output will go to `$stdout`. This can be overridden when
|
|
561
|
+
initializing your OAuth2::Client.
|
|
95
562
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
563
|
+
Sensitive values are filtered from debug logging output using:
|
|
564
|
+
|
|
565
|
+
- `OAuth2.config[:filtered_label]`
|
|
566
|
+
- `OAuth2.config[:filtered_debug_keys]`
|
|
567
|
+
|
|
568
|
+
Debug logging remains opt-in and should still be used cautiously in production environments.
|
|
569
|
+
|
|
570
|
+
```ruby
|
|
571
|
+
require "oauth2"
|
|
572
|
+
client = OAuth2::Client.new(
|
|
573
|
+
"client_id",
|
|
574
|
+
"client_secret",
|
|
575
|
+
site: "https://example.org",
|
|
576
|
+
logger: Logger.new("example.log", "weekly"),
|
|
577
|
+
)
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
</details>
|
|
581
|
+
|
|
582
|
+
### Request Target Trust Boundaries
|
|
583
|
+
|
|
584
|
+
This gem supports request flows that can involve absolute URLs in addition to relative paths.
|
|
585
|
+
That flexibility can expand trust boundaries when a token-bearing client is asked to send requests
|
|
586
|
+
to caller-provided targets.
|
|
587
|
+
|
|
588
|
+
Practical guidance:
|
|
589
|
+
|
|
590
|
+
- prefer relative paths where practical
|
|
591
|
+
- do not pass untrusted absolute URLs into token-bearing clients
|
|
592
|
+
- validate or allowlist request targets at the application layer today if your deployment has strict trust-boundary requirements
|
|
593
|
+
|
|
594
|
+
This release line does not yet enforce same-host or allowlist request policy automatically.
|
|
595
|
+
If stricter outbound request controls are needed, they should currently be implemented by the calling application.
|
|
596
|
+
|
|
597
|
+
### OAuth2::Response
|
|
598
|
+
|
|
599
|
+
The `AccessToken` methods `#get`, `#post`, `#put` and `#delete` and the generic `#request`
|
|
600
|
+
will return an instance of the `OAuth2::Response` class.
|
|
601
|
+
|
|
602
|
+
This instance contains a `#parsed` method that will parse the response body and
|
|
603
|
+
return a Hash-like [`SnakyHash::StringKeyed`](https://gitlab.com/ruby-oauth/snaky_hash/-/blob/main/lib/snaky_hash/string_keyed.rb) if the `Content-Type` is `application/x-www-form-urlencoded` or if
|
|
604
|
+
the body is a JSON object. It will return an Array if the body is a JSON
|
|
605
|
+
array. Otherwise, it will return the original body string.
|
|
100
606
|
|
|
101
607
|
The original response body, headers, and status can be accessed via their
|
|
102
608
|
respective methods.
|
|
103
609
|
|
|
104
|
-
|
|
610
|
+
### OAuth2::AccessToken
|
|
105
611
|
|
|
106
612
|
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).
|
|
613
|
+
using various class methods including the standard new, `from_hash` (if you have
|
|
614
|
+
a hash of the values), or `from_kvform` (if you have an
|
|
615
|
+
`application/x-www-form-urlencoded` encoded string of the values).
|
|
616
|
+
|
|
617
|
+
Options (since v2.0.x unless noted):
|
|
618
|
+
|
|
619
|
+
- `expires_latency` (Integer | nil): Seconds to subtract from expires_in when computing #expired? to offset latency.
|
|
620
|
+
- `token_name` (String | Symbol | nil): When multiple token-like fields exist in responses, select the field name to use as the access token (since v2.0.10).
|
|
621
|
+
- `mode` (Symbol | Proc | Hash): Controls how the token is transmitted on requests made via this AccessToken instance.
|
|
622
|
+
- `:header` — Send as Authorization: Bearer <token> header (default and preferred by OAuth 2.1 draft guidance).
|
|
623
|
+
- `:query` — Send as access_token query parameter (discouraged in general, but required by some providers).
|
|
624
|
+
- Verb-dependent (since v2.0.15): Provide either:
|
|
625
|
+
- a `Proc` taking `|verb|` and returning `:header` or `:query`, or
|
|
626
|
+
- a `Hash` with verb symbols as keys, for example `{get: :query, post: :header, delete: :header}`.
|
|
110
627
|
|
|
111
|
-
|
|
628
|
+
Note: Verb-dependent mode supports providers like Instagram that require query mode for `GET` and header mode for `POST`/`DELETE`
|
|
112
629
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
error_description parameters. The #response property of OAuth2::Error will
|
|
116
|
-
always contain the OAuth2::Response instance.
|
|
630
|
+
- Verb-dependent mode via `Proc` was added in v2.0.15
|
|
631
|
+
- Verb-dependent mode via `Hash` was added in v2.0.16
|
|
117
632
|
|
|
118
|
-
|
|
119
|
-
|
|
633
|
+
### OAuth2::Error
|
|
634
|
+
|
|
635
|
+
On 400+ status code responses, an `OAuth2::Error` will be raised. If it is a
|
|
636
|
+
standard OAuth2 error response, the body will be parsed and `#code` and `#description` will contain the values provided from the error and
|
|
637
|
+
`error_description` parameters. The `#response` property of `OAuth2::Error` will
|
|
638
|
+
always contain the `OAuth2::Response` instance.
|
|
639
|
+
|
|
640
|
+
If you do not want an error to be raised, you may use `:raise_errors => false`
|
|
641
|
+
option on initialization of the client. In this case the `OAuth2::Response`
|
|
120
642
|
instance will be returned as usual and on 400+ status code responses, the
|
|
121
|
-
Response instance will contain the OAuth2::Error instance.
|
|
643
|
+
Response instance will contain the `OAuth2::Error` instance.
|
|
122
644
|
|
|
123
|
-
|
|
645
|
+
### Authorization Grants
|
|
124
646
|
|
|
125
|
-
Currently the Authorization Code, Implicit, Resource Owner Password Credentials, Client Credentials, and Assertion
|
|
647
|
+
Currently, the Authorization Code, Implicit, Resource Owner Password Credentials, Client Credentials, and Assertion
|
|
126
648
|
authentication grant types have helper strategy classes that simplify client
|
|
127
|
-
use.
|
|
649
|
+
use. They are available via the [`#auth_code`](https://gitlab.com/ruby-oauth/oauth2/-/blob/main/lib/oauth2/strategy/auth_code.rb),
|
|
650
|
+
[`#implicit`](https://gitlab.com/ruby-oauth/oauth2/-/blob/main/lib/oauth2/strategy/implicit.rb),
|
|
651
|
+
[`#password`](https://gitlab.com/ruby-oauth/oauth2/-/blob/main/lib/oauth2/strategy/password.rb),
|
|
652
|
+
[`#client_credentials`](https://gitlab.com/ruby-oauth/oauth2/-/blob/main/lib/oauth2/strategy/client_credentials.rb), and
|
|
653
|
+
[`#assertion`](https://gitlab.com/ruby-oauth/oauth2/-/blob/main/lib/oauth2/strategy/assertion.rb) methods respectively.
|
|
128
654
|
|
|
129
|
-
|
|
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')
|
|
655
|
+
#### OAuth 2.1 (draft) Note:
|
|
132
656
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
657
|
+
- **PKCE** is required for all OAuth clients using the authorization code flow (especially public clients). Implement PKCE in your app when required by your provider. See RFC 7636 and RFC 8252.
|
|
658
|
+
- **Implicit grant** (response_type=token) and **Resource Owner Password Credentials grant** are omitted from OAuth 2.1; they remain here for OAuth 2.0 compatibility but should be avoided for new apps.
|
|
659
|
+
- **Redirect URIs** must be compared using exact string matching by the Authorization Server.
|
|
660
|
+
|
|
661
|
+
<details markdown="1">
|
|
662
|
+
<summary>OAuth 2.1 (draft) References</summary>
|
|
136
663
|
|
|
137
|
-
|
|
664
|
+
- OAuth 2.1 draft: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13
|
|
665
|
+
- Aaron Parecki: https://aaronparecki.com/2019/12/12/21/its-time-for-oauth-2-dot-1
|
|
666
|
+
- FusionAuth: https://fusionauth.io/blog/2020/04/15/whats-new-in-oauth-2-1
|
|
667
|
+
- Okta: https://developer.okta.com/blog/2019/12/13/oauth-2-1-how-many-rfcs
|
|
668
|
+
- Video: https://www.youtube.com/watch?v=g_aVPdwBTfw
|
|
669
|
+
- Differences overview: https://fusionauth.io/learn/expert-advice/oauth/differences-between-oauth-2-oauth-2-1/
|
|
138
670
|
|
|
139
|
-
|
|
671
|
+
</details>
|
|
140
672
|
|
|
141
|
-
|
|
673
|
+
These aren't full examples, but demonstrative of the differences between usage for each strategy.
|
|
674
|
+
|
|
675
|
+
```ruby
|
|
676
|
+
auth_url = client.auth_code.authorize_url(redirect_uri: "http://localhost:8080/oauth/callback")
|
|
677
|
+
access = client.auth_code.get_token("code_value", redirect_uri: "http://localhost:8080/oauth/callback")
|
|
678
|
+
|
|
679
|
+
auth_url = client.implicit.authorize_url(redirect_uri: "http://localhost:8080/oauth/callback")
|
|
680
|
+
# get the token params in the callback and
|
|
681
|
+
access = OAuth2::AccessToken.from_kvform(client, query_string)
|
|
682
|
+
|
|
683
|
+
access = client.password.get_token("username", "password")
|
|
684
|
+
|
|
685
|
+
access = client.client_credentials.get_token
|
|
686
|
+
|
|
687
|
+
# Client Assertion Strategy
|
|
688
|
+
# see: https://tools.ietf.org/html/rfc7523
|
|
689
|
+
claimset = {
|
|
690
|
+
iss: "http://localhost:3001",
|
|
691
|
+
aud: "http://localhost:8080/oauth2/token",
|
|
692
|
+
sub: "me@example.com",
|
|
693
|
+
exp: Time.now.utc.to_i + 3600,
|
|
694
|
+
}
|
|
695
|
+
assertion_params = [claimset, "HS256", "secret_key"]
|
|
696
|
+
access = client.assertion.get_token(assertion_params)
|
|
697
|
+
|
|
698
|
+
# The `access` (i.e. access token) is then used like so:
|
|
699
|
+
access.token # actual access_token string, if you need it somewhere
|
|
700
|
+
access.get("/api/stuff") # making api calls with access token
|
|
142
701
|
```
|
|
143
702
|
|
|
144
703
|
If you want to specify additional headers to be sent out with the
|
|
145
704
|
request, add a 'headers' hash under 'params':
|
|
146
705
|
|
|
147
706
|
```ruby
|
|
148
|
-
|
|
707
|
+
access = client.auth_code.get_token("code_value", redirect_uri: "http://localhost:8080/oauth/callback", headers: {"Some" => "Header"})
|
|
149
708
|
```
|
|
150
709
|
|
|
151
|
-
You can always use the
|
|
710
|
+
You can always use the `#request` method on the `OAuth2::Client` instance to make
|
|
152
711
|
requests for tokens for any Authentication grant type.
|
|
153
712
|
|
|
154
|
-
##
|
|
713
|
+
## 📘 Comprehensive Usage
|
|
155
714
|
|
|
156
|
-
|
|
157
|
-
implementations:
|
|
715
|
+
### Common Flows (end-to-end)
|
|
158
716
|
|
|
159
|
-
|
|
717
|
+
- Authorization Code (server-side web app):
|
|
160
718
|
|
|
161
|
-
|
|
162
|
-
|
|
719
|
+
```ruby
|
|
720
|
+
require "oauth2"
|
|
721
|
+
client = OAuth2::Client.new(
|
|
722
|
+
ENV["CLIENT_ID"],
|
|
723
|
+
ENV["CLIENT_SECRET"],
|
|
724
|
+
site: "https://provider.example.com",
|
|
725
|
+
redirect_uri: "https://my.app.example.com/oauth/callback",
|
|
726
|
+
)
|
|
727
|
+
|
|
728
|
+
# Step 1: redirect user to consent
|
|
729
|
+
state = SecureRandom.hex(16)
|
|
730
|
+
auth_url = client.auth_code.authorize_url(scope: "openid profile email", state: state)
|
|
731
|
+
# redirect_to auth_url
|
|
732
|
+
|
|
733
|
+
# Step 2: handle the callback
|
|
734
|
+
# params[:code], params[:state]
|
|
735
|
+
raise "state mismatch" unless params[:state] == state
|
|
736
|
+
access = client.auth_code.get_token(params[:code])
|
|
737
|
+
|
|
738
|
+
# Step 3: call APIs
|
|
739
|
+
profile = access.get("/api/v1/me").parsed
|
|
740
|
+
```
|
|
163
741
|
|
|
164
|
-
|
|
165
|
-
- [JRuby 9.0][jruby-9.0] (targets MRI v2.0)
|
|
166
|
-
* Ruby 2.1
|
|
742
|
+
- Client Credentials (machine-to-machine):
|
|
167
743
|
|
|
168
|
-
|
|
744
|
+
```ruby
|
|
745
|
+
client = OAuth2::Client.new(ENV["CLIENT_ID"], ENV["CLIENT_SECRET"], site: "https://provider.example.com")
|
|
746
|
+
access = client.client_credentials.get_token(audience: "https://api.example.com")
|
|
747
|
+
resp = access.get("/v1/things")
|
|
748
|
+
```
|
|
169
749
|
|
|
170
|
-
|
|
750
|
+
- Resource Owner Password (legacy; avoid when possible):
|
|
171
751
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
|
752
|
+
```ruby
|
|
753
|
+
access = client.password.get_token("jdoe", "s3cret", scope: "read")
|
|
754
|
+
```
|
|
181
755
|
|
|
182
|
-
|
|
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
|
|
756
|
+
#### Examples
|
|
187
757
|
|
|
188
|
-
|
|
758
|
+
<details markdown="1">
|
|
759
|
+
<summary>JHipster UAA (Spring Cloud) password grant example (legacy; avoid when possible)</summary>
|
|
189
760
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
761
|
+
```ruby
|
|
762
|
+
# This converts a Postman/Net::HTTP multipart token request to oauth2 gem usage.
|
|
763
|
+
# JHipster UAA typically exposes the token endpoint at /uaa/oauth/token.
|
|
764
|
+
# The original snippet included:
|
|
765
|
+
# - Basic Authorization header for the client (web_app:changeit)
|
|
766
|
+
# - X-XSRF-TOKEN header from a cookie (some deployments require it)
|
|
767
|
+
# - grant_type=password with username/password and client_id
|
|
768
|
+
# Using oauth2 gem, you don't need to build multipart bodies; the gem sends
|
|
769
|
+
# application/x-www-form-urlencoded as required by RFC 6749.
|
|
770
|
+
|
|
771
|
+
require "oauth2"
|
|
772
|
+
|
|
773
|
+
client = OAuth2::Client.new(
|
|
774
|
+
"web_app", # client_id
|
|
775
|
+
"changeit", # client_secret
|
|
776
|
+
site: "http://localhost:8080/uaa",
|
|
777
|
+
token_url: "/oauth/token", # absolute under site (or "oauth/token" relative)
|
|
778
|
+
auth_scheme: :basic_auth, # sends HTTP Basic Authorization header
|
|
779
|
+
)
|
|
780
|
+
|
|
781
|
+
# If your UAA requires an XSRF header for the token call, provide it as a header.
|
|
782
|
+
# Often this is not required for token endpoints, but if your gateway enforces it,
|
|
783
|
+
# obtain the value from the XSRF-TOKEN cookie and pass it here.
|
|
784
|
+
xsrf_token = ENV["X_XSRF_TOKEN"] # e.g., pulled from a prior set-cookie value
|
|
785
|
+
|
|
786
|
+
access = client.password.get_token(
|
|
787
|
+
"admin", # username
|
|
788
|
+
"admin", # password
|
|
789
|
+
headers: xsrf_token ? {"X-XSRF-TOKEN" => xsrf_token} : {},
|
|
790
|
+
# JHipster commonly also accepts/needs the client_id in the body; include if required:
|
|
791
|
+
# client_id: "web_app",
|
|
792
|
+
)
|
|
793
|
+
|
|
794
|
+
puts access.token
|
|
795
|
+
puts access.to_hash # full token response
|
|
796
|
+
```
|
|
193
797
|
|
|
194
|
-
|
|
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.
|
|
798
|
+
Notes:
|
|
200
799
|
|
|
201
|
-
|
|
800
|
+
- Resource Owner Password Credentials (ROPC) is deprecated in OAuth 2.1 and discouraged. Prefer Authorization Code + PKCE.
|
|
801
|
+
- If your deployment strictly demands the X-XSRF-TOKEN header, first fetch it from an endpoint that sets the XSRF-TOKEN cookie (often "/" or a login page) and pass it to headers.
|
|
802
|
+
- For Basic auth, auth_scheme: :basic_auth handles the Authorization header; you do not need to base64-encode manually.
|
|
202
803
|
|
|
203
|
-
|
|
204
|
-
Violations of this scheme should be reported as bugs. Specifically,
|
|
205
|
-
if a minor or patch version is released that breaks backward
|
|
206
|
-
compatibility, a new version should be immediately released that
|
|
207
|
-
restores compatibility. Breaking changes to the public API will
|
|
208
|
-
only be introduced with new major versions.
|
|
804
|
+
</details>
|
|
209
805
|
|
|
210
|
-
|
|
211
|
-
dependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision.
|
|
806
|
+
### Verb‑dependent Token Mode
|
|
212
807
|
|
|
213
|
-
|
|
808
|
+
Providers like Instagram require the access token to be sent differently depending on the HTTP verb:
|
|
809
|
+
|
|
810
|
+
- GET requests: token must be in the query string (?access_token=...)
|
|
811
|
+
- POST/DELETE requests: token must be in the Authorization header (Bearer ...)
|
|
812
|
+
|
|
813
|
+
Since v2.0.15, you can configure an AccessToken with a verb‑dependent mode. The gem will choose how to send the token based on the request method.
|
|
814
|
+
|
|
815
|
+
Tips:
|
|
816
|
+
|
|
817
|
+
- Avoid query‑string bearer tokens unless required by your provider. Instagram explicitly requires it for `GET` requests.
|
|
818
|
+
- If you need a custom rule, you can pass a `Proc` for `mode`, e.g. `mode: ->(verb) { verb == :get ? :query : :header }`.
|
|
819
|
+
|
|
820
|
+
<details markdown="1">
|
|
821
|
+
<summary>Instagram API Example</summary>
|
|
822
|
+
|
|
823
|
+
Example: exchanging and refreshing long‑lived Instagram tokens, and making API calls
|
|
824
|
+
|
|
825
|
+
```ruby
|
|
826
|
+
require "oauth2"
|
|
827
|
+
|
|
828
|
+
# NOTE: Users authenticate via Facebook Login to obtain a short‑lived user token (not shown here).
|
|
829
|
+
# See Facebook Login docs for obtaining the initial short‑lived token.
|
|
830
|
+
|
|
831
|
+
client = OAuth2::Client.new(nil, nil, site: "https://graph.instagram.com")
|
|
832
|
+
|
|
833
|
+
# Start with a short‑lived token you already obtained via Facebook Login
|
|
834
|
+
short_lived = OAuth2::AccessToken.new(
|
|
835
|
+
client,
|
|
836
|
+
ENV["IG_SHORT_LIVED_TOKEN"],
|
|
837
|
+
# Key part: verb‑dependent mode
|
|
838
|
+
mode: {get: :query, post: :header, delete: :header},
|
|
839
|
+
)
|
|
840
|
+
|
|
841
|
+
# 1) Exchange for a long‑lived token (Instagram requires GET with access_token in query)
|
|
842
|
+
# Endpoint: GET https://graph.instagram.com/access_token
|
|
843
|
+
# Params: grant_type=ig_exchange_token, client_secret=APP_SECRET
|
|
844
|
+
exchange = short_lived.get(
|
|
845
|
+
"/access_token",
|
|
846
|
+
params: {
|
|
847
|
+
grant_type: "ig_exchange_token",
|
|
848
|
+
client_secret: ENV["IG_APP_SECRET"],
|
|
849
|
+
# access_token param will be added automatically by the AccessToken (mode => :query for GET)
|
|
850
|
+
},
|
|
851
|
+
)
|
|
852
|
+
long_lived_token_value = exchange.parsed["access_token"]
|
|
853
|
+
|
|
854
|
+
long_lived = OAuth2::AccessToken.new(
|
|
855
|
+
client,
|
|
856
|
+
long_lived_token_value,
|
|
857
|
+
mode: {get: :query, post: :header, delete: :header},
|
|
858
|
+
)
|
|
859
|
+
|
|
860
|
+
# 2) Refresh the long‑lived token (Instagram uses GET with token in query)
|
|
861
|
+
# Endpoint: GET https://graph.instagram.com/refresh_access_token
|
|
862
|
+
refresh_resp = long_lived.get(
|
|
863
|
+
"/refresh_access_token",
|
|
864
|
+
params: {grant_type: "ig_refresh_token"},
|
|
865
|
+
)
|
|
866
|
+
long_lived = OAuth2::AccessToken.new(
|
|
867
|
+
client,
|
|
868
|
+
refresh_resp.parsed["access_token"],
|
|
869
|
+
mode: {get: :query, post: :header, delete: :header},
|
|
870
|
+
)
|
|
871
|
+
|
|
872
|
+
# 3) Typical API GET request (token in query automatically)
|
|
873
|
+
me = long_lived.get("/me", params: {fields: "id,username"}).parsed
|
|
874
|
+
|
|
875
|
+
# 4) Example POST (token sent via Bearer header automatically)
|
|
876
|
+
# Note: Replace the path/params with a real Instagram Graph API POST you need,
|
|
877
|
+
# such as publishing media via the Graph API endpoints.
|
|
878
|
+
# long_lived.post("/me/media", body: {image_url: "https://...", caption: "hello"})
|
|
879
|
+
```
|
|
880
|
+
|
|
881
|
+
</details>
|
|
882
|
+
|
|
883
|
+
### Refresh Tokens
|
|
884
|
+
|
|
885
|
+
When the server issues a refresh_token, you can refresh manually or implement an auto-refresh wrapper.
|
|
886
|
+
|
|
887
|
+
- Manual refresh:
|
|
888
|
+
|
|
889
|
+
```ruby
|
|
890
|
+
if access.expired?
|
|
891
|
+
access = access.refresh
|
|
892
|
+
end
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
- Auto-refresh wrapper pattern:
|
|
896
|
+
|
|
897
|
+
```ruby
|
|
898
|
+
class AutoRefreshingToken
|
|
899
|
+
def initialize(token_provider, store: nil)
|
|
900
|
+
@token = token_provider
|
|
901
|
+
@store = store # e.g., something that responds to read/write for token data
|
|
902
|
+
end
|
|
903
|
+
|
|
904
|
+
def with(&blk)
|
|
905
|
+
tok = ensure_fresh!
|
|
906
|
+
blk ? blk.call(tok) : tok
|
|
907
|
+
rescue OAuth2::Error => e
|
|
908
|
+
# If a 401 suggests token invalidation, try one refresh and retry once
|
|
909
|
+
if e.response && e.response.status == 401 && @token.refresh_token
|
|
910
|
+
@token = @token.refresh
|
|
911
|
+
@store.write(@token.to_hash) if @store
|
|
912
|
+
retry
|
|
913
|
+
end
|
|
914
|
+
raise
|
|
915
|
+
end
|
|
916
|
+
|
|
917
|
+
private
|
|
918
|
+
|
|
919
|
+
def ensure_fresh!
|
|
920
|
+
if @token.expired? && @token.refresh_token
|
|
921
|
+
@token = @token.refresh
|
|
922
|
+
@store.write(@token.to_hash) if @store
|
|
923
|
+
end
|
|
924
|
+
@token
|
|
925
|
+
end
|
|
926
|
+
end
|
|
927
|
+
|
|
928
|
+
# usage
|
|
929
|
+
keeper = AutoRefreshingToken.new(access)
|
|
930
|
+
keeper.with { |tok| tok.get("/v1/protected") }
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
Persist the token across processes using `AccessToken#to_hash` and `AccessToken.from_hash(client, hash)`.
|
|
934
|
+
|
|
935
|
+
### Token Revocation (RFC 7009)
|
|
936
|
+
|
|
937
|
+
You can revoke either the access token or the refresh token.
|
|
938
|
+
|
|
939
|
+
```ruby
|
|
940
|
+
# Revoke the current access token
|
|
941
|
+
access.revoke(token_type_hint: :access_token)
|
|
942
|
+
|
|
943
|
+
# Or explicitly revoke the refresh token (often also invalidates associated access tokens)
|
|
944
|
+
access.revoke(token_type_hint: :refresh_token)
|
|
945
|
+
```
|
|
946
|
+
|
|
947
|
+
### Client Configuration Tips
|
|
948
|
+
|
|
949
|
+
#### Mutual TLS (mTLS) client authentication
|
|
950
|
+
|
|
951
|
+
Some providers require OAuth requests (including the token request and subsequent API calls) to be sender‑constrained using mutual TLS (mTLS). With this gem, you enable mTLS by providing a client certificate/private key to Faraday via connection_opts.ssl and, if your provider requires it for client authentication, selecting the tls_client_auth auth_scheme.
|
|
952
|
+
|
|
953
|
+
Example using PEM files (certificate and key):
|
|
954
|
+
|
|
955
|
+
```ruby
|
|
956
|
+
require "oauth2"
|
|
957
|
+
require "openssl"
|
|
958
|
+
|
|
959
|
+
client = OAuth2::Client.new(
|
|
960
|
+
ENV.fetch("CLIENT_ID"),
|
|
961
|
+
ENV.fetch("CLIENT_SECRET"),
|
|
962
|
+
site: "https://example.com",
|
|
963
|
+
authorize_url: "/oauth/authorize/",
|
|
964
|
+
token_url: "/oauth/token/",
|
|
965
|
+
auth_scheme: :tls_client_auth, # if your AS requires mTLS-based client authentication
|
|
966
|
+
connection_opts: {
|
|
967
|
+
ssl: {
|
|
968
|
+
client_cert: OpenSSL::X509::Certificate.new(File.read("localhost.pem")),
|
|
969
|
+
client_key: OpenSSL::PKey::RSA.new(File.read("localhost-key.pem")),
|
|
970
|
+
# Optional extras, uncomment as needed:
|
|
971
|
+
# ca_file: "/path/to/ca-bundle.pem", # custom CA(s)
|
|
972
|
+
# verify: true # enable server cert verification (recommended)
|
|
973
|
+
},
|
|
974
|
+
},
|
|
975
|
+
)
|
|
976
|
+
|
|
977
|
+
# Example token request (any grant type can be used). The mTLS handshake
|
|
978
|
+
# will occur automatically on HTTPS calls using the configured cert/key.
|
|
979
|
+
access = client.client_credentials.get_token
|
|
980
|
+
|
|
981
|
+
# Subsequent resource requests will also use mTLS on HTTPS endpoints of `site`:
|
|
982
|
+
resp = access.get("/v1/protected")
|
|
983
|
+
```
|
|
984
|
+
|
|
985
|
+
Notes:
|
|
986
|
+
|
|
987
|
+
- Files must contain the appropriate PEMs. The private key may be encrypted; if so, pass a password to `OpenSSL::PKey::RSA.new(File.read(path), ENV["KEY_PASSWORD"])`.
|
|
988
|
+
- If your certificate and key are in a PKCS#12/PFX bundle, you can load them like:
|
|
989
|
+
- `p12 = OpenSSL::PKCS12.new(File.read("client.p12"), ENV["P12_PASSWORD"])`
|
|
990
|
+
- `client_cert = p12.certificate; client_key = p12.key`
|
|
991
|
+
- Server trust:
|
|
992
|
+
- If your environment does not have system CAs, specify `ca_file` or `ca_path` inside the `ssl:` hash.
|
|
993
|
+
- Keep `verify: true` in production. Set `verify: false` only for local testing.
|
|
994
|
+
- Faraday adapter: Any adapter that supports Ruby’s OpenSSL should work. `net_http` (default) and `net_http_persistent` are common choices.
|
|
995
|
+
- Scope of mTLS: The SSL client cert is applied to any HTTPS request made by this client (token and resource requests) to the configured site base URL (and absolute URLs you call with the same client).
|
|
996
|
+
- OIDC tie-in: Some OPs require tls_client_auth at the token endpoint per OIDC/OAuth specifications. That is enabled via `auth_scheme: :tls_client_auth` as shown above.
|
|
997
|
+
|
|
998
|
+
#### Authentication schemes for the token request
|
|
214
999
|
|
|
215
1000
|
```ruby
|
|
216
|
-
|
|
1001
|
+
OAuth2::Client.new(
|
|
1002
|
+
id,
|
|
1003
|
+
secret,
|
|
1004
|
+
site: "https://provider.example.com",
|
|
1005
|
+
auth_scheme: :basic_auth, # default. Alternatives: :request_body, :tls_client_auth, :private_key_jwt
|
|
1006
|
+
)
|
|
217
1007
|
```
|
|
218
1008
|
|
|
219
|
-
|
|
220
|
-
[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
|
1009
|
+
#### Faraday connection, timeouts, proxy, custom adapter/middleware:
|
|
221
1010
|
|
|
222
|
-
|
|
1011
|
+
```ruby
|
|
1012
|
+
client = OAuth2::Client.new(
|
|
1013
|
+
id,
|
|
1014
|
+
secret,
|
|
1015
|
+
site: "https://provider.example.com",
|
|
1016
|
+
connection_opts: {
|
|
1017
|
+
request: {open_timeout: 5, timeout: 15},
|
|
1018
|
+
proxy: ENV["HTTPS_PROXY"],
|
|
1019
|
+
ssl: {verify: true},
|
|
1020
|
+
},
|
|
1021
|
+
) do |faraday|
|
|
1022
|
+
faraday.request(:url_encoded)
|
|
1023
|
+
# faraday.response :logger, Logger.new($stdout) # see OAUTH_DEBUG below
|
|
1024
|
+
faraday.adapter(:net_http_persistent) # or any Faraday adapter you need
|
|
1025
|
+
end
|
|
1026
|
+
```
|
|
1027
|
+
|
|
1028
|
+
##### Using flat query params (`Faraday::FlatParamsEncoder`)
|
|
1029
|
+
|
|
1030
|
+
Some APIs expect repeated key parameters to be sent as flat params rather than arrays. Faraday provides `FlatParamsEncoder` for this purpose. You can configure the oauth2 client to use it when building requests.
|
|
1031
|
+
|
|
1032
|
+
```ruby
|
|
1033
|
+
require "faraday"
|
|
1034
|
+
|
|
1035
|
+
client = OAuth2::Client.new(
|
|
1036
|
+
id,
|
|
1037
|
+
secret,
|
|
1038
|
+
site: "https://api.example.com",
|
|
1039
|
+
# Pass Faraday connection options to make FlatParamsEncoder the default
|
|
1040
|
+
connection_opts: {
|
|
1041
|
+
request: {params_encoder: Faraday::FlatParamsEncoder},
|
|
1042
|
+
},
|
|
1043
|
+
) do |faraday|
|
|
1044
|
+
faraday.request(:url_encoded)
|
|
1045
|
+
faraday.adapter(:net_http)
|
|
1046
|
+
end
|
|
1047
|
+
|
|
1048
|
+
access = client.client_credentials.get_token
|
|
1049
|
+
|
|
1050
|
+
# Example of a GET with two flat filter params (not an array):
|
|
1051
|
+
# Results in: ?filter=order.clientCreatedTime%3E1445006997000&filter=order.clientCreatedTime%3C1445611797000
|
|
1052
|
+
resp = access.get(
|
|
1053
|
+
"/v1/orders",
|
|
1054
|
+
params: {
|
|
1055
|
+
# Provide the values as an array; FlatParamsEncoder expands them as repeated keys
|
|
1056
|
+
filter: [
|
|
1057
|
+
"order.clientCreatedTime>1445006997000",
|
|
1058
|
+
"order.clientCreatedTime<1445611797000",
|
|
1059
|
+
],
|
|
1060
|
+
},
|
|
1061
|
+
)
|
|
1062
|
+
```
|
|
1063
|
+
|
|
1064
|
+
If you instead need to build a raw Faraday connection yourself, the equivalent configuration is:
|
|
1065
|
+
|
|
1066
|
+
```ruby
|
|
1067
|
+
conn = Faraday.new("https://api.example.com", request: {params_encoder: Faraday::FlatParamsEncoder})
|
|
1068
|
+
```
|
|
1069
|
+
|
|
1070
|
+
#### Redirection
|
|
1071
|
+
|
|
1072
|
+
The library follows up to `max_redirects` (default 5).
|
|
1073
|
+
You can override per-client via `options[:max_redirects]`.
|
|
1074
|
+
|
|
1075
|
+
### Handling Responses and Errors
|
|
1076
|
+
|
|
1077
|
+
- Parsing:
|
|
1078
|
+
|
|
1079
|
+
```ruby
|
|
1080
|
+
resp = access.get("/v1/thing")
|
|
1081
|
+
resp.status # Integer
|
|
1082
|
+
resp.headers # Hash
|
|
1083
|
+
resp.body # String
|
|
1084
|
+
resp.parsed # SnakyHash::StringKeyed or Array when JSON array
|
|
1085
|
+
```
|
|
1086
|
+
|
|
1087
|
+
- Error handling:
|
|
1088
|
+
|
|
1089
|
+
```ruby
|
|
1090
|
+
begin
|
|
1091
|
+
access.get("/v1/forbidden")
|
|
1092
|
+
rescue OAuth2::Error => e
|
|
1093
|
+
e.code # OAuth2 error code (when present)
|
|
1094
|
+
e.description # OAuth2 error description (when present)
|
|
1095
|
+
e.response # OAuth2::Response (full access to status/headers/body)
|
|
1096
|
+
end
|
|
1097
|
+
```
|
|
1098
|
+
|
|
1099
|
+
- Disable raising on 4xx/5xx to inspect the response yourself:
|
|
1100
|
+
|
|
1101
|
+
```ruby
|
|
1102
|
+
client = OAuth2::Client.new(id, secret, site: site, raise_errors: false)
|
|
1103
|
+
res = client.request(:get, "/v1/maybe-errors")
|
|
1104
|
+
if res.status == 429
|
|
1105
|
+
sleep res.headers["retry-after"].to_i
|
|
1106
|
+
end
|
|
1107
|
+
```
|
|
1108
|
+
|
|
1109
|
+
### Making Raw Token Requests
|
|
1110
|
+
|
|
1111
|
+
If a provider requires non-standard parameters or headers, you can call `client.get_token` directly:
|
|
1112
|
+
|
|
1113
|
+
```ruby
|
|
1114
|
+
access = client.get_token({
|
|
1115
|
+
grant_type: "client_credentials",
|
|
1116
|
+
audience: "https://api.example.com",
|
|
1117
|
+
headers: {"X-Custom" => "value"},
|
|
1118
|
+
parse: :json, # override parsing
|
|
1119
|
+
})
|
|
1120
|
+
```
|
|
1121
|
+
|
|
1122
|
+
### OpenID Connect (OIDC)
|
|
1123
|
+
|
|
1124
|
+
- If the token response includes an `id_token` (a JWT), this gem surfaces it in `token.params['id_token']`.
|
|
1125
|
+
- **Note**: This gem does **not** validate the signature of the `id_token`. You must use a JWT library (like the `jwt` [gem](https://github.com/jwt/ruby-jwt)) and your provider's JWKs to verify it.
|
|
1126
|
+
- For `private_key_jwt` client authentication, provide `auth_scheme: :private_key_jwt` and ensure your key configuration matches the provider requirements.
|
|
1127
|
+
- See [OIDC.md](OIDC.md) for a more complete OIDC overview and examples.
|
|
1128
|
+
|
|
1129
|
+
### Debugging
|
|
1130
|
+
|
|
1131
|
+
- Set environment variable `OAUTH_DEBUG=true` to enable verbose Faraday logging (uses the client-provided logger).
|
|
1132
|
+
- To mirror a working curl request, ensure you set the same auth scheme, params, and content type. The Quick Example at the top shows a curl-to-ruby translation.
|
|
1133
|
+
|
|
1134
|
+
---
|
|
1135
|
+
|
|
1136
|
+
## 🦷 FLOSS Funding
|
|
1137
|
+
|
|
1138
|
+
While ruby-oauth tools are free software and will always be, the project would benefit immensely from some funding.
|
|
1139
|
+
Raising a monthly budget of... "dollars" would make the project more sustainable.
|
|
1140
|
+
|
|
1141
|
+
We welcome both individual and corporate sponsors! We also offer a
|
|
1142
|
+
wide array of funding channels to account for your preferences
|
|
1143
|
+
(although currently [Open Collective][🖇osc] is our preferred funding platform).
|
|
1144
|
+
|
|
1145
|
+
**If you're working in a company that's making significant use of ruby-oauth tools we'd
|
|
1146
|
+
appreciate it if you suggest to your company to become a ruby-oauth sponsor.**
|
|
223
1147
|
|
|
224
|
-
|
|
1148
|
+
You can support the development of ruby-oauth tools via
|
|
1149
|
+
[GitHub Sponsors][🖇sponsor],
|
|
1150
|
+
[Liberapay][⛳liberapay],
|
|
1151
|
+
[PayPal][🖇paypal],
|
|
1152
|
+
[Open Collective][🖇osc]
|
|
1153
|
+
and [Tidelift][🏙️entsup-tidelift].
|
|
225
1154
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
1155
|
+
| 📍 NOTE |
|
|
1156
|
+
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
1157
|
+
| If doing a sponsorship in the form of donation is problematic for your company <br/> from an accounting standpoint, we'd recommend the use of Tidelift, <br/> where you can get a support-like subscription instead. |
|
|
229
1158
|
|
|
230
|
-
|
|
1159
|
+
### Open Collective for Individuals
|
|
231
1160
|
|
|
232
|
-
[
|
|
233
|
-
[oauth-xx]: https://github.com/oauth-xx
|
|
234
|
-
[fossa2]: https://app.fossa.io/projects/git%2Bgithub.com%2Foauth-xx%2Foauth2?ref=badge_large
|
|
1161
|
+
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/ruby-oauth#backer)]
|
|
235
1162
|
|
|
236
|
-
|
|
1163
|
+
NOTE: [kettle-readme-backers][kettle-readme-backers] updates this list every day, automatically.
|
|
237
1164
|
|
|
238
|
-
|
|
1165
|
+
<!-- OPENCOLLECTIVE-INDIVIDUALS:START -->
|
|
1166
|
+
No backers yet. Be the first!
|
|
1167
|
+
<!-- OPENCOLLECTIVE-INDIVIDUALS:END -->
|
|
239
1168
|
|
|
240
|
-
|
|
1169
|
+
### Open Collective for Organizations
|
|
241
1170
|
|
|
242
|
-
|
|
1171
|
+
Become a sponsor and get your logo on our README on GitHub with a link to your site. [[Become a sponsor](https://opencollective.com/ruby-oauth#sponsor)]
|
|
243
1172
|
|
|
244
|
-
|
|
1173
|
+
NOTE: [kettle-readme-backers][kettle-readme-backers] updates this list every day, automatically.
|
|
245
1174
|
|
|
246
|
-
|
|
1175
|
+
<!-- OPENCOLLECTIVE-ORGANIZATIONS:START -->
|
|
1176
|
+
No sponsors yet. Be the first!
|
|
1177
|
+
|
|
1178
|
+
### Open Collective for Donors
|
|
1179
|
+
|
|
1180
|
+
[Bill Woika](https://opencollective.com/bill-woika)
|
|
1181
|
+
<!-- OPENCOLLECTIVE-ORGANIZATIONS:END -->
|
|
1182
|
+
|
|
1183
|
+
[kettle-readme-backers]: https://github.com/ruby-oauth/oauth2/blob/main/exe/kettle-readme-backers
|
|
1184
|
+
|
|
1185
|
+
### Another way to support open-source
|
|
1186
|
+
|
|
1187
|
+
I’m driven by a passion to foster a thriving open-source community – a space where people can tackle complex problems, no matter how small. Revitalizing libraries that have fallen into disrepair, and building new libraries focused on solving real-world challenges, are my passions. I was recently affected by layoffs, and the tech jobs market is unwelcoming. I’m reaching out here because your support would significantly aid my efforts to provide for my family, and my farm (11 🐔 chickens, 2 🐶 dogs, 3 🐰 rabbits, 8 🐈 cats).
|
|
1188
|
+
|
|
1189
|
+
If you work at a company that uses my work, please encourage them to support me as a corporate sponsor. My work on gems you use might show up in `bundle fund`.
|
|
1190
|
+
|
|
1191
|
+
I’m developing a new library, [floss_funding][🖇floss-funding-gem], designed to empower open-source developers like myself to get paid for the work we do, in a sustainable way. Please give it a look.
|
|
1192
|
+
|
|
1193
|
+
**[Floss-Funding.dev][🖇floss-funding.dev]: 👉️ No network calls. 👉️ No tracking. 👉️ No oversight. 👉️ Minimal crypto hashing. 💡 Easily disabled nags**
|
|
1194
|
+
|
|
1195
|
+
[![OpenCollective Backers][🖇osc-backers-i]][🖇osc-backers] [![OpenCollective Sponsors][🖇osc-sponsors-i]][🖇osc-sponsors] [![Sponsor Me on Github][🖇sponsor-img]][🖇sponsor] [![Liberapay Goal Progress][⛳liberapay-img]][⛳liberapay] [![Donate on PayPal][🖇paypal-img]][🖇paypal] [![Buy me a coffee][🖇buyme-small-img]][🖇buyme] [![Donate on Polar][🖇polar-img]][🖇polar] [![Donate to my FLOSS efforts at ko-fi.com][🖇kofi-img]][🖇kofi] [![Donate to my FLOSS efforts using Patreon][🖇patreon-img]][🖇patreon]
|
|
1196
|
+
|
|
1197
|
+
## 🔐 Security
|
|
1198
|
+
|
|
1199
|
+
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
|
|
1200
|
+
Tidelift will coordinate the fix and disclosure.
|
|
1201
|
+
|
|
1202
|
+
For more see [SECURITY.md][🔐security], [THREAT_MODEL.md][🔐threat-model], and [IRP.md][🔐irp].
|
|
1203
|
+
|
|
1204
|
+
## 🤝 Contributing
|
|
1205
|
+
|
|
1206
|
+
If you need some ideas of where to help, you could work on adding more code coverage,
|
|
1207
|
+
or if it is already 💯 (see [below](#code-coverage)) check [reek](REEK), [issues][🤝gh-issues], or [PRs][🤝gh-pulls],
|
|
1208
|
+
or use the gem and think about how it could be better.
|
|
1209
|
+
|
|
1210
|
+
We [![Keep A Changelog][📗keep-changelog-img]][📗keep-changelog] so if you make changes, remember to update it.
|
|
1211
|
+
|
|
1212
|
+
See [CONTRIBUTING.md][🤝contributing] for more detailed instructions.
|
|
1213
|
+
|
|
1214
|
+
### 🚀 Release Instructions
|
|
1215
|
+
|
|
1216
|
+
See [CONTRIBUTING.md][🤝contributing].
|
|
1217
|
+
|
|
1218
|
+
### Code Coverage
|
|
1219
|
+
|
|
1220
|
+
[![Coverage Graph][🏀codecov-g]][🏀codecov]
|
|
1221
|
+
|
|
1222
|
+
[![Coveralls Test Coverage][🏀coveralls-img]][🏀coveralls]
|
|
1223
|
+
|
|
1224
|
+
[![QLTY Test Coverage][🏀qlty-covi]][🏀qlty-cov]
|
|
1225
|
+
|
|
1226
|
+
### 🪇 Code of Conduct
|
|
1227
|
+
|
|
1228
|
+
Everyone interacting with this project's codebases, issue trackers,
|
|
1229
|
+
chat rooms and mailing lists agrees to follow the [![Contributor Covenant 2.1][🪇conduct-img]][🪇conduct].
|
|
1230
|
+
|
|
1231
|
+
## 🌈 Contributors
|
|
1232
|
+
|
|
1233
|
+
[![Contributors][🖐contributors-img]][🖐contributors]
|
|
1234
|
+
|
|
1235
|
+
Made with [contributors-img][🖐contrib-rocks].
|
|
1236
|
+
|
|
1237
|
+
Also see GitLab Contributors: [https://gitlab.com/ruby-oauth/oauth2/-/graphs/main][🚎contributors-gl]
|
|
1238
|
+
|
|
1239
|
+
<details>
|
|
1240
|
+
<summary>⭐️ Star History</summary>
|
|
1241
|
+
|
|
1242
|
+
<a href="https://star-history.com/#ruby-oauth/oauth2&Date">
|
|
1243
|
+
<picture>
|
|
1244
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=ruby-oauth/oauth2&type=Date&theme=dark" />
|
|
1245
|
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=ruby-oauth/oauth2&type=Date" />
|
|
1246
|
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=ruby-oauth/oauth2&type=Date" />
|
|
1247
|
+
</picture>
|
|
1248
|
+
</a>
|
|
1249
|
+
|
|
1250
|
+
</details>
|
|
1251
|
+
|
|
1252
|
+
## 📌 Versioning
|
|
1253
|
+
|
|
1254
|
+
This Library adheres to [![Semantic Versioning 2.0.0][📌semver-img]][📌semver].
|
|
1255
|
+
Violations of this scheme should be reported as bugs.
|
|
1256
|
+
Specifically, if a minor or patch version is released that breaks backward compatibility,
|
|
1257
|
+
a new version should be immediately released that restores compatibility.
|
|
1258
|
+
Breaking changes to the public API will only be introduced with new major versions.
|
|
1259
|
+
|
|
1260
|
+
> dropping support for a platform is both obviously and objectively a breaking change <br/>
|
|
1261
|
+
>—Jordan Harband ([@ljharb](https://github.com/ljharb), maintainer of SemVer) [in SemVer issue 716][📌semver-breaking]
|
|
1262
|
+
|
|
1263
|
+
I understand that policy doesn't work universally ("exceptions to every rule!"),
|
|
1264
|
+
but it is the policy here.
|
|
1265
|
+
As such, in many cases it is good to specify a dependency on this library using
|
|
1266
|
+
the [Pessimistic Version Constraint][📌pvc] with two digits of precision.
|
|
1267
|
+
|
|
1268
|
+
For example:
|
|
1269
|
+
|
|
1270
|
+
```ruby
|
|
1271
|
+
spec.add_dependency("oauth2", "~> 2.0")
|
|
1272
|
+
```
|
|
247
1273
|
|
|
248
|
-
|
|
1274
|
+
<details markdown="1">
|
|
1275
|
+
<summary>📌 Is "Platform Support" part of the public API? More details inside.</summary>
|
|
1276
|
+
|
|
1277
|
+
SemVer should, IMO, but doesn't explicitly, say that dropping support for specific Platforms
|
|
1278
|
+
is a *breaking change* to an API, and for that reason the bike shedding is endless.
|
|
1279
|
+
|
|
1280
|
+
To get a better understanding of how SemVer is intended to work over a project's lifetime,
|
|
1281
|
+
read this article from the creator of SemVer:
|
|
1282
|
+
|
|
1283
|
+
- ["Major Version Numbers are Not Sacred"][📌major-versions-not-sacred]
|
|
1284
|
+
|
|
1285
|
+
</details>
|
|
1286
|
+
|
|
1287
|
+
See [CHANGELOG.md][📌changelog] for a list of releases.
|
|
1288
|
+
|
|
1289
|
+
## 📄 License
|
|
1290
|
+
|
|
1291
|
+
The gem is available as open source under the terms of
|
|
1292
|
+
the [MIT License][📄license] [![License: MIT][📄license-img]][📄license-ref].
|
|
1293
|
+
See [LICENSE.txt][📄license] for the official [Copyright Notice][📄copyright-notice-explainer].
|
|
1294
|
+
|
|
1295
|
+
### © Copyright
|
|
1296
|
+
|
|
1297
|
+
<ul>
|
|
1298
|
+
<li>
|
|
1299
|
+
Copyright (c) 2017 – 2026 Peter H. Boling, of
|
|
1300
|
+
<a href="https://discord.gg/3qme4XHNKN">
|
|
1301
|
+
Galtzo.com
|
|
1302
|
+
<picture>
|
|
1303
|
+
<img src="https://logos.galtzo.com/assets/images/galtzo-floss/avatar-128px-blank.svg" alt="Galtzo.com Logo (Wordless) by Aboling0, CC BY-SA 4.0" width="24">
|
|
1304
|
+
</picture>
|
|
1305
|
+
</a>, and oauth2 contributors.
|
|
1306
|
+
</li>
|
|
1307
|
+
<li>
|
|
1308
|
+
Copyright (c) 2011 - 2013 Michael Bleigh and Intridea, Inc.
|
|
1309
|
+
</li>
|
|
1310
|
+
</ul>
|
|
1311
|
+
|
|
1312
|
+
## 🤑 A request for help
|
|
1313
|
+
|
|
1314
|
+
Maintainers have teeth and need to pay their dentists.
|
|
1315
|
+
After getting laid off in an RIF in March, and encountering difficulty finding a new one,
|
|
1316
|
+
I began spending most of my time building open source tools.
|
|
1317
|
+
I'm hoping to be able to pay for my kids' health insurance this month,
|
|
1318
|
+
so if you value the work I am doing, I need your support.
|
|
1319
|
+
Please consider sponsoring me or the project.
|
|
1320
|
+
|
|
1321
|
+
To join the community or get help 👇️ Join the Discord.
|
|
1322
|
+
|
|
1323
|
+
[![Live Chat on Discord][✉️discord-invite-img-ftb]][✉️discord-invite]
|
|
1324
|
+
|
|
1325
|
+
To say "thanks!" ☝️ Join the Discord or 👇️ send money.
|
|
1326
|
+
|
|
1327
|
+
[![Sponsor ruby-oauth/oauth2 on Open Source Collective][🖇osc-all-bottom-img]][🖇osc] 💌 [![Sponsor me on GitHub Sponsors][🖇sponsor-bottom-img]][🖇sponsor] 💌 [![Sponsor me on Liberapay][⛳liberapay-bottom-img]][⛳liberapay] 💌 [![Donate on PayPal][🖇paypal-bottom-img]][🖇paypal]
|
|
1328
|
+
|
|
1329
|
+
### Please give the project a star ⭐ ♥.
|
|
1330
|
+
|
|
1331
|
+
Thanks for RTFM. ☺️
|
|
1332
|
+
|
|
1333
|
+
[⛳liberapay-img]: https://img.shields.io/liberapay/goal/pboling.svg?logo=liberapay&color=a51611&style=flat
|
|
1334
|
+
[⛳liberapay-bottom-img]: https://img.shields.io/liberapay/goal/pboling.svg?style=for-the-badge&logo=liberapay&color=a51611
|
|
1335
|
+
[⛳liberapay]: https://liberapay.com/pboling/donate
|
|
1336
|
+
[🖇osc-all-img]: https://img.shields.io/opencollective/all/ruby-oauth
|
|
1337
|
+
[🖇osc-sponsors-img]: https://img.shields.io/opencollective/sponsors/ruby-oauth
|
|
1338
|
+
[🖇osc-backers-img]: https://img.shields.io/opencollective/backers/ruby-oauth
|
|
1339
|
+
[🖇osc-backers]: https://opencollective.com/ruby-oauth#backer
|
|
1340
|
+
[🖇osc-backers-i]: https://opencollective.com/ruby-oauth/backers/badge.svg?style=flat
|
|
1341
|
+
[🖇osc-sponsors]: https://opencollective.com/ruby-oauth#sponsor
|
|
1342
|
+
[🖇osc-sponsors-i]: https://opencollective.com/ruby-oauth/sponsors/badge.svg?style=flat
|
|
1343
|
+
[🖇osc-all-bottom-img]: https://img.shields.io/opencollective/all/ruby-oauth?style=for-the-badge
|
|
1344
|
+
[🖇osc-sponsors-bottom-img]: https://img.shields.io/opencollective/sponsors/ruby-oauth?style=for-the-badge
|
|
1345
|
+
[🖇osc-backers-bottom-img]: https://img.shields.io/opencollective/backers/ruby-oauth?style=for-the-badge
|
|
1346
|
+
[🖇osc]: https://opencollective.com/ruby-oauth
|
|
1347
|
+
[🖇sponsor-img]: https://img.shields.io/badge/Sponsor_Me!-pboling.svg?style=social&logo=github
|
|
1348
|
+
[🖇sponsor-bottom-img]: https://img.shields.io/badge/Sponsor_Me!-pboling-blue?style=for-the-badge&logo=github
|
|
1349
|
+
[🖇sponsor]: https://github.com/sponsors/pboling
|
|
1350
|
+
[🖇polar-img]: https://img.shields.io/badge/polar-donate-a51611.svg?style=flat
|
|
1351
|
+
[🖇polar]: https://polar.sh/pboling
|
|
1352
|
+
[🖇kofi-img]: https://img.shields.io/badge/ko--fi-%E2%9C%93-a51611.svg?style=flat
|
|
1353
|
+
[🖇kofi]: https://ko-fi.com/O5O86SNP4
|
|
1354
|
+
[🖇patreon-img]: https://img.shields.io/badge/patreon-donate-a51611.svg?style=flat
|
|
1355
|
+
[🖇patreon]: https://patreon.com/galtzo
|
|
1356
|
+
[🖇buyme-small-img]: https://img.shields.io/badge/buy_me_a_coffee-%E2%9C%93-a51611.svg?style=flat
|
|
1357
|
+
[🖇buyme-img]: https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20latte&emoji=&slug=pboling&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff
|
|
1358
|
+
[🖇buyme]: https://www.buymeacoffee.com/pboling
|
|
1359
|
+
[🖇paypal-img]: https://img.shields.io/badge/donate-paypal-a51611.svg?style=flat&logo=paypal
|
|
1360
|
+
[🖇paypal-bottom-img]: https://img.shields.io/badge/donate-paypal-a51611.svg?style=for-the-badge&logo=paypal&color=0A0A0A
|
|
1361
|
+
[🖇paypal]: https://www.paypal.com/paypalme/peterboling
|
|
1362
|
+
[🖇floss-funding.dev]: https://floss-funding.dev
|
|
1363
|
+
[🖇floss-funding-gem]: https://github.com/galtzo-floss/floss_funding
|
|
1364
|
+
[✉️discord-invite]: https://discord.gg/3qme4XHNKN
|
|
1365
|
+
[✉️discord-invite-img-ftb]: https://img.shields.io/discord/1373797679469170758?style=for-the-badge&logo=discord
|
|
1366
|
+
[✉️ruby-friends-img]: https://img.shields.io/badge/daily.dev-%F0%9F%92%8E_Ruby_Friends-0A0A0A?style=for-the-badge&logo=dailydotdev&logoColor=white
|
|
1367
|
+
[✉️ruby-friends]: https://app.daily.dev/squads/rubyfriends
|
|
1368
|
+
|
|
1369
|
+
[⛳gg-discussions]: https://groups.google.com/g/oauth-ruby
|
|
1370
|
+
[⛳gg-discussions-img]: https://img.shields.io/badge/google-group-0093D0.svg?style=for-the-badge&logo=google&logoColor=orange
|
|
1371
|
+
|
|
1372
|
+
[✇bundle-group-pattern]: https://gist.github.com/pboling/4564780
|
|
1373
|
+
[⛳️gem-namespace]: https://github.com/ruby-oauth/oauth2
|
|
1374
|
+
[⛳️namespace-img]: https://img.shields.io/badge/namespace-OAuth2-3C2D2D.svg?style=square&logo=ruby&logoColor=white
|
|
1375
|
+
[⛳️gem-name]: https://bestgems.org/gems/oauth2
|
|
1376
|
+
[⛳️name-img]: https://img.shields.io/badge/name-oauth2-3C2D2D.svg?style=square&logo=rubygems&logoColor=red
|
|
1377
|
+
[⛳️tag-img]: https://img.shields.io/github/tag/ruby-oauth/oauth2.svg
|
|
1378
|
+
[⛳️tag]: http://github.com/ruby-oauth/oauth2/releases
|
|
1379
|
+
[🚂maint-blog]: http://www.railsbling.com/tags/oauth2
|
|
1380
|
+
[🚂maint-blog-img]: https://img.shields.io/badge/blog-railsbling-0093D0.svg?style=for-the-badge&logo=rubyonrails&logoColor=orange
|
|
1381
|
+
[🚂maint-contact]: http://www.railsbling.com/contact
|
|
1382
|
+
[🚂maint-contact-img]: https://img.shields.io/badge/Contact-Maintainer-0093D0.svg?style=flat&logo=rubyonrails&logoColor=red
|
|
1383
|
+
[💖🖇linkedin]: http://www.linkedin.com/in/peterboling
|
|
1384
|
+
[💖🖇linkedin-img]: https://img.shields.io/badge/PeterBoling-LinkedIn-0B66C2?style=flat&logo=newjapanprowrestling
|
|
1385
|
+
[💖✌️wellfound]: https://wellfound.com/u/peter-boling
|
|
1386
|
+
[💖✌️wellfound-img]: https://img.shields.io/badge/peter--boling-orange?style=flat&logo=wellfound
|
|
1387
|
+
[💖💲crunchbase]: https://www.crunchbase.com/person/peter-boling
|
|
1388
|
+
[💖💲crunchbase-img]: https://img.shields.io/badge/peter--boling-purple?style=flat&logo=crunchbase
|
|
1389
|
+
[💖🐘ruby-mast]: https://ruby.social/@galtzo
|
|
1390
|
+
[💖🐘ruby-mast-img]: https://img.shields.io/mastodon/follow/109447111526622197?domain=https://ruby.social&style=flat&logo=mastodon&label=Ruby%20@galtzo
|
|
1391
|
+
[💖🦋bluesky]: https://bsky.app/profile/galtzo.com
|
|
1392
|
+
[💖🦋bluesky-img]: https://img.shields.io/badge/@galtzo.com-0285FF?style=flat&logo=bluesky&logoColor=white
|
|
1393
|
+
[💖🌳linktree]: https://linktr.ee/galtzo
|
|
1394
|
+
[💖🌳linktree-img]: https://img.shields.io/badge/galtzo-purple?style=flat&logo=linktree
|
|
1395
|
+
[💖💁🏼♂️devto]: https://dev.to/galtzo
|
|
1396
|
+
[💖💁🏼♂️devto-img]: https://img.shields.io/badge/dev.to-0A0A0A?style=flat&logo=devdotto&logoColor=white
|
|
1397
|
+
[💖💁🏼♂️aboutme]: https://about.me/peter.boling
|
|
1398
|
+
[💖💁🏼♂️aboutme-img]: https://img.shields.io/badge/about.me-0A0A0A?style=flat&logo=aboutme&logoColor=white
|
|
1399
|
+
[💖🧊berg]: https://codeberg.org/pboling
|
|
1400
|
+
[💖🐙hub]: https://github.org/pboling
|
|
1401
|
+
[💖🛖hut]: https://sr.ht/~galtzo/
|
|
1402
|
+
[💖🧪lab]: https://gitlab.com/pboling
|
|
1403
|
+
[👨🏼🏫expsup-upwork]: https://www.upwork.com/freelancers/~014942e9b056abdf86?mp_source=share
|
|
1404
|
+
[👨🏼🏫expsup-upwork-img]: https://img.shields.io/badge/UpWork-13544E?style=for-the-badge&logo=Upwork&logoColor=white
|
|
1405
|
+
[👨🏼🏫expsup-codementor]: https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github
|
|
1406
|
+
[👨🏼🏫expsup-codementor-img]: https://img.shields.io/badge/CodeMentor-Get_Help-1abc9c?style=for-the-badge&logo=CodeMentor&logoColor=white
|
|
1407
|
+
[🏙️entsup-tidelift]: https://tidelift.com/subscription/pkg/rubygems-oauth2?utm_source=rubygems-oauth2&utm_medium=referral&utm_campaign=readme
|
|
1408
|
+
[🏙️entsup-tidelift-img]: https://img.shields.io/badge/Tidelift_and_Sonar-Enterprise_Support-FD3456?style=for-the-badge&logo=sonar&logoColor=white
|
|
1409
|
+
[🏙️entsup-tidelift-sonar]: https://blog.tidelift.com/tidelift-joins-sonar
|
|
1410
|
+
[💁🏼♂️peterboling]: http://www.peterboling.com
|
|
1411
|
+
[🚂railsbling]: http://www.railsbling.com
|
|
1412
|
+
[📜src-gl-img]: https://img.shields.io/badge/GitLab-FBA326?style=for-the-badge&logo=Gitlab&logoColor=orange
|
|
1413
|
+
[📜src-gl]: https://gitlab.com/ruby-oauth/oauth2/
|
|
1414
|
+
[📜src-cb-img]: https://img.shields.io/badge/CodeBerg-4893CC?style=for-the-badge&logo=CodeBerg&logoColor=blue
|
|
1415
|
+
[📜src-cb]: https://codeberg.org/ruby-oauth/oauth2
|
|
1416
|
+
[📜src-gh-img]: https://img.shields.io/badge/GitHub-238636?style=for-the-badge&logo=Github&logoColor=green
|
|
1417
|
+
[📜src-gh]: https://github.com/ruby-oauth/oauth2
|
|
1418
|
+
[📜docs-cr-rd-img]: https://img.shields.io/badge/RubyDoc-Current_Release-943CD2?style=for-the-badge&logo=readthedocs&logoColor=white
|
|
1419
|
+
[📜docs-head-rd-img]: https://img.shields.io/badge/YARD_on_Galtzo.com-HEAD-943CD2?style=for-the-badge&logo=readthedocs&logoColor=white
|
|
1420
|
+
[📜gl-wiki]: https://gitlab.com/ruby-oauth/oauth2/-/wikis/home
|
|
1421
|
+
[📜gh-wiki]: https://github.com/ruby-oauth/oauth2/wiki
|
|
1422
|
+
[📜gl-wiki-img]: https://img.shields.io/badge/wiki-examples-943CD2.svg?style=for-the-badge&logo=gitlab&logoColor=white
|
|
1423
|
+
[📜gh-wiki-img]: https://img.shields.io/badge/wiki-examples-943CD2.svg?style=for-the-badge&logo=github&logoColor=white
|
|
1424
|
+
[👽dl-rank]: https://bestgems.org/gems/oauth2
|
|
1425
|
+
[👽dl-ranki]: https://img.shields.io/gem/rd/oauth2.svg
|
|
1426
|
+
[👽version]: https://bestgems.org/gems/oauth2
|
|
1427
|
+
[👽versioni]: https://img.shields.io/gem/v/oauth2.svg
|
|
1428
|
+
[🏀qlty-mnt]: https://qlty.sh/gh/ruby-oauth/projects/oauth2
|
|
1429
|
+
[🏀qlty-mnti]: https://qlty.sh/gh/ruby-oauth/projects/oauth2/maintainability.svg
|
|
1430
|
+
[🏀qlty-cov]: https://qlty.sh/gh/ruby-oauth/projects/oauth2/metrics/code?sort=coverageRating
|
|
1431
|
+
[🏀qlty-covi]: https://qlty.sh/gh/ruby-oauth/projects/oauth2/coverage.svg
|
|
1432
|
+
[🏀codecov]: https://codecov.io/gh/ruby-oauth/oauth2
|
|
1433
|
+
[🏀codecovi]: https://codecov.io/gh/ruby-oauth/oauth2/graph/badge.svg
|
|
1434
|
+
[🏀coveralls]: https://coveralls.io/github/ruby-oauth/oauth2?branch=main
|
|
1435
|
+
[🏀coveralls-img]: https://coveralls.io/repos/github/ruby-oauth/oauth2/badge.svg?branch=main
|
|
1436
|
+
[🖐codeQL]: https://github.com/ruby-oauth/oauth2/security/code-scanning
|
|
1437
|
+
[🖐codeQL-img]: https://github.com/ruby-oauth/oauth2/actions/workflows/codeql-analysis.yml/badge.svg
|
|
1438
|
+
[🚎1-an-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/ancient.yml
|
|
1439
|
+
[🚎1-an-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/ancient.yml/badge.svg
|
|
1440
|
+
[🚎2-cov-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/coverage.yml
|
|
1441
|
+
[🚎2-cov-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/coverage.yml/badge.svg
|
|
1442
|
+
[🚎3-hd-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/heads.yml
|
|
1443
|
+
[🚎3-hd-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/heads.yml/badge.svg
|
|
1444
|
+
[🚎4-lg-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/legacy.yml
|
|
1445
|
+
[🚎4-lg-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/legacy.yml/badge.svg
|
|
1446
|
+
[🚎5-st-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/style.yml
|
|
1447
|
+
[🚎5-st-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/style.yml/badge.svg
|
|
1448
|
+
[🚎6-s-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/supported.yml
|
|
1449
|
+
[🚎6-s-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/supported.yml/badge.svg
|
|
1450
|
+
[🚎7-us-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/unsupported.yml
|
|
1451
|
+
[🚎7-us-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/unsupported.yml/badge.svg
|
|
1452
|
+
[🚎8-ho-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/hoary.yml
|
|
1453
|
+
[🚎8-ho-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/hoary.yml/badge.svg
|
|
1454
|
+
[🚎10-j-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/jruby.yml
|
|
1455
|
+
[🚎10-j-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/jruby.yml/badge.svg
|
|
1456
|
+
[🚎11-c-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/current.yml
|
|
1457
|
+
[🚎11-c-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/current.yml/badge.svg
|
|
1458
|
+
[🚎12-crh-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/dep-heads.yml
|
|
1459
|
+
[🚎12-crh-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/dep-heads.yml/badge.svg
|
|
1460
|
+
[🚎13-cbs-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/caboose.yml
|
|
1461
|
+
[🚎13-cbs-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/caboose.yml/badge.svg
|
|
1462
|
+
[🚎13-🔒️-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/locked_deps.yml
|
|
1463
|
+
[🚎13-🔒️-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/locked_deps.yml/badge.svg
|
|
1464
|
+
[🚎14-🔓️-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/unlocked_deps.yml
|
|
1465
|
+
[🚎14-🔓️-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/unlocked_deps.yml/badge.svg
|
|
1466
|
+
[🚎15-🪪-wf]: https://github.com/ruby-oauth/oauth2/actions/workflows/license-eye.yml
|
|
1467
|
+
[🚎15-🪪-wfi]: https://github.com/ruby-oauth/oauth2/actions/workflows/license-eye.yml/badge.svg
|
|
1468
|
+
[💎ruby-2.2i]: https://img.shields.io/badge/Ruby-2.2_(%F0%9F%9A%ABCI)-AABBCC?style=for-the-badge&logo=ruby&logoColor=white
|
|
1469
|
+
[💎ruby-2.3i]: https://img.shields.io/badge/Ruby-2.3-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
|
|
1470
|
+
[💎ruby-2.4i]: https://img.shields.io/badge/Ruby-2.4-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
|
|
1471
|
+
[💎ruby-2.5i]: https://img.shields.io/badge/Ruby-2.5-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
|
|
1472
|
+
[💎ruby-2.6i]: https://img.shields.io/badge/Ruby-2.6-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
|
|
1473
|
+
[💎ruby-2.7i]: https://img.shields.io/badge/Ruby-2.7-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
|
|
1474
|
+
[💎ruby-3.0i]: https://img.shields.io/badge/Ruby-3.0-CC342D?style=for-the-badge&logo=ruby&logoColor=white
|
|
1475
|
+
[💎ruby-3.1i]: https://img.shields.io/badge/Ruby-3.1-CC342D?style=for-the-badge&logo=ruby&logoColor=white
|
|
1476
|
+
[💎ruby-3.2i]: https://img.shields.io/badge/Ruby-3.2-CC342D?style=for-the-badge&logo=ruby&logoColor=white
|
|
1477
|
+
[💎ruby-3.3i]: https://img.shields.io/badge/Ruby-3.3-CC342D?style=for-the-badge&logo=ruby&logoColor=white
|
|
1478
|
+
[💎ruby-c-i]: https://img.shields.io/badge/Ruby-current-CC342D?style=for-the-badge&logo=ruby&logoColor=green
|
|
1479
|
+
[💎ruby-headi]: https://img.shields.io/badge/Ruby-HEAD-CC342D?style=for-the-badge&logo=ruby&logoColor=blue
|
|
1480
|
+
[💎truby-22.3i]: https://img.shields.io/badge/Truffle_Ruby-22.3_(%F0%9F%9A%ABCI)-AABBCC?style=for-the-badge&logo=ruby&logoColor=pink
|
|
1481
|
+
[💎truby-23.0i]: https://img.shields.io/badge/Truffle_Ruby-23.0_(%F0%9F%9A%ABCI)-AABBCC?style=for-the-badge&logo=ruby&logoColor=pink
|
|
1482
|
+
[💎truby-23.1i]: https://img.shields.io/badge/Truffle_Ruby-23.1_(%F0%9F%9A%ABCI)-AABBCC?style=for-the-badge&logo=ruby&logoColor=pink
|
|
1483
|
+
[💎truby-c-i]: https://img.shields.io/badge/Truffle_Ruby-current-34BCB1?style=for-the-badge&logo=ruby&logoColor=green
|
|
1484
|
+
[💎truby-headi]: https://img.shields.io/badge/Truffle_Ruby-HEAD-34BCB1?style=for-the-badge&logo=ruby&logoColor=blue
|
|
1485
|
+
[💎jruby-9.1i]: https://img.shields.io/badge/JRuby-9.1_(%F0%9F%9A%ABCI)-AABBCC?style=for-the-badge&logo=ruby&logoColor=red
|
|
1486
|
+
[💎jruby-9.2i]: https://img.shields.io/badge/JRuby-9.2_(%F0%9F%9A%ABCI)-AABBCC?style=for-the-badge&logo=ruby&logoColor=red
|
|
1487
|
+
[💎jruby-9.3i]: https://img.shields.io/badge/JRuby-9.3_(%F0%9F%9A%ABCI)-AABBCC?style=for-the-badge&logo=ruby&logoColor=red
|
|
1488
|
+
[💎jruby-9.4i]: https://img.shields.io/badge/JRuby-9.4-FBE742?style=for-the-badge&logo=ruby&logoColor=red
|
|
1489
|
+
[💎jruby-c-i]: https://img.shields.io/badge/JRuby-current-FBE742?style=for-the-badge&logo=ruby&logoColor=green
|
|
1490
|
+
[💎jruby-headi]: https://img.shields.io/badge/JRuby-HEAD-FBE742?style=for-the-badge&logo=ruby&logoColor=blue
|
|
1491
|
+
[🤝gh-issues]: https://github.com/ruby-oauth/oauth2/issues
|
|
1492
|
+
[🤝gh-pulls]: https://github.com/ruby-oauth/oauth2/pulls
|
|
1493
|
+
[🤝gl-issues]: https://gitlab.com/ruby-oauth/oauth2/-/issues
|
|
1494
|
+
[🤝gl-pulls]: https://gitlab.com/ruby-oauth/oauth2/-/merge_requests
|
|
1495
|
+
[🤝cb-issues]: https://codeberg.org/ruby-oauth/oauth2/issues
|
|
1496
|
+
[🤝cb-pulls]: https://codeberg.org/ruby-oauth/oauth2/pulls
|
|
1497
|
+
[🤝cb-donate]: https://donate.codeberg.org/
|
|
1498
|
+
[🤝contributing]: CONTRIBUTING.md
|
|
1499
|
+
[🏀codecov-g]: https://codecov.io/gh/ruby-oauth/oauth2/graphs/tree.svg
|
|
1500
|
+
[🖐contrib-rocks]: https://contrib.rocks
|
|
1501
|
+
[🖐contributors]: https://github.com/ruby-oauth/oauth2/graphs/contributors
|
|
1502
|
+
[🖐contributors-img]: https://contrib.rocks/image?repo=ruby-oauth/oauth2
|
|
1503
|
+
[🚎contributors-gl]: https://gitlab.com/ruby-oauth/oauth2/-/graphs/main
|
|
1504
|
+
[🪇conduct]: CODE_OF_CONDUCT.md
|
|
1505
|
+
[🪇conduct-img]: https://img.shields.io/badge/Contributor_Covenant-2.1-259D6C.svg
|
|
1506
|
+
[📌pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
|
1507
|
+
[📌semver]: https://semver.org/spec/v2.0.0.html
|
|
1508
|
+
[📌semver-img]: https://img.shields.io/badge/semver-2.0.0-259D6C.svg?style=flat
|
|
1509
|
+
[📌semver-breaking]: https://github.com/semver/semver/issues/716#issuecomment-869336139
|
|
1510
|
+
[📌major-versions-not-sacred]: https://tom.preston-werner.com/2022/05/23/major-version-numbers-are-not-sacred.html
|
|
1511
|
+
[📌changelog]: CHANGELOG.md
|
|
1512
|
+
[📗keep-changelog]: https://keepachangelog.com/en/1.0.0/
|
|
1513
|
+
[📗keep-changelog-img]: https://img.shields.io/badge/keep--a--changelog-1.0.0-34495e.svg?style=flat
|
|
1514
|
+
[📌gitmoji]: https://gitmoji.dev
|
|
1515
|
+
[📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
|
|
1516
|
+
[🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
|
|
1517
|
+
[🧮kloc-img]: https://img.shields.io/badge/KLOC-0.527-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
|
|
1518
|
+
[🔐security]: SECURITY.md
|
|
1519
|
+
[🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
|
|
1520
|
+
[🔐irp]: IRP.md
|
|
1521
|
+
[🔐irp-img]: https://img.shields.io/badge/IRP-259D6C.svg?style=flat
|
|
1522
|
+
[🔐threat-model]: THREAT_MODEL.md
|
|
1523
|
+
[🔐threat-model-img]: https://img.shields.io/badge/threat-model-259D6C.svg?style=flat
|
|
1524
|
+
[📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
|
|
1525
|
+
[📄license]: LICENSE.txt
|
|
1526
|
+
[📄license-ref]: https://opensource.org/licenses/MIT
|
|
1527
|
+
[📄license-img]: https://img.shields.io/badge/License-MIT-259D6C.svg
|
|
1528
|
+
[📄license-compat]: https://dev.to/galtzo/how-to-check-license-compatibility-41h0
|
|
1529
|
+
[📄license-compat-img]: https://img.shields.io/badge/Apache_Compatible:_Category_A-%E2%9C%93-259D6C.svg?style=flat&logo=Apache
|
|
1530
|
+
[📄ilo-declaration]: https://www.ilo.org/declaration/lang--en/index.htm
|
|
1531
|
+
[📄ilo-declaration-img]: https://img.shields.io/badge/ILO_Fundamental_Principles-✓-259D6C.svg?style=flat
|
|
1532
|
+
[🚎yard-current]: http://rubydoc.info/gems/oauth2
|
|
1533
|
+
[🚎yard-head]: https://oauth2.galtzo.com
|
|
1534
|
+
[💎stone_checksums]: https://github.com/galtzo-floss/stone_checksums
|
|
1535
|
+
[💎SHA_checksums]: https://gitlab.com/ruby-oauth/oauth2/-/tree/main/checksums
|
|
1536
|
+
[💎rlts]: https://github.com/rubocop-lts/rubocop-lts
|
|
1537
|
+
[💎rlts-img]: https://img.shields.io/badge/code_style_&_linting-rubocop--lts-34495e.svg?plastic&logo=ruby&logoColor=white
|
|
1538
|
+
[💎appraisal2]: https://github.com/appraisal-rb/appraisal2
|
|
1539
|
+
[💎appraisal2-img]: https://img.shields.io/badge/appraised_by-appraisal2-34495e.svg?plastic&logo=ruby&logoColor=white
|
|
1540
|
+
[💎d-in-dvcs]: https://railsbling.com/posts/dvcs/put_the_d_in_dvcs/
|
|
1541
|
+
|
|
1542
|
+
<details>
|
|
1543
|
+
<summary>
|
|
1544
|
+
rel="me" Social Proofs
|
|
1545
|
+
</summary>
|
|
1546
|
+
|
|
1547
|
+
<a rel="me" alt="Follow me on Ruby.social" href="https://ruby.social/@galtzo"><img src="https://img.shields.io/mastodon/follow/109447111526622197?domain=https://ruby.social&style=social&label=Follow%20@galtzo%20on%20Ruby.social"></a>
|
|
1548
|
+
<a rel="me" alt="Follow me on FLOSS.social" href="https://floss.social/@galtzo"><img src="https://img.shields.io/mastodon/follow/110304921404405715?domain=https://floss.social&style=social&label=Follow%20@galtzo%20on%20Floss.social"></a>
|
|
1549
|
+
|
|
1550
|
+
</details>
|