diff --git a/.idea/oauth2.iml b/.idea/oauth2.iml index 046be677..f48115c5 100755 --- a/.idea/oauth2.iml +++ b/.idea/oauth2.iml @@ -24,9 +24,10 @@ - + + @@ -45,12 +46,13 @@ + - + @@ -62,26 +64,26 @@ - + - + - + - + - + @@ -91,7 +93,7 @@ - + @@ -116,7 +118,7 @@ - + @@ -126,10 +128,12 @@ - - + + + + diff --git a/.rubocop_gradual.lock b/.rubocop_gradual.lock index 6bf6e50c..9a28e666 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:3678262936": [ + "lib/oauth2/access_token.rb:707681139": [ [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] ], @@ -21,11 +21,11 @@ "lib/oauth2/response.rb:2054901929": [ [53, 5, 204, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 996912427] ], - "spec/oauth2/access_token_spec.rb:3464059918": [ + "spec/oauth2/access_token_spec.rb:3152504592": [ [3, 1, 34, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/access_token*_spec.rb`.", 1972107547], - [824, 13, 25, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 770233088], - [894, 9, 101, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3022740639], - [898, 9, 79, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 2507338967] + [854, 13, 25, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 770233088], + [924, 9, 101, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3022740639], + [928, 9, 79, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 2507338967] ], "spec/oauth2/authenticator_spec.rb:853320290": [ [3, 1, 36, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/authenticator*_spec.rb`.", 819808017], diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e615f86..9090ef40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Please file a bug if you notice a violation of semantic versioning. ## [Unreleased] ### Added +- [gh!682][gh!682] - AccessToken: support Hash-based verb-dependent token transmission mode (e.g., {get: :query, post: :header}) ### Changed ### Deprecated ### Removed diff --git a/Gemfile.lock b/Gemfile.lock index 6cbdc7f5..086329d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -103,7 +103,7 @@ GEM json (2.13.2) jwt (3.1.2) base64 - kettle-dev (1.1.19) + kettle-dev (1.1.20) kettle-soup-cover (1.0.10) simplecov (~> 0.22) simplecov-cobertura (~> 3.0) @@ -135,7 +135,7 @@ GEM net-http (0.6.0) uri nkf (0.2.0) - nokogiri (1.18.9-x86_64-linux-gnu) + nokogiri (1.18.10-x86_64-linux-gnu) racc (~> 1.4) ostruct (0.6.3) parallel (1.27.0) @@ -165,7 +165,7 @@ GEM parser (~> 3.3.0) rainbow (>= 2.0, < 4.0) rexml (~> 3.1) - regexp_parser (2.11.2) + regexp_parser (2.11.3) reline (0.6.2) io-console (~> 0.5) require_bench (1.0.4) @@ -336,7 +336,7 @@ DEPENDENCIES gem_bench (~> 2.0, >= 2.0.5) gitmoji-regex (~> 1.0, >= 1.0.3) irb (~> 1.15, >= 1.15.2) - kettle-dev (~> 1.1, >= 1.1.9) + kettle-dev (~> 1.1, >= 1.1.20) kettle-soup-cover (~> 1.0, >= 1.0.10) kettle-test (~> 1.0) kramdown (~> 2.5, >= 2.5.1) diff --git a/Rakefile b/Rakefile index 4f67de12..2ed315ed 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,6 @@ # frozen_string_literal: true -# kettle-dev Rakefile v1.1.9 - 2025-09-07 +# kettle-dev Rakefile v1.1.20 - 2025-09-15 # Ruby 2.3 (Safe Navigation) or higher required # # MIT License (see License.txt) diff --git a/docs/OAuth2.html b/docs/OAuth2.html index 4b450b6b..35030b1b 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 0959f022..4ad8d27d 100644 --- a/docs/OAuth2/AccessToken.html +++ b/docs/OAuth2/AccessToken.html @@ -843,7 +843,19 @@

-

Parameters:

+ +
+

Examples:

+ + +

Verb-dependent Hash mode

+
+ +
# Send token in query for GET, in header for POST/DELETE, in body for PUT/PATCH
+OAuth2::AccessToken.new(client, token, mode: {get: :query, post: :header, delete: :header, put: :body, patch: :body})
+ +
+

Parameters:

  • @@ -967,7 +979,7 @@

  • :mode - (Symbol or callable) + (Symbol, Hash, or callable) — default: @@ -976,7 +988,8 @@

    the transmission mode of the Access Token parameter value:
    -either one of :header, :body or :query, or a callable that accepts a request-verb parameter
    +either one of :header, :body or :query; or a Hash with verb symbols as keys mapping to one of these symbols
    +(e.g., :query, post: :header, delete: :header); or a callable that accepts a request-verb parameter
    and returns one of these three symbols.

    @@ -1039,11 +1052,6 @@

     
     
    -143
    -144
    -145
    -146
    -147
     148
     149
     150
    @@ -1072,10 +1080,15 @@ 

    173 174 175 -176

    +176 +177 +178 +179 +180 +181 -
    # File 'lib/oauth2/access_token.rb', line 143
    +      
    # File 'lib/oauth2/access_token.rb', line 148
     
     def initialize(client, token, opts = {})
       @client = client
    @@ -1936,12 +1949,12 @@ 

     
     
    -181
    -182
    -183
    +186 +187 +188

    -
    # File 'lib/oauth2/access_token.rb', line 181
    +      
    # File 'lib/oauth2/access_token.rb', line 186
     
     def [](key)
       @params[key]
    @@ -1983,12 +1996,12 @@ 

     
     
    -363
    -364
    -365
    +368 +369 +370

    -
    # File 'lib/oauth2/access_token.rb', line 363
    +      
    # File 'lib/oauth2/access_token.rb', line 368
     
     def delete(path, opts = {}, &block)
       request(:delete, path, opts, &block)
    @@ -2040,12 +2053,12 @@ 

     
     
    -195
    -196
    -197
    +200 +201 +202

    -
    # File 'lib/oauth2/access_token.rb', line 195
    +      
    # File 'lib/oauth2/access_token.rb', line 200
     
     def expired?
       expires? && (expires_at <= Time.now.to_i)
    @@ -2093,12 +2106,12 @@ 

     
     
    -188
    -189
    -190
    +193 +194 +195

    -
    # File 'lib/oauth2/access_token.rb', line 188
    +      
    # File 'lib/oauth2/access_token.rb', line 193
     
     def expires?
       !!@expires_at
    @@ -2140,12 +2153,12 @@ 

     
     
    -335
    -336
    -337
    +340 +341 +342

    -
    # File 'lib/oauth2/access_token.rb', line 335
    +      
    # File 'lib/oauth2/access_token.rb', line 340
     
     def get(path, opts = {}, &block)
       request(:get, path, opts, &block)
    @@ -2180,12 +2193,12 @@ 

     
     
    -368
    -369
    -370
    +373 +374 +375

    -
    # File 'lib/oauth2/access_token.rb', line 368
    +      
    # File 'lib/oauth2/access_token.rb', line 373
     
     def headers
       {"Authorization" => options[:header_format] % token}
    @@ -2227,12 +2240,12 @@ 

     
     
    -356
    -357
    -358
    +361 +362 +363

    -
    # File 'lib/oauth2/access_token.rb', line 356
    +      
    # File 'lib/oauth2/access_token.rb', line 361
     
     def patch(path, opts = {}, &block)
       request(:patch, path, opts, &block)
    @@ -2274,12 +2287,12 @@ 

     
     
    -342
    -343
    -344
    +347 +348 +349

    -
    # File 'lib/oauth2/access_token.rb', line 342
    +      
    # File 'lib/oauth2/access_token.rb', line 347
     
     def post(path, opts = {}, &block)
       request(:post, path, opts, &block)
    @@ -2321,12 +2334,12 @@ 

     
     
    -349
    -350
    -351
    +354 +355 +356

    -
    # File 'lib/oauth2/access_token.rb', line 349
    +      
    # File 'lib/oauth2/access_token.rb', line 354
     
     def put(path, opts = {}, &block)
       request(:put, path, opts, &block)
    @@ -2476,11 +2489,6 @@ 

     
     
    -210
    -211
    -212
    -213
    -214
     215
     216
     217
    @@ -2489,10 +2497,15 @@ 

    220 221 222 -223

    +223 +224 +225 +226 +227 +228

    -
    # File 'lib/oauth2/access_token.rb', line 210
    +      
    # File 'lib/oauth2/access_token.rb', line 215
     
     def refresh(params = {}, access_token_opts = {}, &block)
       raise OAuth2::Error.new({error: "A refresh_token is not available"}) unless refresh_token
    @@ -2698,13 +2711,13 @@ 

     
     
    -327
    -328
    -329
    -330
    +332 +333 +334 +335

    -
    # File 'lib/oauth2/access_token.rb', line 327
    +      
    # File 'lib/oauth2/access_token.rb', line 332
     
     def request(verb, path, opts = {}, &block)
       configure_authentication!(opts, verb)
    @@ -2912,11 +2925,6 @@ 

     
     
    -259
    -260
    -261
    -262
    -263
     264
     265
     266
    @@ -2936,10 +2944,15 @@ 

    280 281 282 -283

    +283 +284 +285 +286 +287 +288

    -
    # File 'lib/oauth2/access_token.rb', line 259
    +      
    # File 'lib/oauth2/access_token.rb', line 264
     
     def revoke(params = {}, &block)
       token_type_hint_orig = params.delete(:token_type_hint)
    @@ -3020,11 +3033,6 @@ 

     
     
    -293
    -294
    -295
    -296
    -297
     298
     299
     300
    @@ -3037,10 +3045,15 @@ 

    307 308 309 -310

    +310 +311 +312 +313 +314 +315

    -
    # File 'lib/oauth2/access_token.rb', line 293
    +      
    # File 'lib/oauth2/access_token.rb', line 298
     
     def to_hash
       hsh = {
    @@ -3070,7 +3083,7 @@ 

diff --git a/docs/OAuth2/Authenticator.html b/docs/OAuth2/Authenticator.html index 2811778b..06a3780b 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 e10bd0d2..cf8a2109 100644 --- a/docs/OAuth2/Client.html +++ b/docs/OAuth2/Client.html @@ -2656,7 +2656,7 @@

diff --git a/docs/OAuth2/Error.html b/docs/OAuth2/Error.html index 03bf44dd..3223d649 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 eefb4838..99681638 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 7a84acda..1034b9d6 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 3fcf55e8..2a990f03 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 887831eb..8df5ae01 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 5d2e432c..e6a76aef 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 a0372b1e..2e13d4a2 100644 --- a/docs/OAuth2/Strategy/AuthCode.html +++ b/docs/OAuth2/Strategy/AuthCode.html @@ -483,7 +483,7 @@

diff --git a/docs/OAuth2/Strategy/Base.html b/docs/OAuth2/Strategy/Base.html index 54f983c2..2337082c 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 a2309451..b73dc3b5 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 ebfff816..018ccd79 100644 --- a/docs/OAuth2/Strategy/Implicit.html +++ b/docs/OAuth2/Strategy/Implicit.html @@ -420,7 +420,7 @@

diff --git a/docs/OAuth2/Strategy/Password.html b/docs/OAuth2/Strategy/Password.html index 002f5975..59655175 100644 --- a/docs/OAuth2/Strategy/Password.html +++ b/docs/OAuth2/Strategy/Password.html @@ -374,7 +374,7 @@

diff --git a/docs/OAuth2/Version.html b/docs/OAuth2/Version.html index 31e00a4b..ec489e73 100644 --- a/docs/OAuth2/Version.html +++ b/docs/OAuth2/Version.html @@ -95,7 +95,7 @@

VERSION =
-
"2.0.16"
+
"2.0.17"
@@ -111,7 +111,7 @@

diff --git a/docs/_index.html b/docs/_index.html index 59056025..cdfdf40c 100644 --- a/docs/_index.html +++ b/docs/_index.html @@ -108,22 +108,28 @@

File Listing

  • oauth2-2.0.15.gem
  • -
  • oauth2-2.0.10.gem
  • +
  • oauth2-2.0.16.gem
  • -
  • oauth2-2.0.11.gem
  • +
  • oauth2-2.0.10.gem
  • -
  • oauth2-2.0.12.gem
  • +
  • oauth2-2.0.11.gem
  • -
  • oauth2-2.0.13.gem
  • +
  • oauth2-2.0.12.gem
  • -
  • oauth2-2.0.14.gem
  • +
  • oauth2-2.0.13.gem
  • -
  • oauth2-2.0.15.gem
  • +
  • oauth2-2.0.14.gem
  • + + +
  • oauth2-2.0.15.gem
  • + + +
  • oauth2-2.0.16.gem
  • REEK
  • @@ -378,7 +384,7 @@

    Namespace Listing A-Z

    diff --git a/docs/file.CHANGELOG.html b/docs/file.CHANGELOG.html index ba516ac9..1efddcb6 100644 --- a/docs/file.CHANGELOG.html +++ b/docs/file.CHANGELOG.html @@ -68,26 +68,30 @@ and yes, platform and engine support are part of the public API.
    Please file a bug if you notice a violation of semantic versioning.

    -

    Unreleased

    +

    Unreleased

    Added

    -

    Changed

    -

    Deprecated

    -

    Removed

    -

    Fixed

    -

    Security

    +
      +
    • [gh!682][gh!682] - AccessToken: support Hash-based verb-dependent token transmission mode (e.g., :query, post: :header) +

      Changed

      +

      Deprecated

      +

      Removed

      +

      Fixed

      +

      Security

      +
    • +

    2.0.16 - 2025-09-14

    • TAG: v2.0.16
    • -
    • COVERAGE: 96.33% – 394/409 lines in 14 files
    • -
    • BRANCH COVERAGE: 86.49% – 64/74 branches in 14 files
    • +
    • COVERAGE: 100.00% – 520/520 lines in 14 files
    • +
    • BRANCH COVERAGE: 100.00% – 176/176 branches in 14 files
    • 90.48% documented

      Added

    • -gh!680—E2E example using mock test server added in v2.0.11 by @pboling +gh!680 - E2E example using mock test server added in v2.0.11 by @pboling
      • mock-oauth2-server upgraded to v2.3.0
          @@ -108,9 +112,7 @@

          Changed

        • gh!678 - Many improvements to make CI more resilient (past/future proof) by @pboling
        • -gh!681 - Upgrade to kettle-dev v1.1.19 -

          Security

          -
        • +gh!681 - Upgrade to kettle-dev v1.1.19

        @@ -145,9 +147,7 @@

        Changed

        Fixed

      • Remove accidentally duplicated lines, and fix typos in CHANGELOG.md
      • -
      • point badge to the correct workflow for Ruby 2.3 (caboose.yml) -

        Security

        -
      • +
      • point badge to the correct workflow for Ruby 2.3 (caboose.yml)

      @@ -221,7 +221,7 @@

      Fixed

    • gh!660 - Links in README (including link to HEAD documentation) by @pboling -

      Security

      +

      Security

    @@ -1075,7 +1075,7 @@

    diff --git a/docs/file.CITATION.html b/docs/file.CITATION.html index 2daada60..8522f684 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 9fa48115..85888e80 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 0ef50d99..b92d1a33 100644 --- a/docs/file.CONTRIBUTING.html +++ b/docs/file.CONTRIBUTING.html @@ -308,7 +308,7 @@

    Manual process

    diff --git a/docs/file.FUNDING.html b/docs/file.FUNDING.html index ee89d91e..e0e83e3c 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 752c9ba5..f2be648d 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.OIDC.html b/docs/file.OIDC.html index f7006e65..870ca548 100644 --- a/docs/file.OIDC.html +++ b/docs/file.OIDC.html @@ -247,7 +247,7 @@

    Raw OIDC with ruby-oauth/oauth2

    diff --git a/docs/file.README.html b/docs/file.README.html index 42db0a14..f34dcba6 100644 --- a/docs/file.README.html +++ b/docs/file.README.html @@ -1710,7 +1710,7 @@

    Quick Examples

    diff --git a/docs/file.REEK.html b/docs/file.REEK.html index eeff2052..87098180 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 b6fd3e2c..f98a5f49 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 d7bfa31a..d55f9de7 100644 --- a/docs/file.SECURITY.html +++ b/docs/file.SECURITY.html @@ -91,7 +91,7 @@

    Additional Support

    diff --git a/docs/file.access_token.html b/docs/file.access_token.html index 8f66685b..810c5256 100644 --- a/docs/file.access_token.html +++ b/docs/file.access_token.html @@ -76,7 +76,7 @@ def patch: (String, ?Hash[Symbol, untyped]) { (untyped) -> void } -> OAuth2::Response def delete: (String, ?Hash[Symbol, untyped]) { (untyped) -> void } -> OAuth2::Response def headers: () -> Hash[String, String] -def configure_authentication!: (Hash[Symbol, untyped]) -> void +def configure_authentication!: (Hash[Symbol, untyped], Symbol) -> void def convert_expires_at: (untyped) -> (Time | Integer | nil) attr_accessor response: OAuth2::Response end end @@ -84,7 +84,7 @@ diff --git a/docs/file.authenticator.html b/docs/file.authenticator.html index b741b4b3..ce3ec189 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 1d7ab7da..77bfa097 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 66755543..fe09eac2 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 41f8a684..dd951683 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 ef9bf350..7b492fbb 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 48ee4fb8..e71744f2 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 578e1dca..cbb0a54c 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 index 1abda5d5..d03ad420 100644 --- a/docs/file.oauth2-2.0.13.gem.html +++ b/docs/file.oauth2-2.0.13.gem.html @@ -61,7 +61,7 @@ diff --git a/docs/file.oauth2-2.0.14.gem.html b/docs/file.oauth2-2.0.14.gem.html index 8ac8b38c..92d61d7f 100644 --- a/docs/file.oauth2-2.0.14.gem.html +++ b/docs/file.oauth2-2.0.14.gem.html @@ -61,7 +61,7 @@ diff --git a/docs/file.oauth2-2.0.15.gem.html b/docs/file.oauth2-2.0.15.gem.html index 90e30eea..7cef8418 100644 --- a/docs/file.oauth2-2.0.15.gem.html +++ b/docs/file.oauth2-2.0.15.gem.html @@ -61,7 +61,7 @@ diff --git a/docs/file.oauth2-2.0.16.gem.html b/docs/file.oauth2-2.0.16.gem.html new file mode 100644 index 00000000..51df38f1 --- /dev/null +++ b/docs/file.oauth2-2.0.16.gem.html @@ -0,0 +1,71 @@ + + + + + + + File: oauth2-2.0.16.gem + + — Documentation by YARD 0.9.37 + + + + + + + + + + + + + + + + + + + +
    + + +

    49788bf25c3afcc08171f92c3c8a21b4bcd322aae0834f69ae77c08963f54be6c9155588ca66f82022af897ddd0bf28b0c5ee254bc9fe533d1a37b1d52f409be

    +
    + + + +
    + + \ No newline at end of file diff --git a/docs/file.oauth2.html b/docs/file.oauth2.html index d17d9115..c454b754 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 34c124d3..82446338 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 6f85354c..56bb0e5d 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 687d19aa..564a96c6 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 c384e86b..ef094c1a 100644 --- a/docs/file_list.html +++ b/docs/file_list.html @@ -127,36 +127,46 @@

    File List

    -
  • +
  • + +
  • + + +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • -
  • +
  • +
  • + +
  • + +
  • diff --git a/docs/index.html b/docs/index.html index edf6033d..c2dd905b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1710,7 +1710,7 @@

    Quick Examples

    diff --git a/docs/top-level-namespace.html b/docs/top-level-namespace.html index e564502f..3352ccfe 100644 --- a/docs/top-level-namespace.html +++ b/docs/top-level-namespace.html @@ -100,7 +100,7 @@

    Defined Under Namespace

    diff --git a/gemfiles/modular/injected.gemfile b/gemfiles/modular/injected.gemfile index 0b5f8fa7..175b724a 100644 --- a/gemfiles/modular/injected.gemfile +++ b/gemfiles/modular/injected.gemfile @@ -2,7 +2,7 @@ # visibility and discoverability on RubyGems.org. # However, this gem sits underneath all my other gems, and also "depends on" many of them. # So instead of depending on them directly it injects them into the other gem's gemspec on install. -# This gem its injected dev dependencies, will install on Ruby down to 2.3.x. +# This gem, and its injected dev dependencies, will install on Ruby down to 2.3.x. # This gem does not inject runtime dependencies. # Thus, dev dependencies injected into gemspecs must have # diff --git a/lib/oauth2/access_token.rb b/lib/oauth2/access_token.rb index e598d110..c428c019 100644 --- a/lib/oauth2/access_token.rb +++ b/lib/oauth2/access_token.rb @@ -132,10 +132,15 @@ def no_tokens_warning(hash, key) # @option opts [FixNum, String] :expires_in (nil) the number of seconds in which the AccessToken will expire # @option opts [FixNum, String] :expires_at (nil) the epoch time in seconds in which AccessToken will expire # @option opts [FixNum, String] :expires_latency (nil) the number of seconds by which AccessToken validity will be reduced to offset latency, @version 2.0+ - # @option opts [Symbol or callable] :mode (:header) the transmission mode of the Access Token parameter value: - # either one of :header, :body or :query, or a callable that accepts a request-verb parameter + # @option opts [Symbol, Hash, or callable] :mode (:header) the transmission mode of the Access Token parameter value: + # either one of :header, :body or :query; or a Hash with verb symbols as keys mapping to one of these symbols + # (e.g., {get: :query, post: :header, delete: :header}); or a callable that accepts a request-verb parameter # and returns one of these three symbols. # @option opts [String] :header_format ('Bearer %s') the string format to use for the Authorization header + # + # @example Verb-dependent Hash mode + # # Send token in query for GET, in header for POST/DELETE, in body for PUT/PATCH + # OAuth2::AccessToken.new(client, token, mode: {get: :query, post: :header, delete: :header, put: :body, patch: :body}) # @option opts [String] :param_name ('access_token') the parameter name to use for transmission of the # Access Token value in :body or :query transmission mode # @option opts [String] :token_name (nil) the name of the response parameter that identifies the access token @@ -372,7 +377,18 @@ def headers private def configure_authentication!(opts, verb) - mode = options[:mode].respond_to?(:call) ? options[:mode].call(verb) : options[:mode] + mode_opt = options[:mode] + mode = + if mode_opt.respond_to?(:call) + mode_opt.call(verb) + elsif mode_opt.is_a?(Hash) + key = verb.to_sym + # Try symbol key first, then string key; default to :header when missing + mode_opt[key] || mode_opt[key.to_s] || :header + else + mode_opt + end + case mode when :header opts[:headers] ||= {} diff --git a/oauth2.gemspec b/oauth2.gemspec index b3358902..471e279a 100644 --- a/oauth2.gemspec +++ b/oauth2.gemspec @@ -153,7 +153,7 @@ Thanks, @pboling / @galtzo spec.add_development_dependency("rexml", "~> 3.2", ">= 3.2.5") # ruby >= 0 # Dev, Test, & Release Tasks - spec.add_development_dependency("kettle-dev", "~> 1.1", ">= 1.1.9") # ruby >= 2.3 + spec.add_development_dependency("kettle-dev", "~> 1.1", ">= 1.1.20") # ruby >= 2.3.0 # Security spec.add_development_dependency("bundler-audit", "~> 0.9.2") # ruby >= 2.0.0 diff --git a/sig/oauth2/access_token.rbs b/sig/oauth2/access_token.rbs index f2e414e9..06779891 100644 --- a/sig/oauth2/access_token.rbs +++ b/sig/oauth2/access_token.rbs @@ -17,7 +17,7 @@ module OAuth2 def patch: (String, ?Hash[Symbol, untyped]) { (untyped) -> void } -> OAuth2::Response def delete: (String, ?Hash[Symbol, untyped]) { (untyped) -> void } -> OAuth2::Response def headers: () -> Hash[String, String] - def configure_authentication!: (Hash[Symbol, untyped]) -> void + def configure_authentication!: (Hash[Symbol, untyped], Symbol) -> void def convert_expires_at: (untyped) -> (Time | Integer | nil) attr_accessor response: OAuth2::Response diff --git a/spec/oauth2/access_token_spec.rb b/spec/oauth2/access_token_spec.rb index 2234b2cd..97f9a706 100644 --- a/spec/oauth2/access_token_spec.rb +++ b/spec/oauth2/access_token_spec.rb @@ -446,6 +446,36 @@ def assert_initialized_token(target) end end + context "with verb-dependent Hash mode" do + let(:mode_hash) do + {get: :query, post: :header, delete: :header, put: :body, patch: :body} + end + let(:options) { {mode: mode_hash} } + + VERBS.each do |verb| + it "correctly handles a #{verb.to_s.upcase} via Hash" do + expected = mode_hash[verb] || :header + expect(subject.__send__(verb, "/token/#{expected}").body).to include(token) + end + end + + context "with fallback to :header for missing key" do + let(:mode_hash) { {get: :query} } + + it "defaults POST to header when not specified" do + expect(subject.post("/token/header").body).to include(token) + end + end + + context "when invalid value" do + let(:mode_hash) { {get: "foobar"} } + + it "raises an error for invalid mapping" do + expect { subject.get("/token/foobar") }.to raise_error("invalid :mode option of foobar") + end + end + end + context "with client.options[:raise_errors] = false" do let(:options) { {raise_errors: false} }