From 30650b2e1cb743e3263181e8b8a32c57ef33b9fb Mon Sep 17 00:00:00 2001 From: autobolt Date: Wed, 20 May 2026 17:32:57 -0600 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=94=96=20Prepare=20release=20v2.0.20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 27 +- README.md | 2 +- REEK | 4 +- docs/OAuth2/AccessToken.html | 2 +- docs/OAuth2/Authenticator.html | 2 +- docs/OAuth2/Client.html | 4 +- docs/OAuth2/Error.html | 2 +- docs/OAuth2/Response.html | 2 +- docs/OAuth2/Strategy/Assertion.html | 2 +- docs/OAuth2/Strategy/AuthCode.html | 2 +- docs/OAuth2/Strategy/Base.html | 2 +- docs/OAuth2/Strategy/ClientCredentials.html | 358 ++++++++++++++++ docs/OAuth2/Strategy/Implicit.html | 435 -------------------- docs/class_list.html | 54 --- docs/file.CODE_OF_CONDUCT.html | 203 --------- docs/file.FUNDING.html | 111 ----- docs/file.LICENSE.html | 72 ---- docs/file.README.html | 24 +- docs/frames.html | 22 + docs/index.html | 24 +- docs/top-level-namespace.html | 112 +++++ 21 files changed, 550 insertions(+), 916 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2cb5d422..f39d1002e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,18 +20,33 @@ Please file a bug if you notice a violation of semantic versioning. ### Added -- OAuth2::VERSION (Traditional Constant Location) - ### Changed -- auth-sanitizer v0.1.3 - ### Deprecated ### Removed ### Fixed +### Security + +## [2.0.20] - 2026-05-20 + +- TAG: [v2.0.20][2.0.20t] +- COVERAGE: 99.62% -- 525/527 lines in 15 files +- BRANCH COVERAGE: 98.88% -- 176/178 branches in 15 files +- 88.35% documented + +### Added + +- OAuth2::VERSION (Traditional Constant Location) + +### Changed + +- auth-sanitizer v0.1.3 + +### Fixed + - [gh!721][gh!721] Load `auth-sanitizer` through an internal isolated loader so requiring `oauth2` does not add top-level `Auth` or `AuthSanitizer` constants that may collide with downstream applications by @pboling ### Security @@ -771,7 +786,9 @@ Please file a bug if you notice a violation of semantic versioning. [gemfiles/readme]: gemfiles/README.md -[Unreleased]: https://github.com/ruby-oauth/oauth2/compare/v2.0.19...HEAD +[Unreleased]: https://github.com/ruby-oauth/oauth2/compare/v2.0.20...HEAD +[2.0.20]: https://github.com/ruby-oauth/oauth2/compare/v2.0.19...v2.0.20 +[2.0.20t]: https://github.com/ruby-oauth/oauth2/releases/tag/v2.0.20 [2.0.19]: https://github.com/ruby-oauth/oauth2/compare/v2.0.18...v2.0.19 [2.0.19t]: https://github.com/ruby-oauth/oauth2/releases/tag/v2.0.19 [2.0.18]: https://github.com/ruby-oauth/oauth2/compare/v2.0.17...v2.0.18 diff --git a/README.md b/README.md index d067f9a00..1a5f2e5b5 100644 --- a/README.md +++ b/README.md @@ -1514,7 +1514,7 @@ Thanks for RTFM. ☺️ [📌gitmoji]: https://gitmoji.dev [📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ -[🧮kloc-img]: https://img.shields.io/badge/KLOC-0.515-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue +[🧮kloc-img]: https://img.shields.io/badge/KLOC-0.527-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue [🔐security]: SECURITY.md [🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat [🔐irp]: IRP.md diff --git a/REEK b/REEK index c0f05d1fe..b1eff8cb8 100644 --- a/REEK +++ b/REEK @@ -1,2 +1,2 @@ -./reek: 1: Error:: not found -./reek: 2: Error:: not found +./reek: 1: ./reek:: not found +./reek: 2: ./reek:: not found diff --git a/docs/OAuth2/AccessToken.html b/docs/OAuth2/AccessToken.html index e79bd4c9c..1a2d8bd2b 100644 --- a/docs/OAuth2/AccessToken.html +++ b/docs/OAuth2/AccessToken.html @@ -3072,7 +3072,7 @@

diff --git a/docs/OAuth2/Authenticator.html b/docs/OAuth2/Authenticator.html index a7265c850..8e518d42a 100644 --- a/docs/OAuth2/Authenticator.html +++ b/docs/OAuth2/Authenticator.html @@ -878,7 +878,7 @@

diff --git a/docs/OAuth2/Client.html b/docs/OAuth2/Client.html index 59619d587..c72177527 100644 --- a/docs/OAuth2/Client.html +++ b/docs/OAuth2/Client.html @@ -855,7 +855,7 @@

- —

Logger instance for HTTP request/response output; requires OAUTH_DEBUG to be true. When debug logging is enabled, sensitive values are filtered using Auth::Sanitizer::SanitizedLogger initialized from OAuth2.config[:filtered_label] and the key names in OAuth2.config[:filtered_debug_keys].

+ —

Logger instance for HTTP request/response output; requires OAUTH_DEBUG to be true. When debug logging is enabled, sensitive values are filtered using OAuth2::AUTH_SANITIZER::SanitizedLogger initialized from OAuth2.config[:filtered_label] and the key names in OAuth2.config[:filtered_debug_keys].

@@ -2650,7 +2650,7 @@

diff --git a/docs/OAuth2/Error.html b/docs/OAuth2/Error.html index a2d313db4..6784dfa13 100644 --- a/docs/OAuth2/Error.html +++ b/docs/OAuth2/Error.html @@ -780,7 +780,7 @@

diff --git a/docs/OAuth2/Response.html b/docs/OAuth2/Response.html index 29eee59e3..ffebee10c 100644 --- a/docs/OAuth2/Response.html +++ b/docs/OAuth2/Response.html @@ -1624,7 +1624,7 @@

diff --git a/docs/OAuth2/Strategy/Assertion.html b/docs/OAuth2/Strategy/Assertion.html index 7b822ac78..b8e662c03 100644 --- a/docs/OAuth2/Strategy/Assertion.html +++ b/docs/OAuth2/Strategy/Assertion.html @@ -486,7 +486,7 @@

diff --git a/docs/OAuth2/Strategy/AuthCode.html b/docs/OAuth2/Strategy/AuthCode.html index deef1c9a4..87181d160 100644 --- a/docs/OAuth2/Strategy/AuthCode.html +++ b/docs/OAuth2/Strategy/AuthCode.html @@ -488,7 +488,7 @@

diff --git a/docs/OAuth2/Strategy/Base.html b/docs/OAuth2/Strategy/Base.html index df6c6ad3e..c44353a40 100644 --- a/docs/OAuth2/Strategy/Base.html +++ b/docs/OAuth2/Strategy/Base.html @@ -199,7 +199,7 @@

diff --git a/docs/OAuth2/Strategy/ClientCredentials.html b/docs/OAuth2/Strategy/ClientCredentials.html index e69de29bb..7a6c86727 100644 --- a/docs/OAuth2/Strategy/ClientCredentials.html +++ b/docs/OAuth2/Strategy/ClientCredentials.html @@ -0,0 +1,358 @@ + + + + + + + Class: OAuth2::Strategy::ClientCredentials + + — Documentation by YARD 0.9.43 + + + + + + + + + + + + + + + + + + + + + +
+ + +

Class: OAuth2::Strategy::ClientCredentials + + + +

+
+ +
+
Inherits:
+
+ Base + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/oauth2/strategy/client_credentials.rb +
+
+ +
+ +

Overview

+
+

The Client Credentials Strategy

+ + +
+
+ + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + + + +

Methods inherited from Base

+

#initialize

+
+

Constructor Details

+ +

This class inherits a constructor from OAuth2::Strategy::Base

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #authorize_url ⇒ Object + + + + + +

+
+

Not used for this strategy

+ + +
+
+
+ +

Raises:

+
    + +
  • + + + (NotImplementedError) + + + +
  • + +
+ +
+ + + + +
+
+
+
+12
+13
+14
+
+
# File 'lib/oauth2/strategy/client_credentials.rb', line 12
+
+def authorize_url
+  raise(NotImplementedError, "The authorization endpoint is not used in this strategy")
+end
+
+
+ +
+

+ + #get_token(params = {}, opts = {}) ⇒ Object + + + + + +

+
+

Retrieve an access token given the specified client.

+ + +
+
+
+

Parameters:

+
    + +
  • + + params + + + (Hash) + + + (defaults to: {}) + + + — +

    additional params

    +
    + +
  • + +
  • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +

    options

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+20
+21
+22
+23
+
+
# File 'lib/oauth2/strategy/client_credentials.rb', line 20
+
+def get_token(params = {}, opts = {})
+  params = params.merge("grant_type" => "client_credentials")
+  @client.get_token(params, opts)
+end
+
+
+ +
+ +
+ + + +
+ + diff --git a/docs/OAuth2/Strategy/Implicit.html b/docs/OAuth2/Strategy/Implicit.html index 05c0fa79b..e69de29bb 100644 --- a/docs/OAuth2/Strategy/Implicit.html +++ b/docs/OAuth2/Strategy/Implicit.html @@ -1,435 +0,0 @@ - - - - - - - Class: OAuth2::Strategy::Implicit - - — Documentation by YARD 0.9.43 - - - - - - - - - - - - - - - - - - - - - -
- - -

Class: OAuth2::Strategy::Implicit - - - -

-
- -
-
Inherits:
-
- Base - -
    -
  • Object
  • - - - - - -
- show all - -
-
- - - - - - - - - - - -
-
Defined in:
-
lib/oauth2/strategy/implicit.rb -
-
- -
- -

Overview

-
-

The Implicit Strategy

- -

IMPORTANT (OAuth 2.1): The Implicit grant (response_type=token) is omitted from the OAuth 2.1 draft specification.
-It remains here for backward compatibility with OAuth 2.0 providers. Prefer the Authorization Code flow with PKCE.

- -

References:

-
    -
  • OAuth 2.1 draft: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13
  • -
  • Why drop implicit: https://aaronparecki.com/2019/12/12/21/its-time-for-oauth-2-dot-1
  • -
  • Background: https://fusionauth.io/learn/expert-advice/oauth/differences-between-oauth-2-oauth-2-1/
  • -
- - -
-
- - - - - - - - -

- Instance Method Summary - collapse -

- - - - - - - - - - - - - - - -

Methods inherited from Base

-

#initialize

-
-

Constructor Details

- -

This class inherits a constructor from OAuth2::Strategy::Base

- -
- - -
-

Instance Method Details

- - -
-

- - #authorize_params(params = {}) ⇒ Object - - - - - -

-
-

The required query parameters for the authorize URL

- - -
-
-
-

Parameters:

-
    - -
  • - - params - - - (Hash) - - - (defaults to: {}) - - - — -

    additional query parameters

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-20
-21
-22
-
-
# File 'lib/oauth2/strategy/implicit.rb', line 20
-
-def authorize_params(params = {})
-  params.merge("response_type" => "token", "client_id" => @client.id)
-end
-
-
- -
-

- - #authorize_url(params = {}) ⇒ Object - - - - - -

-
-

The authorization URL endpoint of the provider

- - -
-
-
-

Parameters:

-
    - -
  • - - params - - - (Hash) - - - (defaults to: {}) - - - — -

    additional query parameters for the URL

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-27
-28
-29
-30
-
-
# File 'lib/oauth2/strategy/implicit.rb', line 27
-
-def authorize_url(params = {})
-  assert_valid_params(params)
-  @client.authorize_url(authorize_params.merge(params))
-end
-
-
- -
-

