diff --git a/.rubocop_gradual.lock b/.rubocop_gradual.lock index 77253f0f..9e178ebe 100644 --- a/.rubocop_gradual.lock +++ b/.rubocop_gradual.lock @@ -6,7 +6,7 @@ "lib/oauth2.rb:2435263975": [ [73, 11, 7, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 651502127] ], - "lib/oauth2/access_token.rb:558937598": [ + "lib/oauth2/access_token.rb:1775225572": [ [64, 13, 5, "Style/IdenticalConditionalBranches: Move `t_key` out of the conditional.", 183811513], [70, 13, 5, "Style/IdenticalConditionalBranches: Move `t_key` out of the conditional.", 183811513] ], diff --git a/CHANGELOG.md b/CHANGELOG.md index a6ebafb3..7c36d47d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,19 @@ # Changelog All notable changes to this project will be documented in this file. -The format (since v2) is based on [Keep a Changelog v1](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning v2](https://semver.org/spec/v2.0.0.html). +The format (since v2) is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] ### Added - improved documentation by @pboling +- documentation notes in code comments and README highlighting OAuth 2.1 differences, with references, such as: + - PKCE required for auth code, + - exact redirect URI match, + - implicit/password grants omitted, + - avoid bearer tokens in query, + - refresh token guidance for public clients, + - simplified client definitions) ### Changed ### Deprecated ### Removed diff --git a/README.md b/README.md index 3b54066f..56365fa0 100644 --- a/README.md +++ b/README.md @@ -692,6 +692,22 @@ Response instance will contain the `OAuth2::Error` instance. ### Authorization Grants +Note on OAuth 2.1 (draft): +- 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. +- Redirect URIs must be compared using exact string matching by the Authorization Server. +- The Implicit grant (response_type=token) and the 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. +- Bearer tokens in the query string are omitted due to security risks; prefer Authorization header usage. +- Refresh tokens for public clients must either be sender-constrained (e.g., DPoP/MTLS) or one-time use. +- The definitions of public and confidential clients are simplified to refer only to whether the client has credentials. + +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/ + 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`](https://gitlab.com/ruby-oauth/oauth2/-/blob/main/lib/oauth2/strategy/auth_code.rb), diff --git a/docs/OAuth2.html b/docs/OAuth2.html index 794f4356..f147de49 100644 --- a/docs/OAuth2.html +++ b/docs/OAuth2.html @@ -415,7 +415,7 @@

diff --git a/docs/OAuth2/AccessToken.html b/docs/OAuth2/AccessToken.html index 2e75301b..9390625c 100644 --- a/docs/OAuth2/AccessToken.html +++ b/docs/OAuth2/AccessToken.html @@ -3069,7 +3069,7 @@

diff --git a/docs/OAuth2/Authenticator.html b/docs/OAuth2/Authenticator.html index 0e0214dd..dabcdf70 100644 --- a/docs/OAuth2/Authenticator.html +++ b/docs/OAuth2/Authenticator.html @@ -883,7 +883,7 @@

diff --git a/docs/OAuth2/Client.html b/docs/OAuth2/Client.html index 14375cb7..f7320c23 100644 --- a/docs/OAuth2/Client.html +++ b/docs/OAuth2/Client.html @@ -1843,6 +1843,9 @@

requesting authorization. If it is provided at authorization time it MUST
also be provided with the token exchange request.

+

OAuth 2.1 note: Authorization Servers must compare redirect URIs using exact string matching.
+This client simply forwards the configured redirect_uri; the exact-match validation happens server-side.

+

Providing :redirect_uri to the OAuth2::Client instantiation will take
care of managing this.

@@ -1880,6 +1883,8 @@

  • https://datatracker.ietf.org/doc/html/rfc6749#section-10.6
  • +
  • https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13
  • + @@ -1888,16 +1893,16 @@

     
     
    -335
    -336
    -337
    -338
     339
     340
    -341
    +341 +342 +343 +344 +345

    -
    # File 'lib/oauth2/client.rb', line 335
    +      
    # File 'lib/oauth2/client.rb', line 339
     
     def redirection_params
       if options[:redirect_uri]
    @@ -2651,7 +2656,7 @@ 

    diff --git a/docs/OAuth2/Error.html b/docs/OAuth2/Error.html index 526c9ded..565b17d6 100644 --- a/docs/OAuth2/Error.html +++ b/docs/OAuth2/Error.html @@ -772,7 +772,7 @@

    diff --git a/docs/OAuth2/FilteredAttributes.html b/docs/OAuth2/FilteredAttributes.html index 7959f3ed..8add3c57 100644 --- a/docs/OAuth2/FilteredAttributes.html +++ b/docs/OAuth2/FilteredAttributes.html @@ -335,7 +335,7 @@

    diff --git a/docs/OAuth2/FilteredAttributes/ClassMethods.html b/docs/OAuth2/FilteredAttributes/ClassMethods.html index 2fcffb79..53511059 100644 --- a/docs/OAuth2/FilteredAttributes/ClassMethods.html +++ b/docs/OAuth2/FilteredAttributes/ClassMethods.html @@ -280,7 +280,7 @@

    diff --git a/docs/OAuth2/Response.html b/docs/OAuth2/Response.html index 9cb8de78..a9fb6698 100644 --- a/docs/OAuth2/Response.html +++ b/docs/OAuth2/Response.html @@ -1619,7 +1619,7 @@

    diff --git a/docs/OAuth2/Strategy.html b/docs/OAuth2/Strategy.html index d4e31108..14eeec5c 100644 --- a/docs/OAuth2/Strategy.html +++ b/docs/OAuth2/Strategy.html @@ -107,7 +107,7 @@

    Defined Under Namespace

    diff --git a/docs/OAuth2/Strategy/Assertion.html b/docs/OAuth2/Strategy/Assertion.html index b283a6d9..76a454a4 100644 --- a/docs/OAuth2/Strategy/Assertion.html +++ b/docs/OAuth2/Strategy/Assertion.html @@ -481,7 +481,7 @@

    diff --git a/docs/OAuth2/Strategy/AuthCode.html b/docs/OAuth2/Strategy/AuthCode.html index 4cb8b641..73881c8e 100644 --- a/docs/OAuth2/Strategy/AuthCode.html +++ b/docs/OAuth2/Strategy/AuthCode.html @@ -105,6 +105,20 @@

    Overview

    The Authorization Code Strategy

    +

    OAuth 2.1 notes:

    +
      +
    • PKCE is required for all OAuth clients using the authorization code flow (especially public clients).
      +This library does not enforce PKCE generation/verification; implement PKCE in your application when required.
    • +
    • Redirect URIs must be compared using exact string matching by the Authorization Server.
      +This client forwards redirect_uri but does not perform server-side validation.
    • +
    + +

    References:

    +
      +
    • OAuth 2.1 draft: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13
    • +
    • OAuth for native apps (RFC 8252) and PKCE (RFC 7636)
    • +
    +
    @@ -274,12 +288,12 @@

     
     
    -12
    -13
    -14
    +22 +23 +24

    -
    # File 'lib/oauth2/strategy/auth_code.rb', line 12
    +      
    # File 'lib/oauth2/strategy/auth_code.rb', line 22
     
     def authorize_params(params = {})
       params.merge("response_type" => "code", "client_id" => @client.id)
    @@ -335,13 +349,13 @@ 

     
     
    -19
    -20
    -21
    -22
    +29 +30 +31 +32

    -
    # File 'lib/oauth2/strategy/auth_code.rb', line 19
    +      
    # File 'lib/oauth2/strategy/auth_code.rb', line 29
     
     def authorize_url(params = {})
       assert_valid_params(params)
    @@ -437,18 +451,18 @@ 

     
     
    -30
    -31
    -32
    -33
    -34
    -35
    -36
    -37
    -38
    +40 +41 +42 +43 +44 +45 +46 +47 +48

    -
    # File 'lib/oauth2/strategy/auth_code.rb', line 30
    +      
    # File 'lib/oauth2/strategy/auth_code.rb', line 40
     
     def get_token(code, params = {}, opts = {})
       params = {"grant_type" => "authorization_code", "code" => code}.merge(@client.redirection_params).merge(params)
    @@ -469,7 +483,7 @@ 

    diff --git a/docs/OAuth2/Strategy/Base.html b/docs/OAuth2/Strategy/Base.html index 642e130e..ed53e472 100644 --- a/docs/OAuth2/Strategy/Base.html +++ b/docs/OAuth2/Strategy/Base.html @@ -195,7 +195,7 @@

    diff --git a/docs/OAuth2/Strategy/ClientCredentials.html b/docs/OAuth2/Strategy/ClientCredentials.html index d3aa1f86..140ac362 100644 --- a/docs/OAuth2/Strategy/ClientCredentials.html +++ b/docs/OAuth2/Strategy/ClientCredentials.html @@ -343,7 +343,7 @@

    diff --git a/docs/OAuth2/Strategy/Implicit.html b/docs/OAuth2/Strategy/Implicit.html index cacba7d5..7db5f9e2 100644 --- a/docs/OAuth2/Strategy/Implicit.html +++ b/docs/OAuth2/Strategy/Implicit.html @@ -105,6 +105,16 @@

    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/
    • +
    +
    @@ -274,12 +284,12 @@

     
     
    -12
    -13
    -14
    +20 +21 +22

    -
    # File 'lib/oauth2/strategy/implicit.rb', line 12
    +      
    # File 'lib/oauth2/strategy/implicit.rb', line 20
     
     def authorize_params(params = {})
       params.merge("response_type" => "token", "client_id" => @client.id)
    @@ -335,13 +345,13 @@ 

     
     
    -19
    -20
    -21
    -22
    +27 +28 +29 +30

    -
    # File 'lib/oauth2/strategy/implicit.rb', line 19
    +      
    # File 'lib/oauth2/strategy/implicit.rb', line 27
     
     def authorize_url(params = {})
       assert_valid_params(params)
    @@ -390,12 +400,12 @@ 

     
     
    -27
    -28
    -29
    +35 +36 +37

    -
    # File 'lib/oauth2/strategy/implicit.rb', line 27
    +      
    # File 'lib/oauth2/strategy/implicit.rb', line 35
     
     def get_token(*)
       raise(NotImplementedError, "The token is accessed differently in this strategy")
    @@ -410,7 +420,7 @@ 

    diff --git a/docs/OAuth2/Strategy/Password.html b/docs/OAuth2/Strategy/Password.html index e73b941b..1db42065 100644 --- a/docs/OAuth2/Strategy/Password.html +++ b/docs/OAuth2/Strategy/Password.html @@ -105,6 +105,16 @@

    Overview

    The Resource Owner Password Credentials Authorization Strategy

    +

    IMPORTANT (OAuth 2.1): The Resource Owner Password Credentials grant is omitted in OAuth 2.1.
    +It remains here for backward compatibility with OAuth 2.0 providers. Prefer Authorization Code + PKCE.

    + +

    References:

    +
      +
    • OAuth 2.1 draft: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13
    • +
    • Okta explainer: https://developer.okta.com/blog/2019/12/13/oauth-2-1-how-many-rfcs
    • +
    • FusionAuth blog: https://fusionauth.io/blog/2020/04/15/whats-new-in-oauth-2-1
    • +
    +
    @@ -243,12 +253,12 @@

     
     
    -12
    -13
    -14
    +20 +21 +22

    -
    # File 'lib/oauth2/strategy/password.rb', line 12
    +      
    # File 'lib/oauth2/strategy/password.rb', line 20
     
     def authorize_url
       raise(NotImplementedError, "The authorization endpoint is not used in this strategy")
    @@ -334,17 +344,17 @@ 

     
     
    -21
    -22
    -23
    -24
    -25
    -26
    -27
    -28
    +29 +30 +31 +32 +33 +34 +35 +36

    -
    # File 'lib/oauth2/strategy/password.rb', line 21
    +      
    # File 'lib/oauth2/strategy/password.rb', line 29
     
     def get_token(username, password, params = {}, opts = {})
       params = {
    @@ -364,7 +374,7 @@ 

    diff --git a/docs/OAuth2/Version.html b/docs/OAuth2/Version.html index 9b63d3c1..1fa26949 100644 --- a/docs/OAuth2/Version.html +++ b/docs/OAuth2/Version.html @@ -111,7 +111,7 @@

    diff --git a/docs/_index.html b/docs/_index.html index 3995f9e9..48ac3aaa 100644 --- a/docs/_index.html +++ b/docs/_index.html @@ -84,6 +84,63 @@

    File Listing

  • LICENSE
  • +
  • CITATION
  • + + +
  • oauth2-2.0.10.gem
  • + + +
  • oauth2-2.0.11.gem
  • + + +
  • oauth2-2.0.12.gem
  • + + +
  • oauth2-2.0.13.gem
  • + + +
  • oauth2-2.0.10.gem
  • + + +
  • oauth2-2.0.11.gem
  • + + +
  • oauth2-2.0.12.gem
  • + + +
  • oauth2-2.0.13.gem
  • + + +
  • REEK
  • + + +
  • access_token
  • + + +
  • authenticator
  • + + +
  • client
  • + + +
  • error
  • + + +
  • filtered_attributes
  • + + +
  • response
  • + + +
  • strategy
  • + + +
  • version
  • + + +
  • oauth2
  • + +
    @@ -306,7 +363,7 @@

    Namespace Listing A-Z

    diff --git a/docs/file.CHANGELOG.html b/docs/file.CHANGELOG.html index 20347058..d8e4431a 100644 --- a/docs/file.CHANGELOG.html +++ b/docs/file.CHANGELOG.html @@ -60,18 +60,28 @@

    Changelog

    All notable changes to this project will be documented in this file.

    -

    The format (since v2) is based on Keep a Changelog v1,
    -and this project adheres to Semantic Versioning v2.

    +

    The format (since v2) is based on Keep a Changelog
    +and this project adheres to Semantic Versioning.

    Unreleased

    Added

      -
    • improved documentation by @pboling -

      Changed

      -

      Deprecated

      -

      Removed

      -

      Fixed

      -

      Security

      +
    • improved documentation by @pboling
    • +
    • documentation notes in code comments and README highlighting OAuth 2.1 differences, with references, such as: +
        +
      • PKCE required for auth code,
      • +
      • exact redirect URI match,
      • +
      • implicit/password grants omitted,
      • +
      • avoid bearer tokens in query,
      • +
      • refresh token guidance for public clients,
      • +
      • simplified client definitions) +

        Changed

        +

        Deprecated

        +

        Removed

        +

        Fixed

        +

        Security

        +
      • +
    @@ -1228,7 +1238,7 @@

    diff --git a/docs/file.CITATION.html b/docs/file.CITATION.html index 163c9de9..ad98f8f8 100644 --- a/docs/file.CITATION.html +++ b/docs/file.CITATION.html @@ -82,7 +82,7 @@ diff --git a/docs/file.CODE_OF_CONDUCT.html b/docs/file.CODE_OF_CONDUCT.html index 4b891735..ed3003e1 100644 --- a/docs/file.CODE_OF_CONDUCT.html +++ b/docs/file.CODE_OF_CONDUCT.html @@ -191,7 +191,7 @@

    Attribution

    diff --git a/docs/file.CONTRIBUTING.html b/docs/file.CONTRIBUTING.html index 707469c7..4978c12c 100644 --- a/docs/file.CONTRIBUTING.html +++ b/docs/file.CONTRIBUTING.html @@ -274,7 +274,7 @@

    Manual process

    diff --git a/docs/file.FUNDING.html b/docs/file.FUNDING.html index d464f2b2..0d4904a8 100644 --- a/docs/file.FUNDING.html +++ b/docs/file.FUNDING.html @@ -104,7 +104,7 @@

    Another Way to Support Open diff --git a/docs/file.LICENSE.html b/docs/file.LICENSE.html index 6c799800..d1165879 100644 --- a/docs/file.LICENSE.html +++ b/docs/file.LICENSE.html @@ -60,7 +60,7 @@
    MIT License

    Copyright (c) 2017-2025 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 fba30eca..0d3fa887 100644 --- a/docs/file.README.html +++ b/docs/file.README.html @@ -826,6 +826,26 @@

    OAuth2::Error

    Authorization Grants

    +

    Note on OAuth 2.1 (draft):

    +
      +
    • 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.
    • +
    • Redirect URIs must be compared using exact string matching by the Authorization Server.
    • +
    • The Implicit grant (response_type=token) and the 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.
    • +
    • Bearer tokens in the query string are omitted due to security risks; prefer Authorization header usage.
    • +
    • Refresh tokens for public clients must either be sender-constrained (e.g., DPoP/MTLS) or one-time use.
    • +
    • The definitions of public and confidential clients are simplified to refer only to whether the client has credentials.
    • +
    + +

    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/
    • +
    +

    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,
    @@ -1160,7 +1180,7 @@

    🔐 Security

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

    @@ -1306,7 +1326,7 @@

    Please give the project a star ⭐ ♥ diff --git a/docs/file.REEK.html b/docs/file.REEK.html index 137dfca2..57f29476 100644 --- a/docs/file.REEK.html +++ b/docs/file.REEK.html @@ -61,7 +61,7 @@ diff --git a/docs/file.RUBOCOP.html b/docs/file.RUBOCOP.html index 62540ff2..4ac6b96e 100644 --- a/docs/file.RUBOCOP.html +++ b/docs/file.RUBOCOP.html @@ -161,7 +161,7 @@

    Benefits of rubocop_gradual

    diff --git a/docs/file.SECURITY.html b/docs/file.SECURITY.html index 145a52d4..7643c7c2 100644 --- a/docs/file.SECURITY.html +++ b/docs/file.SECURITY.html @@ -113,7 +113,7 @@

    Enterprise Support

    diff --git a/docs/file.access_token.html b/docs/file.access_token.html index 59dd96da..4cb72ea2 100644 --- a/docs/file.access_token.html +++ b/docs/file.access_token.html @@ -84,7 +84,7 @@ diff --git a/docs/file.authenticator.html b/docs/file.authenticator.html index e703185b..ce2b14fb 100644 --- a/docs/file.authenticator.html +++ b/docs/file.authenticator.html @@ -81,7 +81,7 @@ diff --git a/docs/file.client.html b/docs/file.client.html index a26f7a40..f7d7750b 100644 --- a/docs/file.client.html +++ b/docs/file.client.html @@ -111,7 +111,7 @@ diff --git a/docs/file.error.html b/docs/file.error.html index d36d31cb..419173f9 100644 --- a/docs/file.error.html +++ b/docs/file.error.html @@ -68,7 +68,7 @@ diff --git a/docs/file.filtered_attributes.html b/docs/file.filtered_attributes.html index b6be30c1..2006a7ed 100644 --- a/docs/file.filtered_attributes.html +++ b/docs/file.filtered_attributes.html @@ -66,7 +66,7 @@ diff --git a/docs/file.oauth2-2.0.10.gem.html b/docs/file.oauth2-2.0.10.gem.html index 74bd8adf..734ab2bc 100644 --- a/docs/file.oauth2-2.0.10.gem.html +++ b/docs/file.oauth2-2.0.10.gem.html @@ -61,7 +61,7 @@ diff --git a/docs/file.oauth2-2.0.11.gem.html b/docs/file.oauth2-2.0.11.gem.html index b8260853..81a61042 100644 --- a/docs/file.oauth2-2.0.11.gem.html +++ b/docs/file.oauth2-2.0.11.gem.html @@ -61,7 +61,7 @@ diff --git a/docs/file.oauth2-2.0.12.gem.html b/docs/file.oauth2-2.0.12.gem.html index dc9a40a6..100e46f9 100644 --- a/docs/file.oauth2-2.0.12.gem.html +++ b/docs/file.oauth2-2.0.12.gem.html @@ -61,7 +61,7 @@ diff --git a/docs/file.oauth2-2.0.13.gem.html b/docs/file.oauth2-2.0.13.gem.html new file mode 100644 index 00000000..a86bbff3 --- /dev/null +++ b/docs/file.oauth2-2.0.13.gem.html @@ -0,0 +1,71 @@ + + + + + + + File: oauth2-2.0.13.gem + + — Documentation by YARD 0.9.37 + + + + + + + + + + + + + + + + + + + +
    + + +

    3bfe481d98f859f37f3b90ced2b8856a843eef0f2e0263163cccc14430047bc3cd03d28597f48daa3d623b52d692c3b3e7c2dc26df5eb588dd82d28608fba639

    +
    + + + +
    + + \ No newline at end of file diff --git a/docs/file.oauth2.html b/docs/file.oauth2.html index 575122d0..5ca07d80 100644 --- a/docs/file.oauth2.html +++ b/docs/file.oauth2.html @@ -69,7 +69,7 @@ diff --git a/docs/file.response.html b/docs/file.response.html index 1208f24b..6eef2f43 100644 --- a/docs/file.response.html +++ b/docs/file.response.html @@ -77,7 +77,7 @@ diff --git a/docs/file.strategy.html b/docs/file.strategy.html index 1d74d472..86173f0f 100644 --- a/docs/file.strategy.html +++ b/docs/file.strategy.html @@ -93,7 +93,7 @@ diff --git a/docs/file.version.html b/docs/file.version.html index 0d97cbcf..14bb9040 100644 --- a/docs/file.version.html +++ b/docs/file.version.html @@ -65,7 +65,7 @@ diff --git a/docs/file_list.html b/docs/file_list.html index 95fe7792..0f55bc81 100644 --- a/docs/file_list.html +++ b/docs/file_list.html @@ -87,6 +87,101 @@

    File List

    +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + diff --git a/docs/index.html b/docs/index.html index ec35c16a..4bdbc8bd 100644 --- a/docs/index.html +++ b/docs/index.html @@ -826,6 +826,26 @@

    OAuth2::Error

    Authorization Grants

    +

    Note on OAuth 2.1 (draft):

    +
      +
    • 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.
    • +
    • Redirect URIs must be compared using exact string matching by the Authorization Server.
    • +
    • The Implicit grant (response_type=token) and the 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.
    • +
    • Bearer tokens in the query string are omitted due to security risks; prefer Authorization header usage.
    • +
    • Refresh tokens for public clients must either be sender-constrained (e.g., DPoP/MTLS) or one-time use.
    • +
    • The definitions of public and confidential clients are simplified to refer only to whether the client has credentials.
    • +
    + +

    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/
    • +
    +

    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,
    @@ -1160,7 +1180,7 @@

    🔐 Security

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

    @@ -1306,7 +1326,7 @@

    Please give the project a star ⭐ ♥ diff --git a/docs/top-level-namespace.html b/docs/top-level-namespace.html index 785e5eb9..2c7379c1 100644 --- a/docs/top-level-namespace.html +++ b/docs/top-level-namespace.html @@ -100,7 +100,7 @@

    Defined Under Namespace

    diff --git a/lib/oauth2/access_token.rb b/lib/oauth2/access_token.rb index c5607392..57b95b10 100644 --- a/lib/oauth2/access_token.rb +++ b/lib/oauth2/access_token.rb @@ -376,6 +376,8 @@ def configure_authentication!(opts) opts[:headers] ||= {} opts[:headers].merge!(headers) when :query + # OAuth 2.1 note: Bearer tokens in the query string are omitted from the spec due to security risks. + # Prefer the default :header mode whenever possible. opts[:params] ||= {} opts[:params][options[:param_name]] = token when :body diff --git a/lib/oauth2/client.rb b/lib/oauth2/client.rb index 193e95c4..7c64c3c1 100644 --- a/lib/oauth2/client.rb +++ b/lib/oauth2/client.rb @@ -321,6 +321,9 @@ def assertion # requesting authorization. If it is provided at authorization time it MUST # also be provided with the token exchange request. # + # OAuth 2.1 note: Authorization Servers must compare redirect URIs using exact string matching. + # This client simply forwards the configured redirect_uri; the exact-match validation happens server-side. + # # Providing :redirect_uri to the OAuth2::Client instantiation will take # care of managing this. # @@ -330,6 +333,7 @@ def assertion # @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.3 # @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.2.1 # @see https://datatracker.ietf.org/doc/html/rfc6749#section-10.6 + # @see https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13 # # @return [Hash] the params to add to a request or URL def redirection_params diff --git a/lib/oauth2/strategy/auth_code.rb b/lib/oauth2/strategy/auth_code.rb index 96eedf5d..ff909a37 100644 --- a/lib/oauth2/strategy/auth_code.rb +++ b/lib/oauth2/strategy/auth_code.rb @@ -4,6 +4,16 @@ module OAuth2 module Strategy # The Authorization Code Strategy # + # OAuth 2.1 notes: + # - PKCE is required for all OAuth clients using the authorization code flow (especially public clients). + # This library does not enforce PKCE generation/verification; implement PKCE in your application when required. + # - Redirect URIs must be compared using exact string matching by the Authorization Server. + # This client forwards redirect_uri but does not perform server-side validation. + # + # References: + # - OAuth 2.1 draft: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13 + # - OAuth for native apps (RFC 8252) and PKCE (RFC 7636) + # # @see http://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-15#section-4.1 class AuthCode < Base # The required query parameters for the authorize URL diff --git a/lib/oauth2/strategy/implicit.rb b/lib/oauth2/strategy/implicit.rb index e9efe5c2..8dfd0a64 100644 --- a/lib/oauth2/strategy/implicit.rb +++ b/lib/oauth2/strategy/implicit.rb @@ -4,6 +4,14 @@ module OAuth2 module Strategy # 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/ + # # @see http://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-26#section-4.2 class Implicit < Base # The required query parameters for the authorize URL diff --git a/lib/oauth2/strategy/password.rb b/lib/oauth2/strategy/password.rb index 79acf654..9621e684 100644 --- a/lib/oauth2/strategy/password.rb +++ b/lib/oauth2/strategy/password.rb @@ -4,6 +4,14 @@ module OAuth2 module Strategy # The Resource Owner Password Credentials Authorization Strategy # + # IMPORTANT (OAuth 2.1): The Resource Owner Password Credentials grant is omitted in OAuth 2.1. + # It remains here for backward compatibility with OAuth 2.0 providers. Prefer Authorization Code + PKCE. + # + # References: + # - OAuth 2.1 draft: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13 + # - Okta explainer: https://developer.okta.com/blog/2019/12/13/oauth-2-1-how-many-rfcs + # - FusionAuth blog: https://fusionauth.io/blog/2020/04/15/whats-new-in-oauth-2-1 + # # @see http://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-15#section-4.3 class Password < Base # Not used for this strategy