- - #get_token ⇒ Object - - - - - -

-
-

Not used for this strategy

- - -
-
-
- -

Raises:

-
    - -
  • - - - (NotImplementedError) - - - -
  • - -
- -
- - - - -
-
-
-
-35
-36
-37
-
-
# File 'lib/oauth2/strategy/implicit.rb', line 35
-
-def get_token(*)
-  raise(NotImplementedError, "The token is accessed differently in this strategy")
-end
-
-
- -
- -
- - - -
- - diff --git a/docs/class_list.html b/docs/class_list.html index f21d031f4..e69de29bb 100644 --- a/docs/class_list.html +++ b/docs/class_list.html @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - Class List - - - -
-
-

Class List

- - - -
- - -
- - diff --git a/docs/file.CODE_OF_CONDUCT.html b/docs/file.CODE_OF_CONDUCT.html index 7e2636616..e69de29bb 100644 --- a/docs/file.CODE_OF_CONDUCT.html +++ b/docs/file.CODE_OF_CONDUCT.html @@ -1,203 +0,0 @@ - - - - - - - File: CODE_OF_CONDUCT - - — Documentation by YARD 0.9.43 - - - - - - - - - - - - - - - - - - - - - -
- - -

Contributor Covenant Code of Conduct

- -

Our Pledge

- -

We as members, contributors, and leaders pledge to make participation in our
-community a harassment-free experience for everyone, regardless of age, body
-size, visible or invisible disability, ethnicity, sex characteristics, gender
-identity and expression, level of experience, education, socio-economic status,
-nationality, personal appearance, race, caste, color, religion, or sexual
-identity and orientation.

- -

We pledge to act and interact in ways that contribute to an open, welcoming,
-diverse, inclusive, and healthy community.

- -

Our Standards

- -

Examples of behavior that contributes to a positive environment for our
-community include:

- -
    -
  • Demonstrating empathy and kindness toward other people
  • -
  • Being respectful of differing opinions, viewpoints, and experiences
  • -
  • Giving and gracefully accepting constructive feedback
  • -
  • Accepting responsibility and apologizing to those affected by our mistakes,
    -and learning from the experience
  • -
  • Focusing on what is best not just for us as individuals, but for the overall
    -community
  • -
- -

Examples of unacceptable behavior include:

- -
    -
  • The use of sexualized language or imagery, and sexual attention or advances of
    -any kind
  • -
  • Trolling, insulting or derogatory comments, and personal or political attacks
  • -
  • Public or private harassment
  • -
  • Publishing others’ private information, such as a physical or email address,
    -without their explicit permission
  • -
  • Other conduct which could reasonably be considered inappropriate in a
    -professional setting
  • -
- -

Enforcement Responsibilities

- -

Community leaders are responsible for clarifying and enforcing our standards of
-acceptable behavior and will take appropriate and fair corrective action in
-response to any behavior that they deem inappropriate, threatening, offensive,
-or harmful.

- -

Community leaders have the right and responsibility to remove, edit, or reject
-comments, commits, code, wiki edits, issues, and other contributions that are
-not aligned to this Code of Conduct, and will communicate reasons for moderation
-decisions when appropriate.

- -

Scope

- -

This Code of Conduct applies within all community spaces, and also applies when
-an individual is officially representing the community in public spaces.
-Examples of representing our community include using an official email address,
-posting via an official social media account, or acting as an appointed
-representative at an online or offline event.

- -

Enforcement

- -

Instances of abusive, harassing, or otherwise unacceptable behavior may be
-reported to the community leaders responsible for enforcement at
-Contact Maintainer.
-All complaints will be reviewed and investigated promptly and fairly.

- -

All community leaders are obligated to respect the privacy and security of the
-reporter of any incident.

- -

Enforcement Guidelines

- -

Community leaders will follow these Community Impact Guidelines in determining
-the consequences for any action they deem in violation of this Code of Conduct:

- -

1. Correction

- -

Community Impact: Use of inappropriate language or other behavior deemed
-unprofessional or unwelcome in the community.

- -

Consequence: A private, written warning from community leaders, providing
-clarity around the nature of the violation and an explanation of why the
-behavior was inappropriate. A public apology may be requested.

- -

2. Warning

- -

Community Impact: A violation through a single incident or series of
-actions.

- -

Consequence: A warning with consequences for continued behavior. No
-interaction with the people involved, including unsolicited interaction with
-those enforcing the Code of Conduct, for a specified period of time. This
-includes avoiding interactions in community spaces as well as external channels
-like social media. Violating these terms may lead to a temporary or permanent
-ban.

- -

3. Temporary Ban

- -

Community Impact: A serious violation of community standards, including
-sustained inappropriate behavior.

- -

Consequence: A temporary ban from any sort of interaction or public
-communication with the community for a specified period of time. No public or
-private interaction with the people involved, including unsolicited interaction
-with those enforcing the Code of Conduct, is allowed during this period.
-Violating these terms may lead to a permanent ban.

- -

4. Permanent Ban

- -

Community Impact: Demonstrating a pattern of violation of community
-standards, including sustained inappropriate behavior, harassment of an
-individual, or aggression toward or disparagement of classes of individuals.

- -

Consequence: A permanent ban from any sort of public interaction within the
-community.

- -

Attribution

- -

This Code of Conduct is adapted from the Contributor Covenant,
-version 2.1, available at
-https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.

- -

Community Impact Guidelines were inspired by
-Mozilla’s code of conduct enforcement ladder.

- -

For answers to common questions about this code of conduct, see the FAQ at
-https://www.contributor-covenant.org/faq. Translations are available at
-https://www.contributor-covenant.org/translations.

- -
- - - -
- - diff --git a/docs/file.FUNDING.html b/docs/file.FUNDING.html index 58b76bd86..e69de29bb 100644 --- a/docs/file.FUNDING.html +++ b/docs/file.FUNDING.html @@ -1,111 +0,0 @@ - - - - - - - File: FUNDING - - — Documentation by YARD 0.9.43 - - - - - - - - - - - - - - - - - - - - - -
- - -
- -

Official Discord 👉️ Live Chat on Discord

- -

Many paths lead to being a sponsor or a backer of this project. Are you on such a path?

- -

OpenCollective Backers OpenCollective Sponsors Sponsor Me on Github Liberapay Goal Progress Donate on PayPal

- -

Buy me a coffee Donate on Polar Donate to my FLOSS efforts at ko-fi.com Donate to my FLOSS efforts using Patreon

- - - -

🤑 A request for help

- -

Maintainers have teeth and need to pay their dentists.
-After getting laid off in an RIF in March, and encountering difficulty finding a new one,
-I began spending most of my time building open source tools.
-I’m hoping to be able to pay for my kids’ health insurance this month,
-so if you value the work I am doing, I need your support.
-Please consider sponsoring me or the project.

- -

To join the community or get help 👇️ Join the Discord.

- -

Live Chat on Discord

- -

To say “thanks!” ☝️ Join the Discord or 👇️ send money.

- -

Sponsor ruby-oauth/oauth2 on Open Source Collective 💌 Sponsor me on GitHub Sponsors 💌 Sponsor me on Liberapay 💌 Donate on PayPal

- -

Another Way to Support Open Source Software

- -

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).

- -

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.

- -

I’m developing a new library, floss_funding, 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.

- -

Floss-Funding.dev: 👉️ No network calls. 👉️ No tracking. 👉️ No oversight. 👉️ Minimal crypto hashing. 💡 Easily disabled nags

- -
- - - -
- - diff --git a/docs/file.LICENSE.html b/docs/file.LICENSE.html index 20d63855b..e69de29bb 100644 --- a/docs/file.LICENSE.html +++ b/docs/file.LICENSE.html @@ -1,72 +0,0 @@ - - - - - - - File: LICENSE - - — Documentation by YARD 0.9.43 - - - - - - - - - - - - - - - - - - - - - -
- - -
MIT License

Copyright (c) 2017-2026 Peter H. Boling, of Galtzo.com, and oauth2 contributors
Copyright (c) 2011-2013 Michael Bleigh and Intridea, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- - - -
- - diff --git a/docs/file.README.html b/docs/file.README.html index 87348675f..f21694884 100644 --- a/docs/file.README.html +++ b/docs/file.README.html @@ -273,7 +273,7 @@

💡 Info you can shake a stick at

Compliance -License: MIT Compatible with Apache Software Projects: Verified by SkyWalking Eyes 📄ilo-declaration-img Security Policy Contributor Covenant 2.1 SemVer 2.0.0 +License: MIT Compatible with Apache Software Projects: Verified by SkyWalking Eyes 📄ilo-declaration-img Security Policy Contributor Covenant 2.1 SemVer 2.0.0 @@ -577,7 +577,7 @@

Compatibility

NOTE: The 1.4 series will only receive critical security updates.
-See SECURITY.md and IRP.md.

+See SECURITY.md and IRP.md.

⚙️ Configuration

@@ -1458,7 +1458,7 @@

OpenID Connect (OIDC)

  • Note: This gem does not validate the signature of the id_token. You must use a JWT library (like the jwt gem) and your provider’s JWKs to verify it.
  • For private_key_jwt client authentication, provide auth_scheme: :private_key_jwt and ensure your key configuration matches the provider requirements.
  • -
  • See OIDC.md for a more complete OIDC overview and examples.
  • +
  • See OIDC.md for a more complete OIDC overview and examples.
  • Debugging

    @@ -1543,21 +1543,21 @@

    🔐 Security

    To report a security vulnerability, please use the Tidelift security contact.
    Tidelift will coordinate the fix and disclosure.

    -

    For more see SECURITY.md, THREAT_MODEL.md, and IRP.md.

    +

    For more see SECURITY.md, THREAT_MODEL.md, and IRP.md.

    🤝 Contributing

    If you need some ideas of where to help, you could work on adding more code coverage,
    -or if it is already 💯 (see below) check reek, issues, or PRs,
    +or if it is already 💯 (see below) check reek, issues, or PRs,
    or use the gem and think about how it could be better.

    We Keep A Changelog so if you make changes, remember to update it.

    -

    See CONTRIBUTING.md for more detailed instructions.

    +

    See CONTRIBUTING.md for more detailed instructions.

    🚀 Release Instructions

    -

    See CONTRIBUTING.md.

    +

    See CONTRIBUTING.md.

    Code Coverage

    @@ -1570,7 +1570,7 @@

    Code Coverage

    🪇 Code of Conduct

    Everyone interacting with this project’s codebases, issue trackers,
    -chat rooms and mailing lists agrees to follow the Contributor Covenant 2.1.

    +chat rooms and mailing lists agrees to follow the Contributor Covenant 2.1.

    🌈 Contributors

    @@ -1631,13 +1631,13 @@

    📌 Versioning

    -

    See CHANGELOG.md for a list of releases.

    +

    See CHANGELOG.md for a list of releases.

    📄 License

    The gem is available as open source under the terms of
    -the MIT License License: MIT.
    -See LICENSE.txt for the official Copyright Notice.

    +the MIT License License: MIT.
    +See LICENSE.txt for the official Copyright Notice.

    @@ -1689,7 +1689,7 @@

    Please give the project a star ⭐ ♥ diff --git a/docs/frames.html b/docs/frames.html index e69de29bb..5dd6a469f 100644 --- a/docs/frames.html +++ b/docs/frames.html @@ -0,0 +1,22 @@ + + + + + Documentation by YARD 0.9.43 + + + + diff --git a/docs/index.html b/docs/index.html index 2d564f28b..bf7c248fd 100644 --- a/docs/index.html +++ b/docs/index.html @@ -273,7 +273,7 @@

    💡 Info you can shake a stick at

    Compliance -License: MIT Compatible with Apache Software Projects: Verified by SkyWalking Eyes 📄ilo-declaration-img Security Policy Contributor Covenant 2.1 SemVer 2.0.0 +License: MIT Compatible with Apache Software Projects: Verified by SkyWalking Eyes 📄ilo-declaration-img Security Policy Contributor Covenant 2.1 SemVer 2.0.0 @@ -577,7 +577,7 @@

    Compatibility

    NOTE: The 1.4 series will only receive critical security updates.
    -See SECURITY.md and IRP.md.

    +See SECURITY.md and IRP.md.

    ⚙️ Configuration

    @@ -1458,7 +1458,7 @@

    OpenID Connect (OIDC)

  • Note: This gem does not validate the signature of the id_token. You must use a JWT library (like the jwt gem) and your provider’s JWKs to verify it.
  • For private_key_jwt client authentication, provide auth_scheme: :private_key_jwt and ensure your key configuration matches the provider requirements.
  • -
  • See OIDC.md for a more complete OIDC overview and examples.
  • +
  • See OIDC.md for a more complete OIDC overview and examples.
  • Debugging

    @@ -1543,21 +1543,21 @@

    🔐 Security

    To report a security vulnerability, please use the Tidelift security contact.
    Tidelift will coordinate the fix and disclosure.

    -

    For more see SECURITY.md, THREAT_MODEL.md, and IRP.md.

    +

    For more see SECURITY.md, THREAT_MODEL.md, and IRP.md.

    🤝 Contributing

    If you need some ideas of where to help, you could work on adding more code coverage,
    -or if it is already 💯 (see below) check reek, issues, or PRs,
    +or if it is already 💯 (see below) check reek, issues, or PRs,
    or use the gem and think about how it could be better.

    We Keep A Changelog so if you make changes, remember to update it.

    -

    See CONTRIBUTING.md for more detailed instructions.

    +

    See CONTRIBUTING.md for more detailed instructions.

    🚀 Release Instructions

    -

    See CONTRIBUTING.md.

    +

    See CONTRIBUTING.md.

    Code Coverage

    @@ -1570,7 +1570,7 @@

    Code Coverage

    🪇 Code of Conduct

    Everyone interacting with this project’s codebases, issue trackers,
    -chat rooms and mailing lists agrees to follow the Contributor Covenant 2.1.

    +chat rooms and mailing lists agrees to follow the Contributor Covenant 2.1.

    🌈 Contributors

    @@ -1631,13 +1631,13 @@

    📌 Versioning

    -

    See CHANGELOG.md for a list of releases.

    +

    See CHANGELOG.md for a list of releases.

    📄 License

    The gem is available as open source under the terms of
    -the MIT License License: MIT.
    -See LICENSE.txt for the official Copyright Notice.

    +the MIT License License: MIT.
    +See LICENSE.txt for the official Copyright Notice.

    @@ -1689,7 +1689,7 @@

    Please give the project a star ⭐ ♥ diff --git a/docs/top-level-namespace.html b/docs/top-level-namespace.html index e69de29bb..49b5047ac 100644 --- a/docs/top-level-namespace.html +++ b/docs/top-level-namespace.html @@ -0,0 +1,112 @@ + + + + + + + Top Level Namespace + + — Documentation by YARD 0.9.43 + + + + + + + + + + + + + + + + + + + + + +
    + + +

    Top Level Namespace + + + +

    +
    + + + + + + + + + + + +
    + +

    Defined Under Namespace

    +

    + + + Modules: OAuth2 + + + + +

    + + + + + + + + + +
    + + + +
    + + From e2d509705db6091c8d5f27c31e29c58e39e51c7c Mon Sep 17 00:00:00 2001 From: autobolt Date: Wed, 20 May 2026 18:13:37 -0600 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A7=20:nocov:=20for=20unreachable?= =?UTF-8?q?=20error=20states?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/OAuth2/Authenticator.html | 888 ---------- docs/OAuth2/Strategy/Base.html | 209 --- docs/OAuth2/Strategy/ClientCredentials.html | 358 ---- docs/file.README.html | 1699 ------------------- docs/file.REEK.html | 74 - docs/top-level-namespace.html | 112 -- lib/oauth2/auth_sanitizer.rb | 4 + 7 files changed, 4 insertions(+), 3340 deletions(-) diff --git a/docs/OAuth2/Authenticator.html b/docs/OAuth2/Authenticator.html index 8e518d42a..e69de29bb 100644 --- a/docs/OAuth2/Authenticator.html +++ b/docs/OAuth2/Authenticator.html @@ -1,888 +0,0 @@ - - - - - - - Class: OAuth2::Authenticator - - — Documentation by YARD 0.9.43 - - - - - - - - - - - - - - - - - - - - - -
    - - -

    Class: OAuth2::Authenticator - - - -

    -
    - -
    -
    Inherits:
    -
    - Object - -
      -
    • Object
    • - - - -
    - show all - -
    -
    - - - - - - -
    -
    Includes:
    -
    FilteredAttributes
    -
    - - - - - - -
    -
    Defined in:
    -
    lib/oauth2/authenticator.rb -
    -
    - -
    - -

    Overview

    -
    -

    Builds and applies client authentication to token and revoke requests.

    - -

    Depending on the selected mode, credentials are applied as Basic Auth
    -headers, request body parameters, or only the client_id is sent (TLS).

    - - -
    -
    -
    - - -
    - - - -

    Instance Attribute Summary collapse

    - - - - - - -

    - Class Method Summary - collapse -

    - - - - -

    - Instance Method Summary - collapse -

    - - - - - - -
    -

    Constructor Details

    - -
    -

    - - #initialize(id, secret, mode) ⇒ Authenticator - - - - - -

    -
    -

    Create a new Authenticator

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - id - - - (String, nil) - - - - — -

      Client identifier

      -
      - -
    • - -
    • - - secret - - - (String, nil) - - - - — -

      Client secret

      -
      - -
    • - -
    • - - mode - - - (Symbol, String) - - - - — -

      Authentication mode

      -
      - -
    • - -
    - - -
    - - - - -
    -
    -
    -
    -24
    -25
    -26
    -27
    -28
    -
    -
    # File 'lib/oauth2/authenticator.rb', line 24
    -
    -def initialize(id, secret, mode)
    -  @id = id
    -  @secret = secret
    -  @mode = mode
    -end
    -
    -
    - -
    - -
    -

    Instance Attribute Details

    - - - -
    -

    - - #id ⇒ Symbol, ... (readonly) - - - - - -

    -
    - - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Symbol, String) - - - - — -

      Authentication mode (e.g., :basic_auth, :request_body, :tls_client_auth, :private_key_jwt)

      -
      - -
    • - -
    • - - - (String, nil) - - - - — -

      Client identifier

      -
      - -
    • - -
    • - - - (String, nil) - - - - — -

      Client secret (filtered in inspected output)

      -
      - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -16
    -17
    -18
    -
    -
    # File 'lib/oauth2/authenticator.rb', line 16
    -
    -def id
    -  @id
    -end
    -
    -
    - - - -
    -

    - - #mode ⇒ Symbol, ... (readonly) - - - - - -

    -
    - - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Symbol, String) - - - - — -

      Authentication mode (e.g., :basic_auth, :request_body, :tls_client_auth, :private_key_jwt)

      -
      - -
    • - -
    • - - - (String, nil) - - - - — -

      Client identifier

      -
      - -
    • - -
    • - - - (String, nil) - - - - — -

      Client secret (filtered in inspected output)

      -
      - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -16
    -17
    -18
    -
    -
    # File 'lib/oauth2/authenticator.rb', line 16
    -
    -def mode
    -  @mode
    -end
    -
    -
    - - - -
    -

    - - #secret ⇒ Symbol, ... (readonly) - - - - - -

    -
    - - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Symbol, String) - - - - — -

      Authentication mode (e.g., :basic_auth, :request_body, :tls_client_auth, :private_key_jwt)

      -
      - -
    • - -
    • - - - (String, nil) - - - - — -

      Client identifier

      -
      - -
    • - -
    • - - - (String, nil) - - - - — -

      Client secret (filtered in inspected output)

      -
      - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -16
    -17
    -18
    -
    -
    # File 'lib/oauth2/authenticator.rb', line 16
    -
    -def secret
    -  @secret
    -end
    -
    -
    - -
    - - -
    -

    Class Method Details

    - - -
    -

    - - .encode_basic_auth(user, password) ⇒ String - - - - - -

    -
    -

    Encodes a Basic Authorization header value for the provided credentials.

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - user - - - (String) - - - - — -

      The client identifier

      -
      - -
    • - -
    • - - password - - - (String) - - - - — -

      The client secret

      -
      - -
    • - -
    - -

    Returns:

    -
      - -
    • - - - (String) - - - - — -

      The value to use for the Authorization header

      -
      - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -60
    -61
    -62
    -
    -
    # File 'lib/oauth2/authenticator.rb', line 60
    -
    -def encode_basic_auth(user, password)
    -  "Basic #{Base64.strict_encode64("#{user}:#{password}")}"
    -end
    -
    -
    - -
    - -
    -

    Instance Method Details

    - - -
    -

    - - #apply(params) ⇒ Hash - - - - - -

    -
    -

    Apply the request credentials used to authenticate to the Authorization Server

    - -

    Depending on the configuration, this might be as request params or as an
    -Authorization header.

    - -

    User-provided params and header take precedence.

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - params - - - (Hash) - - - - — -

      a Hash of params for the token endpoint

      -
      - -
    • - -
    - -

    Returns:

    -
      - -
    • - - - (Hash) - - - - — -

      params amended with appropriate authentication details

      -
      - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -39
    -40
    -41
    -42
    -43
    -44
    -45
    -46
    -47
    -48
    -49
    -50
    -51
    -52
    -
    -
    # File 'lib/oauth2/authenticator.rb', line 39
    -
    -def apply(params)
    -  case mode.to_sym
    -  when :basic_auth
    -    apply_basic_auth(params)
    -  when :request_body
    -    apply_params_auth(params)
    -  when :tls_client_auth
    -    apply_client_id(params)
    -  when :private_key_jwt
    -    params
    -  else
    -    raise NotImplementedError
    -  end
    -end
    -
    -
    - -
    - -
    - - - -
    - - diff --git a/docs/OAuth2/Strategy/Base.html b/docs/OAuth2/Strategy/Base.html index c44353a40..e69de29bb 100644 --- a/docs/OAuth2/Strategy/Base.html +++ b/docs/OAuth2/Strategy/Base.html @@ -1,209 +0,0 @@ - - - - - - - Class: OAuth2::Strategy::Base - - — Documentation by YARD 0.9.43 - - - - - - - - - - - - - - - - - - - - - -
    - - -

    Class: OAuth2::Strategy::Base - - - -

    -
    - -
    -
    Inherits:
    -
    - Object - -
      -
    • Object
    • - - - -
    - show all - -
    -
    - - - - - - - - - - - -
    -
    Defined in:
    -
    lib/oauth2/strategy/base.rb -
    -
    - -
    - -
    -

    Direct Known Subclasses

    -

    Assertion, AuthCode, ClientCredentials, Implicit, Password

    -
    - - - - - - - - -

    - Instance Method Summary - collapse -

    - - - - - -
    -

    Constructor Details

    - -
    -

    - - #initialize(client) ⇒ Base - - - - - -

    -
    -

    Returns a new instance of Base.

    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -6
    -7
    -8
    -
    -
    # File 'lib/oauth2/strategy/base.rb', line 6
    -
    -def initialize(client)
    -  @client = client
    -end
    -
    -
    - -
    - - -
    - - - -
    - - diff --git a/docs/OAuth2/Strategy/ClientCredentials.html b/docs/OAuth2/Strategy/ClientCredentials.html index 7a6c86727..e69de29bb 100644 --- a/docs/OAuth2/Strategy/ClientCredentials.html +++ b/docs/OAuth2/Strategy/ClientCredentials.html @@ -1,358 +0,0 @@ - - - - - - - Class: OAuth2::Strategy::ClientCredentials - - — Documentation by YARD 0.9.43 - - - - - - - - - - - - - - - - - - - - - -
    - - -

    Class: OAuth2::Strategy::ClientCredentials - - - -

    -
    - -
    -
    Inherits:
    -
    - Base - -
      -
    • Object
    • - - - - - -
    - show all - -
    -
    - - - - - - - - - - - -
    -
    Defined in:
    -
    lib/oauth2/strategy/client_credentials.rb -
    -
    - -
    - -

    Overview

    -
    -

    The Client Credentials Strategy

    - - -
    -
    - - - - - - - - -

    - Instance Method Summary - collapse -

    - - - - - - - - - - - - - - - -

    Methods inherited from Base

    -

    #initialize

    -
    -

    Constructor Details

    - -

    This class inherits a constructor from OAuth2::Strategy::Base

    - -
    - - -
    -

    Instance Method Details

    - - -
    -

    - - #authorize_url ⇒ Object - - - - - -

    -
    -

    Not used for this strategy

    - - -
    -
    -
    - -

    Raises:

    -
      - -
    • - - - (NotImplementedError) - - - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -12
    -13
    -14
    -
    -
    # File 'lib/oauth2/strategy/client_credentials.rb', line 12
    -
    -def authorize_url
    -  raise(NotImplementedError, "The authorization endpoint is not used in this strategy")
    -end
    -
    -
    - -
    -

    - - #get_token(params = {}, opts = {}) ⇒ Object - - - - - -

    -
    -

    Retrieve an access token given the specified client.

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - params - - - (Hash) - - - (defaults to: {}) - - - — -

      additional params

      -
      - -
    • - -
    • - - opts - - - (Hash) - - - (defaults to: {}) - - - — -

      options

      -
      - -
    • - -
    - - -
    - - - - -
    -
    -
    -
    -20
    -21
    -22
    -23
    -
    -
    # File 'lib/oauth2/strategy/client_credentials.rb', line 20
    -
    -def get_token(params = {}, opts = {})
    -  params = params.merge("grant_type" => "client_credentials")
    -  @client.get_token(params, opts)
    -end
    -
    -
    - -
    - -
    - - - -
    - - diff --git a/docs/file.README.html b/docs/file.README.html index f21694884..e69de29bb 100644 --- a/docs/file.README.html +++ b/docs/file.README.html @@ -1,1699 +0,0 @@ - - - - - - - File: README - - — Documentation by YARD 0.9.43 - - - - - - - - - - - - - - - - - - - - - -
    - - -

    Galtzo FLOSS Logo by Aboling0, CC BY-SA 4.0 ruby-lang Logo, Yukihiro Matsumoto, Ruby Visual Identity Team, CC BY-SA 2.5 oauth2 Logo by Chris Messina, CC BY-SA 3.0

    - -

    🔐 OAuth 2.0 Authorization Framework

    - -

    Version GitHub tag (latest SemVer) License: MIT Downloads Rank CodeCov Test Coverage Coveralls Test Coverage QLTY Test Coverage QLTY Maintainability CI Heads CI Runtime Dependencies @ HEAD CI Current CI JRuby Deps Locked Deps Unlocked CI Supported CI Legacy CI Unsupported CI Ancient CI Test Coverage CI Style CodeQL Apache SkyWalking Eyes License Compatibility Check

    - -

    if ci_badges.map(&:color).detect { it != "green"} ☝️ let me know, as I may have missed the discord notification.

    - -
    - -

    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.

    - -

    OpenCollective Backers OpenCollective Sponsors Sponsor Me on Github Liberapay Goal Progress Donate on PayPal Buy me a coffee Donate on Polar Donate at ko-fi.com

    - -
    - 👣 How will this project approach the September 2025 hostile takeover of RubyGems? 🚑️ - -I've summarized my thoughts in [this blog post](https://dev.to/galtzo/hostile-takeover-of-rubygems-my-thoughts-5hlo). - -
    - -

    🌻 Synopsis

    - -

    OAuth 2.0 is the industry-standard protocol for authorization.
    -This is a RubyGem for implementing OAuth 2.0 clients (not servers) in Ruby applications.

    - -

    ⭐️ including OAuth 2.1 draft spec & OpenID Connect (OIDC)

    - -

    Quick Examples

    - -
    - Convert the following `curl` command into a token request using this gem... - -
    curl --request POST \
    -  --url 'https://login.microsoftonline.com/REDMOND_REDACTED/oauth2/token' \
    -  --header 'content-type: application/x-www-form-urlencoded' \
    -  --data grant_type=client_credentials \
    -  --data client_id=REDMOND_CLIENT_ID \
    -  --data client_secret=REDMOND_CLIENT_SECRET \
    -  --data resource=REDMOND_RESOURCE_UUID
    -
    - -

    NOTE: In the ruby version below, certain params are passed to the get_token call, instead of the client creation.

    - -
    client = OAuth2::Client.new(
    -  "REDMOND_CLIENT_ID", # client_id
    -  "REDMOND_CLIENT_SECRET", # client_secret
    -  auth_scheme: :request_body, # Other modes are supported: :basic_auth, :tls_client_auth, :private_key_jwt
    -  token_url: "oauth2/token", # relative path, except with leading `/`, then absolute path
    -  site: "https://login.microsoftonline.com/REDMOND_REDACTED",
    -)
    -client.
    -  client_credentials. # There are many other types to choose from!
    -  get_token(resource: "REDMOND_RESOURCE_UUID")
    -
    - -

    NOTE: header - The content type specified in the curl is already the default!

    - -
    - -
    - Complete E2E single file script against mock-oauth2-server - -
      -
    • E2E example uses navikt/mock-oauth2-server, which was added in v2.0.11
    • -
    • E2E example does not ship with the released gem, so clone the source to play with it.
    • -
    - -
    docker compose -f docker-compose-ssl.yml up -d --wait
    -ruby examples/e2e.rb
    -# If your machine is slow or Docker pulls are cold, increase the wait:
    -E2E_WAIT_TIMEOUT=120 ruby examples/e2e.rb
    -# The mock server serves HTTP on 8080; the example points to http://localhost:8080 by default.
    -
    - -

    The output should be something like this:

    - -
    ➜  ruby examples/e2e.rb
    -Access token (truncated): eyJraWQiOiJkZWZhdWx0...
    -userinfo status: 200
    -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"}
    -E2E complete
    -
    - -

    Make sure to shut down the mock server when you are done:

    - -
    docker compose -f docker-compose-ssl.yml down
    -
    - -

    Troubleshooting: validate connectivity to the mock server

    - -
      -
    • Check container status and port mapping: -
        -
      • docker compose -f docker-compose-ssl.yml ps
      • -
      -
    • -
    • From the host, try the discovery URL directly (this is what the example uses by default): -
        -
      • curl -v http://localhost:8080/default/.well-known/openid-configuration
      • -
      • If that fails immediately, also try: curl -v --connect-timeout 2 http://127.0.0.1:8080/default/.well-known/openid-configuration -
      • -
      -
    • -
    • From inside the container (to distinguish container vs. host networking): -
        -
      • docker exec -it oauth2-mock-oauth2-server-1 curl -v http://127.0.0.1:8080/default/.well-known/openid-configuration
      • -
      -
    • -
    • Simple TCP probe from the host: -
        -
      • nc -vz localhost 8080 # or: ruby -rsocket -e 'TCPSocket.new("localhost",8080).close; puts "tcp ok"'
      • -
      -
    • -
    • Inspect which host port 8080 is bound to (should be 8080): -
        -
      • docker inspect -f '{{ (index (index .NetworkSettings.Ports "8080/tcp") 0).HostPort }}' oauth2-mock-oauth2-server-1
      • -
      -
    • -
    • Look at server logs for readiness/errors: -
        -
      • docker logs -n 200 oauth2-mock-oauth2-server-1
      • -
      -
    • -
    • On Linux, ensure nothing else is bound to 8080 and that firewall/SELinux aren’t blocking: -
        -
      • ss -ltnp | grep :8080
      • -
      -
    • -
    - -

    Notes

    - -
      -
    • Discovery URL pattern is: http://localhost:8080/<realm>/.well-known/openid-configuration, where <realm> defaults to default.
    • -
    • You can change these with env vars when running the example: -
        -
      • -E2E_ISSUER_BASE (default: http://localhost:8080)
      • -
      • -E2E_REALM (default: default)
      • -
      -
    • -
    - -
    - -

    If it seems like you are in the wrong place, you might try one of these:

    - - - -

    💡 Info you can shake a stick at

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Tokens to Remember -Gem name Gem namespace -
    Works with JRuby -JRuby 9.1 Compat JRuby 9.2 Compat JRuby 9.3 Compat
    JRuby 9.4 Compat JRuby 10.0 Compat JRuby HEAD Compat -
    Works with Truffle Ruby -Truffle Ruby 22.3 Compat Truffle Ruby 23.0 Compat Truffle Ruby 23.1 Compat
    Truffle Ruby 24.1 Compat -
    Works with MRI Ruby 3 -Ruby 3.0 Compat Ruby 3.1 Compat Ruby 3.2 Compat Ruby 3.3 Compat Ruby 3.4 Compat Ruby HEAD Compat -
    Works with MRI Ruby 2 -Ruby 2.2 Compat
    Ruby 2.3 Compat Ruby 2.4 Compat Ruby 2.5 Compat Ruby 2.6 Compat Ruby 2.7 Compat -
    Support & Community -Join Me on Daily.dev's RubyFriends Live Chat on Discord Get help from me on Upwork Get help from me on Codementor -
    Source -Source on GitLab.com Source on CodeBerg.org Source on Github.com The best SHA: dQw4w9WgXcQ! -
    Documentation -Current release on RubyDoc.info YARD on Galtzo.com Maintainer Blog GitLab Wiki GitHub Wiki -
    Compliance -License: MIT Compatible with Apache Software Projects: Verified by SkyWalking Eyes 📄ilo-declaration-img Security Policy Contributor Covenant 2.1 SemVer 2.0.0 -
    Style -Enforced Code Style Linter Keep-A-Changelog 1.0.0 Gitmoji Commits Compatibility appraised by: appraisal2 -
    Maintainer 🎖️ -Follow Me on LinkedIn Follow Me on Ruby.Social Follow Me on Bluesky Contact Maintainer My technical writing -
    -... 💖 -Find Me on WellFound: Find Me on CrunchBase My LinkTree More About Me 🧊 🐙 🛖 🧪 -
    - -

    Compatibility

    - -

    Compatible with MRI Ruby 2.2.0+, and concordant releases of JRuby, and TruffleRuby.

    - - - - - - - - - - - - - - -
    🚚 Amazing test matrix was brought to you by🔎 appraisal2 🔎 and the color 💚 green 💚
    👟 Check it out!✨ github.com/appraisal-rb/appraisal2 ✨
    - -

    Federated DVCS

    - -
    - Find this repo on federated forges (Coming soon!) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Federated DVCS RepositoryStatusIssuesPRsWikiCIDiscussions
    🧪 ruby-oauth/oauth2 on GitLab -The Truth💚💚💚🐭 Tiny Matrix➖
    🧊 ruby-oauth/oauth2 on CodeBerg -An Ethical Mirror (Donate)💚💚➖⭕️ No Matrix➖
    🐙 ruby-oauth/oauth2 on GitHub -Another Mirror💚💚💚💯 Full Matrix💚
    🎮️ Discord Server -Live Chat on DiscordLet’stalkaboutthislibrary!
    - -
    - -

    Enterprise Support Tidelift -

    - -

    Available as part of the Tidelift Subscription.

    - -
    - Need enterprise-level guarantees? - -

    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.

    - -

    Get help from me on Tidelift

    - -
      -
    • 💡Subscribe for support guarantees covering all your FLOSS dependencies
    • -
    • 💡Tidelift is part of Sonar -
    • -
    • 💡Tidelift pays maintainers to maintain the software you depend on!
      📊@Pointy Haired Boss: An enterprise support subscription is “never gonna let you down”, and supports open source maintainers
    • -
    - -

    Alternatively:

    - -
      -
    • Live Chat on Discord
    • -
    • Get help from me on Upwork
    • -
    • Get help from me on Codementor
    • -
    - -
    - -

    ✨ Installation

    - -

    Install the gem and add to the application’s Gemfile by executing:

    - -
    bundle add oauth2
    -
    - -

    If bundler is not being used to manage dependencies, install the gem by executing:

    - -
    gem install oauth2
    -
    - -

    🔒 Secure Installation

    - -
    - For Medium or High Security Installations - -

    This gem is cryptographically signed, and has verifiable SHA-256 and SHA-512 checksums by -stone_checksums. Be sure the gem you install hasn’t been tampered with -by following the instructions below.

    - -

    Add my public key (if you haven’t already, expires 2045-04-29) as a trusted certificate:

    - -
    gem cert --add <(curl -Ls https://raw.github.com/galtzo-floss/certs/main/pboling.pem)
    -
    - -

    You only need to do that once. Then proceed to install with:

    - -
    gem install oauth2 -P MediumSecurity
    -
    - -

    The MediumSecurity trust profile will verify signed gems, but allow the installation of unsigned dependencies.

    - -

    This is necessary because not all of oauth2’s dependencies are signed, so we cannot use HighSecurity.

    - -

    If you want to up your security game full-time:

    - -
    bundle config set --global trust-policy MediumSecurity
    -
    - -

    MediumSecurity instead of HighSecurity is necessary if not all the gems you use are signed.

    - -

    NOTE: Be prepared to track down certs for signed gems and add them the same way you added mine.

    - -
    - -

    What is new for v2.0?

    - -
      -
    • Works with Ruby versions >= 2.2
    • -
    • Drop support for the expired MAC Draft (all versions)
    • -
    • Support IETF rfc7515 JSON Web Signature - JWS (since v2.0.12) -
        -
      • Support JWT kid for key discovery and management
      • -
      -
    • -
    • Support IETF rfc7523 JWT Bearer Tokens (since v2.0.0)
    • -
    • Support IETF rfc7231 Relative Location in Redirect (since v2.0.0)
    • -
    • Support IETF rfc6749 Don’t set oauth params when nil (since v2.0.0)
    • -
    • Support IETF rfc7009 Token Revocation (since v2.0.10, updated in v2.0.13 to support revocation via URL-encoded parameters)
    • -
    • Support OIDC 1.0 Private Key JWT; based on the OAuth JWT assertion specification (RFC 7523) -
    • -
    • Support new formats, including from jsonapi.org: application/vdn.api+json, application/vnd.collection+json, application/hal+json, application/problem+json -
    • -
    • Adds option to OAuth2::Client#get_token: -
        -
      • -:access_token_class (AccessToken); user specified class to use for all calls to get_token -
      • -
      -
    • -
    • Adds option to OAuth2::AccessToken#initialize: -
        -
      • -:expires_latency (nil); number of seconds by which AccessToken validity will be reduced to offset latency
      • -
      -
    • -
    • By default, keys are transformed to snake case. -
        -
      • Original keys will still work as previously, in most scenarios, thanks to snaky_hash gem.
      • -
      • 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.
      • -
      • As of version 2.0.4 you can turn key transformation off with the snaky: false option.
      • -
      -
    • -
    • By default, the :auth_scheme is now :basic_auth (instead of :request_body) -
        -
      • Third-party strategies and gems may need to be updated if a provider was requiring client id/secret in the request body
      • -
      -
    • -
    • … A lot more
    • -
    - -

    Compatibility

    - -

    Targeted ruby compatibility is non-EOL versions of Ruby, currently 3.2, 3.3, and 3.4.
    -Compatibility is further distinguished as “Best Effort Support” or “Incidental Support” for older versions of Ruby.
    -This gem will install on Ruby versions >= v2.2 for 2.x releases.
    -See 1-4-stable branch for older rubies.

    - -
    - Ruby Engine Compatibility Policy - -

    This gem is tested against MRI, JRuby, and Truffleruby. -Each of those has varying versions that target a specific version of MRI Ruby. -This gem should work in the just-listed Ruby engines according to the targeted MRI compatibility in the table below. -If you would like to add support for additional engines, -see gemfiles/README.md, then submit a PR to the correct maintenance branch as according to the table below.

    - -
    - -
    - Ruby Version Compatibility Policy - -

    If something doesn’t work on one of these interpreters, it’s a bug.

    - -

    This library may inadvertently work (or seem to work) on other Ruby -implementations; however, support will only be provided for the versions listed -above.

    - -

    If you would like this library to support another Ruby version, you may -volunteer to be a maintainer. Being a maintainer entails making sure all tests -run and pass on that implementation. When something breaks on your -implementation, you will be responsible for providing patches in a timely -fashion. If critical issues for a particular implementation exist at the time -of a major release, support for that Ruby version may be dropped.

    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     Ruby OAuth2 VersionMaintenance BranchTargeted SupportBest Effort SupportIncidental Support
    1️⃣2.0.xmain3.2, 3.3, 3.42.5, 2.6, 2.7, 3.0, 3.12.2, 2.3, 2.4
    2️⃣1.4.x1-4-stable3.2, 3.3, 3.42.5, 2.6, 2.7, 3.0, 3.11.9, 2.0, 2.1, 2.2, 2.3, 2.4
    3️⃣olderN/ABest of luck to you!Please upgrade! 
    - -

    NOTE: The 1.4 series will only receive critical security updates.
    -See SECURITY.md and IRP.md.

    - -

    ⚙️ Configuration

    - -

    Global settings for the library:

    - -
    OAuth2.configure do |config|
    -  config.silence_extra_tokens_warning = false # default: true
    -  config.silence_no_tokens_warning = false    # default: true
    -end
    -
    - -

    Filtering-related settings:

    - -
    OAuth2.configure do |config|
    -  config.filtered_label = "[REDACTED]" # default: "[FILTERED]"
    -  config.filtered_debug_keys += ["client_assertion"]
    -end
    -
    - -
      -
    • -filtered_label controls the placeholder used when sensitive values are filtered from inspected objects and debug logging output.
    • -
    • -filtered_debug_keys controls which key names have their values redacted from debug logging output when OAUTH_DEBUG=true.
    • -
    • Debug logging remains opt-in and should still be used cautiously in production environments.
    • -
    - -

    🔧 Basic Usage

    - -

    Client Initialization Options

    - -

    OAuth2::Client.new accepts several options:

    - -
      -
    • -:site: The base URL for the OAuth 2.0 provider.
    • -
    • -:authorize_url: The authorization endpoint (default: "oauth/authorize").
    • -
    • -:token_url: The token endpoint (default: "oauth/token").
    • -
    • -:auth_scheme: The authentication scheme (:basic_auth, :request_body, :tls_client_auth, :private_key_jwt). Default is :basic_auth.
    • -
    • -:connection_opts: Options for the underlying Faraday connection (timeouts, proxy, etc.).
    • -
    • -:raise_errors: Whether to raise OAuth2::Error on 400+ responses (default: true).
    • -
    - -
    - authorize_url and token_url - -

    -authorize_url and token_url are on site root (Just Works!)

    - -
    require "oauth2"
    -client = OAuth2::Client.new("client_id", "client_secret", site: "https://example.org")
    -# => #<OAuth2::Client:0x00000001204c8288 @id="client_id", @secret="client_sec...
    -client.auth_code.authorize_url(redirect_uri: "http://localhost:8080/oauth2/callback")
    -# => "https://example.org/oauth/authorize?client_id=client_id&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Foauth2%2Fcallback&response_type=code"
    -
    -access = client.auth_code.get_token("authorization_code_value", redirect_uri: "http://localhost:8080/oauth2/callback", headers: {"Authorization" => "Basic some_password"})
    -response = access.get("/api/resource", params: {"query_foo" => "bar"})
    -response.class.name
    -# => OAuth2::Response
    -
    - -

    Relative authorize_url and token_url (Not on site root, Just Works!)

    - -

    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.

    - -
    client = OAuth2::Client.new("client_id", "client_secret", site: "https://example.org/nested/directory/on/your/server")
    -# => #<OAuth2::Client:0x00000001204c8288 @id="client_id", @secret="client_sec...
    -client.auth_code.authorize_url(redirect_uri: "http://localhost:8080/oauth2/callback")
    -# => "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"
    -
    - -

    Customize authorize_url and token_url -

    - -

    You can specify custom URLs for authorization and access token, and when using a leading / they will not be relative, as shown below:

    - -
    client = OAuth2::Client.new(
    -  "client_id",
    -  "client_secret",
    -  site: "https://example.org/nested/directory/on/your/server",
    -  authorize_url: "/jaunty/authorize/",
    -  token_url: "/stirrups/access_token",
    -)
    -# => #<OAuth2::Client:0x00000001204c8288 @id="client_id", @secret="client_sec...
    -client.auth_code.authorize_url(redirect_uri: "http://localhost:8080/oauth2/callback")
    -# => "https://example.org/jaunty/authorize/?client_id=client_id&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Foauth2%2Fcallback&response_type=code"
    -client.class.name
    -# => OAuth2::Client
    -
    - -
    - -

    Advanced Initializers

    - -
    client = OAuth2::Client.new(id, secret, site: site) do |faraday|
    -  faraday.request(:url_encoded)
    -  faraday.adapter(:net_http_persistent)
    -end
    -
    - -

    AccessToken Features

    - -

    Instances of OAuth2::AccessToken handle request signing and token expiration.

    - -
      -
    • -Snake Case & Indifferent Access: response.parsed returns a SnakyHash allowing access via string/symbol and snake_case keys even if the provider returns CamelCase.
    • -
    • -Auto-Refresh: You can manually check token.expired? and call token.refresh.
    • -
    • -Serialization: Persist tokens using token.to_hash and restore via OAuth2::AccessToken.from_hash(client, hash).
    • -
    - -

    snake_case and indifferent access in Response#parsed

    - -
    response = access.get("/api/resource", params: {"query_foo" => "bar"})
    -# Even if the actual response is CamelCase. it will be made available as snaky:
    -JSON.parse(response.body)         # => {"accessToken"=>"aaaaaaaa", "additionalData"=>"additional"}
    -response.parsed                   # => {"access_token"=>"aaaaaaaa", "additional_data"=>"additional"}
    -response.parsed.access_token      # => "aaaaaaaa"
    -response.parsed[:access_token]    # => "aaaaaaaa"
    -response.parsed.additional_data   # => "additional"
    -response.parsed[:additional_data] # => "additional"
    -response.parsed.class.name        # => SnakyHash::StringKeyed (from snaky_hash gem)
    -
    - -

    Serialization

    - -

    As of v2.0.11, if you need to serialize the parsed result, you can!

    - -

    There are two ways to do this, globally, or discretely. The discrete way is recommended.

    - -
    Global Serialization Config
    - -

    Globally configure SnakyHash::StringKeyed to use the serializer. Put this in your code somewhere reasonable (like an initializer for Rails).

    - -
    SnakyHash::StringKeyed.class_eval do
    -  extend SnakyHash::Serializer
    -end
    -
    - -
    Discrete Serialization Config
    - -

    Discretely configure a custom Snaky Hash class to use the serializer.

    - -
    class MySnakyHash < SnakyHash::StringKeyed
    -  # Give this hash class `dump` and `load` abilities!
    -  extend SnakyHash::Serializer
    -end
    -
    -# And tell your client to use the custom class in each call:
    -client = OAuth2::Client.new("client_id", "client_secret", site: "https://example.org/oauth2")
    -token = client.get_token({snaky_hash_klass: MySnakyHash})
    -
    - -
    Serialization Extensions
    - -

    These extensions work regardless of whether you used the global or discrete config above.

    - -

    There are a few hacks you may need in your class to support Ruby < 2.4.2 or < 2.6.
    -They are likely not needed if you are on a newer Ruby.
    -Expand the examples below, or the ruby-oauth/snaky_hash gem,
    -or response_spec.rb, for more ideas, especially if you need to study the hacks for older Rubies.

    - -
    - See Examples - -
    class MySnakyHash < SnakyHash::StringKeyed
    -  # Give this hash class `dump` and `load` abilities!
    -  extend SnakyHash::Serializer
    -
    -  #### Serialization Extentions
    -  #
    -  # Act on the non-hash values (including the values of hashes) as they are dumped to JSON
    -  # In other words, this retains nested hashes, and only the deepest leaf nodes become bananas.
    -  # WARNING: This is a silly example!
    -  dump_value_extensions.add(:to_fruit) do |value|
    -    "banana" # => Make values "banana" on dump
    -  end
    -
    -  # Act on the non-hash values (including the values of hashes) as they are loaded from the JSON dump
    -  # In other words, this retains nested hashes, and only the deepest leaf nodes become ***.
    -  # WARNING: This is a silly example!
    -  load_value_extensions.add(:to_stars) do |value|
    -    "***" # Turn dumped bananas into *** when they are loaded
    -  end
    -
    -  # Act on the entire hash as it is prepared for dumping to JSON
    -  # WARNING: This is a silly example!
    -  dump_hash_extensions.add(:to_cheese) do |value|
    -    if value.is_a?(Hash)
    -      value.transform_keys do |key|
    -        split = key.split("_")
    -        first_word = split[0]
    -        key.sub(first_word, "cheese")
    -      end
    -    else
    -      value
    -    end
    -  end
    -
    -  # Act on the entire hash as it is loaded from the JSON dump
    -  # WARNING: This is a silly example!
    -  load_hash_extensions.add(:to_pizza) do |value|
    -    if value.is_a?(Hash)
    -      res = klass.new
    -      value.keys.each_with_object(res) do |key, result|
    -        split = key.split("_")
    -        last_word = split[-1]
    -        new_key = key.sub(last_word, "pizza")
    -        result[new_key] = value[key]
    -      end
    -      res
    -    else
    -      value
    -    end
    -  end
    -end
    -
    - -
    - -

    Prefer camelCase over snake_case? => snaky: false

    - -
    response = access.get("/api/resource", params: {"query_foo" => "bar"}, snaky: false)
    -JSON.parse(response.body)         # => {"accessToken"=>"aaaaaaaa", "additionalData"=>"additional"}
    -response.parsed                   # => {"accessToken"=>"aaaaaaaa", "additionalData"=>"additional"}
    -response.parsed["accessToken"]    # => "aaaaaaaa"
    -response.parsed["additionalData"] # => "additional"
    -response.parsed.class.name        # => Hash (just, regular old Hash)
    -
    - -
    - Debugging & Logging - -

    Set an environment variable as per usual (e.g. with dotenv).

    - -
    # will log both request and response, including bodies
    -ENV["OAUTH_DEBUG"] = "true"
    -
    - -

    By default, debug output will go to $stdout. This can be overridden when -initializing your OAuth2::Client.

    - -

    Sensitive values are filtered from debug logging output using:

    - -
      -
    • OAuth2.config[:filtered_label]
    • -
    • OAuth2.config[:filtered_debug_keys]
    • -
    - -

    Debug logging remains opt-in and should still be used cautiously in production environments.

    - -
    require "oauth2"
    -client = OAuth2::Client.new(
    -  "client_id",
    -  "client_secret",
    -  site: "https://example.org",
    -  logger: Logger.new("example.log", "weekly"),
    -)
    -
    - -
    - -

    Request Target Trust Boundaries

    - -

    This gem supports request flows that can involve absolute URLs in addition to relative paths.
    -That flexibility can expand trust boundaries when a token-bearing client is asked to send requests
    -to caller-provided targets.

    - -

    Practical guidance:

    - -
      -
    • prefer relative paths where practical
    • -
    • do not pass untrusted absolute URLs into token-bearing clients
    • -
    • validate or allowlist request targets at the application layer today if your deployment has strict trust-boundary requirements
    • -
    - -

    This release line does not yet enforce same-host or allowlist request policy automatically.
    -If stricter outbound request controls are needed, they should currently be implemented by the calling application.

    - -

    OAuth2::Response

    - -

    The AccessToken methods #get, #post, #put and #delete and the generic #request
    -will return an instance of the OAuth2::Response class.

    - -

    This instance contains a #parsed method that will parse the response body and
    -return a Hash-like SnakyHash::StringKeyed if the Content-Type is application/x-www-form-urlencoded or if
    -the body is a JSON object. It will return an Array if the body is a JSON
    -array. Otherwise, it will return the original body string.

    - -

    The original response body, headers, and status can be accessed via their
    -respective methods.

    - -

    OAuth2::AccessToken

    - -

    If you have an existing Access Token for a user, you can initialize an instance
    -using various class methods including the standard new, from_hash (if you have
    -a hash of the values), or from_kvform (if you have an
    -application/x-www-form-urlencoded encoded string of the values).

    - -

    Options (since v2.0.x unless noted):

    - -
      -
    • - - - - - - - -
      -expires_latency (Integernil): Seconds to subtract from expires_in when computing #expired? to offset latency.
      -
    • -
    • - - - - - - - - -
      -token_name (StringSymbolnil): When multiple token-like fields exist in responses, select the field name to use as the access token (since v2.0.10).
      -
    • -
    • - - - - - - - - -
      -mode (SymbolProcHash): Controls how the token is transmitted on requests made via this AccessToken instance.
      -
        -
      • -:header — Send as Authorization: Bearer header (default and preferred by OAuth 2.1 draft guidance). -
      • -
      • -:query — Send as access_token query parameter (discouraged in general, but required by some providers).
      • -
      • Verb-dependent (since v2.0.15): Provide either: -
          -
        • a Proc taking |verb| and returning :header or :query, or
        • -
        • a Hash with verb symbols as keys, for example {get: :query, post: :header, delete: :header}.
        • -
        -
      • -
      -
    • -
    - -

    Note: Verb-dependent mode supports providers like Instagram that require query mode for GET and header mode for POST/DELETE

    - -
      -
    • Verb-dependent mode via Proc was added in v2.0.15
    • -
    • Verb-dependent mode via Hash was added in v2.0.16
    • -
    - -

    OAuth2::Error

    - -

    On 400+ status code responses, an OAuth2::Error will be raised. If it is a
    -standard OAuth2 error response, the body will be parsed and #code and #description will contain the values provided from the error and
    -error_description parameters. The #response property of OAuth2::Error will
    -always contain the OAuth2::Response instance.

    - -

    If you do not want an error to be raised, you may use :raise_errors => false
    -option on initialization of the client. In this case the OAuth2::Response
    -instance will be returned as usual and on 400+ status code responses, the
    -Response instance will contain the OAuth2::Error instance.

    - -

    Authorization Grants

    - -

    Currently, the Authorization Code, Implicit, Resource Owner Password Credentials, Client Credentials, and Assertion
    -authentication grant types have helper strategy classes that simplify client
    -use. They are available via the #auth_code,
    -#implicit,
    -#password,
    -#client_credentials, and
    -#assertion methods respectively.

    - -

    OAuth 2.1 (draft) Note:

    - -
      -
    • -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.
    • -
    • -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.
    • -
    • -Redirect URIs must be compared using exact string matching by the Authorization Server.
    • -
    - -
    - OAuth 2.1 (draft) References - -
      -
    • OAuth 2.1 draft: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13
    • -
    • Aaron Parecki: https://aaronparecki.com/2019/12/12/21/its-time-for-oauth-2-dot-1
    • -
    • FusionAuth: https://fusionauth.io/blog/2020/04/15/whats-new-in-oauth-2-1
    • -
    • Okta: https://developer.okta.com/blog/2019/12/13/oauth-2-1-how-many-rfcs
    • -
    • Video: https://www.youtube.com/watch?v=g_aVPdwBTfw
    • -
    • Differences overview: https://fusionauth.io/learn/expert-advice/oauth/differences-between-oauth-2-oauth-2-1/
    • -
    - -
    - -

    These aren’t full examples, but demonstrative of the differences between usage for each strategy.

    - -
    auth_url = client.auth_code.authorize_url(redirect_uri: "http://localhost:8080/oauth/callback")
    -access = client.auth_code.get_token("code_value", redirect_uri: "http://localhost:8080/oauth/callback")
    -
    -auth_url = client.implicit.authorize_url(redirect_uri: "http://localhost:8080/oauth/callback")
    -# get the token params in the callback and
    -access = OAuth2::AccessToken.from_kvform(client, query_string)
    -
    -access = client.password.get_token("username", "password")
    -
    -access = client.client_credentials.get_token
    -
    -# Client Assertion Strategy
    -# see: https://tools.ietf.org/html/rfc7523
    -claimset = {
    -  iss: "http://localhost:3001",
    -  aud: "http://localhost:8080/oauth2/token",
    -  sub: "me@example.com",
    -  exp: Time.now.utc.to_i + 3600,
    -}
    -assertion_params = [claimset, "HS256", "secret_key"]
    -access = client.assertion.get_token(assertion_params)
    -
    -# The `access` (i.e. access token) is then used like so:
    -access.token # actual access_token string, if you need it somewhere
    -access.get("/api/stuff") # making api calls with access token
    -
    - -

    If you want to specify additional headers to be sent out with the
    -request, add a ‘headers’ hash under ‘params’:

    - -
    access = client.auth_code.get_token("code_value", redirect_uri: "http://localhost:8080/oauth/callback", headers: {"Some" => "Header"})
    -
    - -

    You can always use the #request method on the OAuth2::Client instance to make
    -requests for tokens for any Authentication grant type.

    - -

    📘 Comprehensive Usage

    - -

    Common Flows (end-to-end)

    - -
      -
    • Authorization Code (server-side web app):
    • -
    - -
    require "oauth2"
    -client = OAuth2::Client.new(
    -  ENV["CLIENT_ID"],
    -  ENV["CLIENT_SECRET"],
    -  site: "https://provider.example.com",
    -  redirect_uri: "https://my.app.example.com/oauth/callback",
    -)
    -
    -# Step 1: redirect user to consent
    -state = SecureRandom.hex(16)
    -auth_url = client.auth_code.authorize_url(scope: "openid profile email", state: state)
    -# redirect_to auth_url
    -
    -# Step 2: handle the callback
    -# params[:code], params[:state]
    -raise "state mismatch" unless params[:state] == state
    -access = client.auth_code.get_token(params[:code])
    -
    -# Step 3: call APIs
    -profile = access.get("/api/v1/me").parsed
    -
    - -
      -
    • Client Credentials (machine-to-machine):
    • -
    - -
    client = OAuth2::Client.new(ENV["CLIENT_ID"], ENV["CLIENT_SECRET"], site: "https://provider.example.com")
    -access = client.client_credentials.get_token(audience: "https://api.example.com")
    -resp = access.get("/v1/things")
    -
    - -
      -
    • Resource Owner Password (legacy; avoid when possible):
    • -
    - -
    access = client.password.get_token("jdoe", "s3cret", scope: "read")
    -
    - -

    Examples

    - -
    - JHipster UAA (Spring Cloud) password grant example (legacy; avoid when possible) - -
    # This converts a Postman/Net::HTTP multipart token request to oauth2 gem usage.
    -# JHipster UAA typically exposes the token endpoint at /uaa/oauth/token.
    -# The original snippet included:
    -# - Basic Authorization header for the client (web_app:changeit)
    -# - X-XSRF-TOKEN header from a cookie (some deployments require it)
    -# - grant_type=password with username/password and client_id
    -# Using oauth2 gem, you don't need to build multipart bodies; the gem sends
    -# application/x-www-form-urlencoded as required by RFC 6749.
    -
    -require "oauth2"
    -
    -client = OAuth2::Client.new(
    -  "web_app",            # client_id
    -  "changeit",           # client_secret
    -  site: "http://localhost:8080/uaa",
    -  token_url: "/oauth/token",      # absolute under site (or "oauth/token" relative)
    -  auth_scheme: :basic_auth,         # sends HTTP Basic Authorization header
    -)
    -
    -# If your UAA requires an XSRF header for the token call, provide it as a header.
    -# Often this is not required for token endpoints, but if your gateway enforces it,
    -# obtain the value from the XSRF-TOKEN cookie and pass it here.
    -xsrf_token = ENV["X_XSRF_TOKEN"] # e.g., pulled from a prior set-cookie value
    -
    -access = client.password.get_token(
    -  "admin",                 # username
    -  "admin",                 # password
    -  headers: xsrf_token ? {"X-XSRF-TOKEN" => xsrf_token} : {},
    -  # JHipster commonly also accepts/needs the client_id in the body; include if required:
    -  # client_id: "web_app",
    -)
    -
    -puts access.token
    -puts access.to_hash # full token response
    -
    - -

    Notes:

    - -
      -
    • Resource Owner Password Credentials (ROPC) is deprecated in OAuth 2.1 and discouraged. Prefer Authorization Code + PKCE.
    • -
    • 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.
    • -
    • For Basic auth, auth_scheme: :basic_auth handles the Authorization header; you do not need to base64-encode manually.
    • -
    - -
    - -

    Verb‑dependent Token Mode

    - -

    Providers like Instagram require the access token to be sent differently depending on the HTTP verb:

    - -
      -
    • GET requests: token must be in the query string (?access_token=…)
    • -
    • POST/DELETE requests: token must be in the Authorization header (Bearer …)
    • -
    - -

    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.

    - -

    Tips:

    - -
      -
    • Avoid query‑string bearer tokens unless required by your provider. Instagram explicitly requires it for GET requests.
    • -
    • If you need a custom rule, you can pass a Proc for mode, e.g. mode: ->(verb) { verb == :get ? :query : :header }.
    • -
    - -
    - Instagram API Example - -

    Example: exchanging and refreshing long‑lived Instagram tokens, and making API calls

    - -
    require "oauth2"
    -
    -# NOTE: Users authenticate via Facebook Login to obtain a short‑lived user token (not shown here).
    -# See Facebook Login docs for obtaining the initial short‑lived token.
    -
    -client = OAuth2::Client.new(nil, nil, site: "https://graph.instagram.com")
    -
    -# Start with a short‑lived token you already obtained via Facebook Login
    -short_lived = OAuth2::AccessToken.new(
    -  client,
    -  ENV["IG_SHORT_LIVED_TOKEN"],
    -  # Key part: verb‑dependent mode
    -  mode: {get: :query, post: :header, delete: :header},
    -)
    -
    -# 1) Exchange for a long‑lived token (Instagram requires GET with access_token in query)
    -#    Endpoint: GET https://graph.instagram.com/access_token
    -#    Params: grant_type=ig_exchange_token, client_secret=APP_SECRET
    -exchange = short_lived.get(
    -  "/access_token",
    -  params: {
    -    grant_type: "ig_exchange_token",
    -    client_secret: ENV["IG_APP_SECRET"],
    -    # access_token param will be added automatically by the AccessToken (mode => :query for GET)
    -  },
    -)
    -long_lived_token_value = exchange.parsed["access_token"]
    -
    -long_lived = OAuth2::AccessToken.new(
    -  client,
    -  long_lived_token_value,
    -  mode: {get: :query, post: :header, delete: :header},
    -)
    -
    -# 2) Refresh the long‑lived token (Instagram uses GET with token in query)
    -#    Endpoint: GET https://graph.instagram.com/refresh_access_token
    -refresh_resp = long_lived.get(
    -  "/refresh_access_token",
    -  params: {grant_type: "ig_refresh_token"},
    -)
    -long_lived = OAuth2::AccessToken.new(
    -  client,
    -  refresh_resp.parsed["access_token"],
    -  mode: {get: :query, post: :header, delete: :header},
    -)
    -
    -# 3) Typical API GET request (token in query automatically)
    -me = long_lived.get("/me", params: {fields: "id,username"}).parsed
    -
    -# 4) Example POST (token sent via Bearer header automatically)
    -# Note: Replace the path/params with a real Instagram Graph API POST you need,
    -# such as publishing media via the Graph API endpoints.
    -# long_lived.post("/me/media", body: {image_url: "https://...", caption: "hello"})
    -
    - -
    - -

    Refresh Tokens

    - -

    When the server issues a refresh_token, you can refresh manually or implement an auto-refresh wrapper.

    - -
      -
    • Manual refresh:
    • -
    - -
    if access.expired?
    -  access = access.refresh
    -end
    -
    - -
      -
    • Auto-refresh wrapper pattern:
    • -
    - -
    class AutoRefreshingToken
    -  def initialize(token_provider, store: nil)
    -    @token = token_provider
    -    @store = store # e.g., something that responds to read/write for token data
    -  end
    -
    -  def with(&blk)
    -    tok = ensure_fresh!
    -    blk ? blk.call(tok) : tok
    -  rescue OAuth2::Error => e
    -    # If a 401 suggests token invalidation, try one refresh and retry once
    -    if e.response && e.response.status == 401 && @token.refresh_token
    -      @token = @token.refresh
    -      @store.write(@token.to_hash) if @store
    -      retry
    -    end
    -    raise
    -  end
    -
    -private
    -
    -  def ensure_fresh!
    -    if @token.expired? && @token.refresh_token
    -      @token = @token.refresh
    -      @store.write(@token.to_hash) if @store
    -    end
    -    @token
    -  end
    -end
    -
    -# usage
    -keeper = AutoRefreshingToken.new(access)
    -keeper.with { |tok| tok.get("/v1/protected") }
    -
    - -

    Persist the token across processes using AccessToken#to_hash and AccessToken.from_hash(client, hash).

    - -

    Token Revocation (RFC 7009)

    - -

    You can revoke either the access token or the refresh token.

    - -
    # Revoke the current access token
    -access.revoke(token_type_hint: :access_token)
    -
    -# Or explicitly revoke the refresh token (often also invalidates associated access tokens)
    -access.revoke(token_type_hint: :refresh_token)
    -
    - -

    Client Configuration Tips

    - -

    Mutual TLS (mTLS) client authentication

    - -

    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.

    - -

    Example using PEM files (certificate and key):

    - -
    require "oauth2"
    -require "openssl"
    -
    -client = OAuth2::Client.new(
    -  ENV.fetch("CLIENT_ID"),
    -  ENV.fetch("CLIENT_SECRET"),
    -  site: "https://example.com",
    -  authorize_url: "/oauth/authorize/",
    -  token_url: "/oauth/token/",
    -  auth_scheme: :tls_client_auth, # if your AS requires mTLS-based client authentication
    -  connection_opts: {
    -    ssl: {
    -      client_cert: OpenSSL::X509::Certificate.new(File.read("localhost.pem")),
    -      client_key: OpenSSL::PKey::RSA.new(File.read("localhost-key.pem")),
    -      # Optional extras, uncomment as needed:
    -      # ca_file: "/path/to/ca-bundle.pem",   # custom CA(s)
    -      # verify: true                           # enable server cert verification (recommended)
    -    },
    -  },
    -)
    -
    -# Example token request (any grant type can be used). The mTLS handshake
    -# will occur automatically on HTTPS calls using the configured cert/key.
    -access = client.client_credentials.get_token
    -
    -# Subsequent resource requests will also use mTLS on HTTPS endpoints of `site`:
    -resp = access.get("/v1/protected")
    -
    - -

    Notes:

    - -
      -
    • 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"]).
    • -
    • If your certificate and key are in a PKCS#12/PFX bundle, you can load them like: -
        -
      • p12 = OpenSSL::PKCS12.new(File.read("client.p12"), ENV["P12_PASSWORD"])
      • -
      • client_cert = p12.certificate; client_key = p12.key
      • -
      -
    • -
    • Server trust: -
        -
      • If your environment does not have system CAs, specify ca_file or ca_path inside the ssl: hash.
      • -
      • Keep verify: true in production. Set verify: false only for local testing.
      • -
      -
    • -
    • Faraday adapter: Any adapter that supports Ruby’s OpenSSL should work. net_http (default) and net_http_persistent are common choices.
    • -
    • 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).
    • -
    • 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.
    • -
    - -

    Authentication schemes for the token request

    - -
    OAuth2::Client.new(
    -  id,
    -  secret,
    -  site: "https://provider.example.com",
    -  auth_scheme: :basic_auth, # default. Alternatives: :request_body, :tls_client_auth, :private_key_jwt
    -)
    -
    - -

    Faraday connection, timeouts, proxy, custom adapter/middleware:

    - -
    client = OAuth2::Client.new(
    -  id,
    -  secret,
    -  site: "https://provider.example.com",
    -  connection_opts: {
    -    request: {open_timeout: 5, timeout: 15},
    -    proxy: ENV["HTTPS_PROXY"],
    -    ssl: {verify: true},
    -  },
    -) do |faraday|
    -  faraday.request(:url_encoded)
    -  # faraday.response :logger, Logger.new($stdout) # see OAUTH_DEBUG below
    -  faraday.adapter(:net_http_persistent) # or any Faraday adapter you need
    -end
    -
    - -
    Using flat query params (Faraday::FlatParamsEncoder)
    - -

    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.

    - -
    require "faraday"
    -
    -client = OAuth2::Client.new(
    -  id,
    -  secret,
    -  site: "https://api.example.com",
    -  # Pass Faraday connection options to make FlatParamsEncoder the default
    -  connection_opts: {
    -    request: {params_encoder: Faraday::FlatParamsEncoder},
    -  },
    -) do |faraday|
    -  faraday.request(:url_encoded)
    -  faraday.adapter(:net_http)
    -end
    -
    -access = client.client_credentials.get_token
    -
    -# Example of a GET with two flat filter params (not an array):
    -# Results in: ?filter=order.clientCreatedTime%3E1445006997000&filter=order.clientCreatedTime%3C1445611797000
    -resp = access.get(
    -  "/v1/orders",
    -  params: {
    -    # Provide the values as an array; FlatParamsEncoder expands them as repeated keys
    -    filter: [
    -      "order.clientCreatedTime>1445006997000",
    -      "order.clientCreatedTime<1445611797000",
    -    ],
    -  },
    -)
    -
    - -

    If you instead need to build a raw Faraday connection yourself, the equivalent configuration is:

    - -
    conn = Faraday.new("https://api.example.com", request: {params_encoder: Faraday::FlatParamsEncoder})
    -
    - -

    Redirection

    - -

    The library follows up to max_redirects (default 5).
    -You can override per-client via options[:max_redirects].

    - -

    Handling Responses and Errors

    - -
      -
    • Parsing:
    • -
    - -
    resp = access.get("/v1/thing")
    -resp.status     # Integer
    -resp.headers    # Hash
    -resp.body       # String
    -resp.parsed     # SnakyHash::StringKeyed or Array when JSON array
    -
    - -
      -
    • Error handling:
    • -
    - -
    begin
    -  access.get("/v1/forbidden")
    -rescue OAuth2::Error => e
    -  e.code         # OAuth2 error code (when present)
    -  e.description  # OAuth2 error description (when present)
    -  e.response     # OAuth2::Response (full access to status/headers/body)
    -end
    -
    - -
      -
    • Disable raising on 4xx/5xx to inspect the response yourself:
    • -
    - -
    client = OAuth2::Client.new(id, secret, site: site, raise_errors: false)
    -res = client.request(:get, "/v1/maybe-errors")
    -if res.status == 429
    -  sleep res.headers["retry-after"].to_i
    -end
    -
    - -

    Making Raw Token Requests

    - -

    If a provider requires non-standard parameters or headers, you can call client.get_token directly:

    - -
    access = client.get_token({
    -  grant_type: "client_credentials",
    -  audience: "https://api.example.com",
    -  headers: {"X-Custom" => "value"},
    -  parse: :json, # override parsing
    -})
    -
    - -

    OpenID Connect (OIDC)

    - -
      -
    • If the token response includes an id_token (a JWT), this gem surfaces it in token.params['id_token'].
    • -
    • -Note: This gem does not validate the signature of the id_token. You must use a JWT library (like the jwt gem) and your provider’s JWKs to verify it.
    • -
    • For private_key_jwt client authentication, provide auth_scheme: :private_key_jwt and ensure your key configuration matches the provider requirements.
    • -
    • See OIDC.md for a more complete OIDC overview and examples.
    • -
    - -

    Debugging

    - -
      -
    • Set environment variable OAUTH_DEBUG=true to enable verbose Faraday logging (uses the client-provided logger).
    • -
    • 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.
    • -
    - -
    - -

    🦷 FLOSS Funding

    - -

    While ruby-oauth tools are free software and will always be, the project would benefit immensely from some funding.
    -Raising a monthly budget of… “dollars” would make the project more sustainable.

    - -

    We welcome both individual and corporate sponsors! We also offer a
    -wide array of funding channels to account for your preferences
    -(although currently Open Collective is our preferred funding platform).

    - -

    If you’re working in a company that’s making significant use of ruby-oauth tools we’d
    -appreciate it if you suggest to your company to become a ruby-oauth sponsor.

    - -

    You can support the development of ruby-oauth tools via
    -GitHub Sponsors,
    -Liberapay,
    -PayPal,
    -Open Collective
    -and Tidelift.

    - - - - - - - - - - - - -
    📍 NOTE
    If doing a sponsorship in the form of donation is problematic for your company
    from an accounting standpoint, we’d recommend the use of Tidelift,
    where you can get a support-like subscription instead.
    - -

    Open Collective for Individuals

    - -

    Support us with a monthly donation and help us continue our activities. [Become a backer]

    - -

    NOTE: kettle-readme-backers updates this list every day, automatically.

    - - -

    No backers yet. Be the first!
    -

    - -

    Open Collective for Organizations

    - -

    Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]

    - -

    NOTE: kettle-readme-backers updates this list every day, automatically.

    - - -

    No sponsors yet. Be the first!

    - -

    Open Collective for Donors

    - -

    Bill Woika
    -

    - -

    Another way to support open-source

    - -

    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).

    - -

    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.

    - -

    I’m developing a new library, floss_funding, 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.

    - -

    Floss-Funding.dev: 👉️ No network calls. 👉️ No tracking. 👉️ No oversight. 👉️ Minimal crypto hashing. 💡 Easily disabled nags

    - -

    OpenCollective Backers OpenCollective Sponsors Sponsor Me on Github Liberapay Goal Progress Donate on PayPal Buy me a coffee Donate on Polar Donate to my FLOSS efforts at ko-fi.com Donate to my FLOSS efforts using Patreon

    - -

    🔐 Security

    - -

    To report a security vulnerability, please use the Tidelift security contact.
    -Tidelift will coordinate the fix and disclosure.

    - -

    For more see SECURITY.md, THREAT_MODEL.md, and IRP.md.

    - -

    🤝 Contributing

    - -

    If you need some ideas of where to help, you could work on adding more code coverage,
    -or if it is already 💯 (see below) check reek, issues, or PRs,
    -or use the gem and think about how it could be better.

    - -

    We Keep A Changelog so if you make changes, remember to update it.

    - -

    See CONTRIBUTING.md for more detailed instructions.

    - -

    🚀 Release Instructions

    - -

    See CONTRIBUTING.md.

    - -

    Code Coverage

    - -

    Coverage Graph

    - -

    Coveralls Test Coverage

    - -

    QLTY Test Coverage

    - -

    🪇 Code of Conduct

    - -

    Everyone interacting with this project’s codebases, issue trackers,
    -chat rooms and mailing lists agrees to follow the Contributor Covenant 2.1.

    - -

    🌈 Contributors

    - -

    Contributors

    - -

    Made with contributors-img.

    - -

    Also see GitLab Contributors: https://gitlab.com/ruby-oauth/oauth2/-/graphs/main

    - -
    - ⭐️ Star History - - - - - - Star History Chart - - - -
    - -

    📌 Versioning

    - -

    This Library adheres to Semantic Versioning 2.0.0.
    -Violations of this scheme should be reported as bugs.
    -Specifically, if a minor or patch version is released that breaks backward compatibility,
    -a new version should be immediately released that restores compatibility.
    -Breaking changes to the public API will only be introduced with new major versions.

    - -
    -

    dropping support for a platform is both obviously and objectively a breaking change

    -—Jordan Harband (@ljharb, maintainer of SemVer) in SemVer issue 716

    -
    - -

    I understand that policy doesn’t work universally (“exceptions to every rule!”),
    -but it is the policy here.
    -As such, in many cases it is good to specify a dependency on this library using
    -the Pessimistic Version Constraint with two digits of precision.

    - -

    For example:

    - -
    spec.add_dependency("oauth2", "~> 2.0")
    -
    - -
    - 📌 Is "Platform Support" part of the public API? More details inside. - -

    SemVer should, IMO, but doesn’t explicitly, say that dropping support for specific Platforms -is a breaking change to an API, and for that reason the bike shedding is endless.

    - -

    To get a better understanding of how SemVer is intended to work over a project’s lifetime, -read this article from the creator of SemVer:

    - - - -
    - -

    See CHANGELOG.md for a list of releases.

    - -

    📄 License

    - -

    The gem is available as open source under the terms of
    -the MIT License License: MIT.
    -See LICENSE.txt for the official Copyright Notice.

    - - - -
      -
    • - Copyright (c) 2017 – 2026 Peter H. Boling, of - - Galtzo.com - - Galtzo.com Logo (Wordless) by Aboling0, CC BY-SA 4.0 - - , and oauth2 contributors. -
    • -
    • - Copyright (c) 2011 - 2013 Michael Bleigh and Intridea, Inc. -
    • -
    - -

    🤑 A request for help

    - -

    Maintainers have teeth and need to pay their dentists.
    -After getting laid off in an RIF in March, and encountering difficulty finding a new one,
    -I began spending most of my time building open source tools.
    -I’m hoping to be able to pay for my kids’ health insurance this month,
    -so if you value the work I am doing, I need your support.
    -Please consider sponsoring me or the project.

    - -

    To join the community or get help 👇️ Join the Discord.

    - -

    Live Chat on Discord

    - -

    To say “thanks!” ☝️ Join the Discord or 👇️ send money.

    - -

    Sponsor ruby-oauth/oauth2 on Open Source Collective 💌 Sponsor me on GitHub Sponsors 💌 Sponsor me on Liberapay 💌 Donate on PayPal

    - -

    Please give the project a star ⭐ ♥.

    - -

    Thanks for RTFM. ☺️

    - -
    - - rel="me" Social Proofs - - - - - -
    -
    - - - -
    - - diff --git a/docs/file.REEK.html b/docs/file.REEK.html index ca6db01f0..e69de29bb 100644 --- a/docs/file.REEK.html +++ b/docs/file.REEK.html @@ -1,74 +0,0 @@ - - - - - - - File: REEK - - — Documentation by YARD 0.9.43 - - - - - - - - - - - - - - - - - - - - - -
    - - -

    Error: No such file - is
    -Error: No such file - empty

    -
    - - - -
    - - diff --git a/docs/top-level-namespace.html b/docs/top-level-namespace.html index 49b5047ac..e69de29bb 100644 --- a/docs/top-level-namespace.html +++ b/docs/top-level-namespace.html @@ -1,112 +0,0 @@ - - - - - - - Top Level Namespace - - — Documentation by YARD 0.9.43 - - - - - - - - - - - - - - - - - - - - - -
    - - -

    Top Level Namespace - - - -

    -
    - - - - - - - - - - - -
    - -

    Defined Under Namespace

    -

    - - - Modules: OAuth2 - - - - -

    - - - - - - - - - -
    - - - -
    - - diff --git a/lib/oauth2/auth_sanitizer.rb b/lib/oauth2/auth_sanitizer.rb index 3397d6271..80d785c31 100644 --- a/lib/oauth2/auth_sanitizer.rb +++ b/lib/oauth2/auth_sanitizer.rb @@ -5,7 +5,9 @@ module OAuth2 auth_sanitizer_requirement = Gem::Requirement.new("~> 0.1", ">= 0.1.3") auth_sanitizer_spec = Gem.loaded_specs["auth-sanitizer"] unless auth_sanitizer_spec && auth_sanitizer_requirement.satisfied_by?(auth_sanitizer_spec.version) + # :nocov: auth_sanitizer_spec = Gem::Specification.find_by_name("auth-sanitizer", auth_sanitizer_requirement) + # :nocov: end auth_sanitizer_loader_path = File.join( @@ -13,8 +15,10 @@ module OAuth2 "lib/auth_sanitizer/loader.rb", ) unless File.file?(auth_sanitizer_loader_path) + # :nocov: raise LoadError, "oauth2 requires auth-sanitizer #{auth_sanitizer_requirement}; " \ "loader not found at #{auth_sanitizer_loader_path}" + # :nocov: end auth_sanitizer_loader_namespace = Module.new