grape-jwt-authentication 3.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d39f954c1709be8bcf40890427ce3c5903cbf1a3e354efe46ade4ef2d9e8d086
4
- data.tar.gz: ccbf4143b8fc1258bb3235e1b910aa8b3bca2c0d118b00ef03251447d447cce7
3
+ metadata.gz: 2dc344933b04d2166715f0580af0d4e6904bfc36430e85d8258776d0eae5ba4b
4
+ data.tar.gz: 6969bbc278b237497418be8b35362a5be11c0b0013647760bd44da33cfdf8d0e
5
5
  SHA512:
6
- metadata.gz: 89c29d5a661bc6d865d19193ae60c8310072281cc92b4e2501038d6a7038e9b7a1c20baa0b38c0e414c855a1800f49f1a986df9571e1e179387c5ccb3e3283fb
7
- data.tar.gz: 1f7bd448ee6e7cd6323c1e24b05ab2ac928359bc906b81d3d6e4d3ab58847c833790d81d4e785efae7d4fe89941d26fafd632627fadf7966cef11d19f7fed0a4
6
+ metadata.gz: 815ed44f92461b67e059b35b746549fd0139acd3641b13b691561848ce8d80833b672bcced0699cde2bdcd429732e6974cf2619fe2f9ae1c6e6509bba3fc14df
7
+ data.tar.gz: bb06cd6e6640293be1930caaae50cbd762bd989dc2d8974acc7656241d7af256bd877557991e242d83590675fb04a66179d22ec59d5e255ac7ef4218087743c2
@@ -16,7 +16,7 @@ jobs:
16
16
  docs:
17
17
  name: Release the gem
18
18
  runs-on: ubuntu-22.04
19
- timeout-minutes: 5
19
+ timeout-minutes: 10
20
20
  steps:
21
21
  - uses: actions/checkout@v4
22
22
 
@@ -11,7 +11,7 @@ concurrency:
11
11
  cancel-in-progress: true
12
12
 
13
13
  jobs:
14
- test:
14
+ test-rails:
15
15
  name: 'Test the gem (Ruby ${{ matrix.ruby }}, Rails ${{ matrix.rails }})'
16
16
  runs-on: ubuntu-22.04
17
17
  timeout-minutes: 5
@@ -19,7 +19,7 @@ jobs:
19
19
  fail-fast: false
20
20
  matrix:
21
21
  ruby: ['3.2', '3.3', '3.4']
22
- rails: ['7.1', '7.2', '8.0']
22
+ rails: ['7.1', '7.2', '8.0', '8.1']
23
23
  env:
24
24
  BUNDLE_GEMFILE: 'gemfiles/rails_${{ matrix.rails }}.gemfile'
25
25
  steps:
@@ -45,3 +45,38 @@ jobs:
45
45
 
46
46
  - name: Upload the code coverage report
47
47
  run: coverage
48
+
49
+ test-grape:
50
+ name: 'Test the gem (Ruby ${{ matrix.ruby }}, Grape ${{ matrix.grape }})'
51
+ runs-on: ubuntu-22.04
52
+ timeout-minutes: 5
53
+ strategy:
54
+ fail-fast: false
55
+ matrix:
56
+ ruby: ['3.2', '3.3', '3.4']
57
+ grape: ['1', '2', '3']
58
+ env:
59
+ BUNDLE_GEMFILE: 'gemfiles/grape_${{ matrix.grape }}.gemfile'
60
+ steps:
61
+ - uses: actions/checkout@v4
62
+
63
+ - name: Install the correct Ruby version
64
+ uses: ruby/setup-ruby@v1
65
+ with:
66
+ ruby-version: ${{ matrix.ruby }}
67
+ bundler-cache: true
68
+ rubygems: '3.6.9'
69
+
70
+ - name: Prepare the virtual environment
71
+ uses: hausgold/actions/ci@master
72
+ with:
73
+ clone_token: '${{ secrets.CLONE_TOKEN }}'
74
+ settings_secret_key: '${{ secrets.SETTINGS_SECRET_KEY }}'
75
+ settings: '${{ github.repository }}'
76
+ target: ci/gem-test
77
+
78
+ - name: Run the gem tests
79
+ run: make test
80
+
81
+ - name: Upload the code coverage report
82
+ run: coverage
data/.rubocop.yml CHANGED
@@ -13,7 +13,7 @@ AllCops:
13
13
  SuggestExtensions: false
14
14
  DisplayCopNames: true
15
15
  TargetRubyVersion: 3.2
16
- TargetRailsVersion: 6.1
16
+ TargetRailsVersion: 7.1
17
17
  Exclude:
18
18
  - bin/**/*
19
19
  - vendor/**/*
data/Appraisals CHANGED
@@ -17,3 +17,21 @@ appraise 'rails-8.0' do
17
17
  gem 'activerecord', '~> 8.0.0'
18
18
  gem 'activesupport', '~> 8.0.0'
19
19
  end
20
+
21
+ appraise 'rails-8.1' do
22
+ gem 'activejob', '~> 8.1.0'
23
+ gem 'activerecord', '~> 8.1.0'
24
+ gem 'activesupport', '~> 8.1.0'
25
+ end
26
+
27
+ appraise 'grape-1' do
28
+ gem 'grape', '~> 1.8.0'
29
+ end
30
+
31
+ appraise 'grape-2' do
32
+ gem 'grape', '~> 2.4.0'
33
+ end
34
+
35
+ appraise 'grape-3' do
36
+ gem 'grape', '~> 3.0.0'
37
+ end
data/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  * TODO: Replace this bullet point with an actual description of a change.
4
4
 
5
+ ### 3.2.0 (2 December 2025)
6
+
7
+ * Added appraisals for Grape 1, 2 and 3 and loosed up the version requirement
8
+ to `>= 1, < 4.0` ([#28](https://github.com/hausgold/grape-jwt-authentication/pull/28))
9
+ * Loosed up the version requirement for the `jwt` gem to `>= 2.6`, so people
10
+ can [migrate to
11
+ 3.0+](https://github.com/jwt/ruby-jwt/blob/v3.1.2/UPGRADING.md) ([#28](https://github.com/hausgold/grape-jwt-authentication/pull/28))
12
+
13
+ ### 3.1.0 (23 October 2025)
14
+
15
+ * Dropped Reek ([#24](https://github.com/hausgold/grape-jwt-authentication/pull/24))
16
+ * Added support for Rails 8.1 ([#25](https://github.com/hausgold/grape-jwt-authentication/pull/25))
17
+ * Switched from `ActiveSupport::Configurable` to a custom implementation based
18
+ on `ActiveSupport::OrderedOptions` ([#26](https://github.com/hausgold/grape-jwt-authentication/pull/26))
19
+
5
20
  ### 3.0.0 (28 June 2025)
6
21
 
7
22
  * Corrected some RuboCop glitches ([#21](https://github.com/hausgold/grape-jwt-authentication/pull/21))
data/Gemfile CHANGED
@@ -10,7 +10,7 @@ gemspec
10
10
  # Development dependencies
11
11
  gem 'appraisal', '~> 2.4'
12
12
  gem 'bundler', '~> 2.6'
13
- gem 'countless', '~> 2.0'
13
+ gem 'countless', '~> 2.2'
14
14
  gem 'guard-rspec', '~> 4.7'
15
15
  gem 'rack', '~> 2.2'
16
16
  gem 'rack-test', '~> 2.0'
@@ -0,0 +1,25 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", "~> 2.4"
6
+ gem "bundler", "~> 2.6"
7
+ gem "countless", "~> 2.2"
8
+ gem "guard-rspec", "~> 4.7"
9
+ gem "rack", "~> 2.2"
10
+ gem "rack-test", "~> 2.0"
11
+ gem "railties", ">= 7.1"
12
+ gem "rake", "~> 13.0"
13
+ gem "rspec", "~> 3.12"
14
+ gem "rubocop"
15
+ gem "rubocop-rails"
16
+ gem "rubocop-rspec"
17
+ gem "simplecov", ">= 0.22"
18
+ gem "timecop", ">= 0.9.6"
19
+ gem "vcr", "~> 6.0"
20
+ gem "webmock", "~> 3.18"
21
+ gem "yard", ">= 0.9.28"
22
+ gem "yard-activesupport-concern", ">= 0.0.1"
23
+ gem "grape", "~> 1.8.0"
24
+
25
+ gemspec path: "../"
@@ -0,0 +1,25 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", "~> 2.4"
6
+ gem "bundler", "~> 2.6"
7
+ gem "countless", "~> 2.2"
8
+ gem "guard-rspec", "~> 4.7"
9
+ gem "rack", "~> 2.2"
10
+ gem "rack-test", "~> 2.0"
11
+ gem "railties", ">= 7.1"
12
+ gem "rake", "~> 13.0"
13
+ gem "rspec", "~> 3.12"
14
+ gem "rubocop"
15
+ gem "rubocop-rails"
16
+ gem "rubocop-rspec"
17
+ gem "simplecov", ">= 0.22"
18
+ gem "timecop", ">= 0.9.6"
19
+ gem "vcr", "~> 6.0"
20
+ gem "webmock", "~> 3.18"
21
+ gem "yard", ">= 0.9.28"
22
+ gem "yard-activesupport-concern", ">= 0.0.1"
23
+ gem "grape", "~> 2.4.0"
24
+
25
+ gemspec path: "../"
@@ -0,0 +1,25 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", "~> 2.4"
6
+ gem "bundler", "~> 2.6"
7
+ gem "countless", "~> 2.2"
8
+ gem "guard-rspec", "~> 4.7"
9
+ gem "rack", "~> 2.2"
10
+ gem "rack-test", "~> 2.0"
11
+ gem "railties", ">= 7.1"
12
+ gem "rake", "~> 13.0"
13
+ gem "rspec", "~> 3.12"
14
+ gem "rubocop"
15
+ gem "rubocop-rails"
16
+ gem "rubocop-rspec"
17
+ gem "simplecov", ">= 0.22"
18
+ gem "timecop", ">= 0.9.6"
19
+ gem "vcr", "~> 6.0"
20
+ gem "webmock", "~> 3.18"
21
+ gem "yard", ">= 0.9.28"
22
+ gem "yard-activesupport-concern", ">= 0.0.1"
23
+ gem "grape", "~> 3.0.0"
24
+
25
+ gemspec path: "../"
@@ -4,7 +4,7 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "~> 2.4"
6
6
  gem "bundler", "~> 2.6"
7
- gem "countless", "~> 2.0"
7
+ gem "countless", "~> 2.2"
8
8
  gem "guard-rspec", "~> 4.7"
9
9
  gem "rack", "~> 2.2"
10
10
  gem "rack-test", "~> 2.0"
@@ -4,7 +4,7 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "~> 2.4"
6
6
  gem "bundler", "~> 2.6"
7
- gem "countless", "~> 2.0"
7
+ gem "countless", "~> 2.2"
8
8
  gem "guard-rspec", "~> 4.7"
9
9
  gem "rack", "~> 2.2"
10
10
  gem "rack-test", "~> 2.0"
@@ -4,7 +4,7 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "~> 2.4"
6
6
  gem "bundler", "~> 2.6"
7
- gem "countless", "~> 2.0"
7
+ gem "countless", "~> 2.2"
8
8
  gem "guard-rspec", "~> 4.7"
9
9
  gem "rack", "~> 2.2"
10
10
  gem "rack-test", "~> 2.0"
@@ -0,0 +1,27 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", "~> 2.4"
6
+ gem "bundler", "~> 2.6"
7
+ gem "countless", "~> 2.2"
8
+ gem "guard-rspec", "~> 4.7"
9
+ gem "rack", "~> 2.2"
10
+ gem "rack-test", "~> 2.0"
11
+ gem "railties", ">= 7.1"
12
+ gem "rake", "~> 13.0"
13
+ gem "rspec", "~> 3.12"
14
+ gem "rubocop"
15
+ gem "rubocop-rails"
16
+ gem "rubocop-rspec"
17
+ gem "simplecov", ">= 0.22"
18
+ gem "timecop", ">= 0.9.6"
19
+ gem "vcr", "~> 6.0"
20
+ gem "webmock", "~> 3.18"
21
+ gem "yard", ">= 0.9.28"
22
+ gem "yard-activesupport-concern", ">= 0.0.1"
23
+ gem "activejob", "~> 8.1.0"
24
+ gem "activerecord", "~> 8.1.0"
25
+ gem "activesupport", "~> 8.1.0"
26
+
27
+ gemspec path: "../"
@@ -34,11 +34,11 @@ Gem::Specification.new do |spec|
34
34
  spec.required_ruby_version = '>= 3.2'
35
35
 
36
36
  spec.add_dependency 'activesupport', '>= 7.1'
37
- spec.add_dependency 'grape', '>= 1.0', '< 3.0'
37
+ spec.add_dependency 'grape', '>= 1.0', '< 4.0'
38
38
  spec.add_dependency 'httparty', '>= 0.21'
39
- spec.add_dependency 'jwt', '~> 2.6'
40
- spec.add_dependency 'keyless', '~> 2.0'
41
- spec.add_dependency 'mutex_m', '~> 0.3.0'
39
+ spec.add_dependency 'jwt', '>= 2.6'
40
+ spec.add_dependency 'keyless', '~> 2.1'
41
+ spec.add_dependency 'mutex_m', '>= 0.3'
42
42
  spec.add_dependency 'recursive-open-struct', '~> 2.0'
43
43
  spec.add_dependency 'zeitwerk', '~> 2.6'
44
44
  end
@@ -4,8 +4,46 @@ module Grape
4
4
  module Jwt
5
5
  module Authentication
6
6
  # The configuration for the Grape JWT authentication concern.
7
- class Configuration
8
- include ActiveSupport::Configurable
7
+ class Configuration < ActiveSupport::OrderedOptions
8
+ # Track our configurations settings (+Symbol+ keys) and their defaults
9
+ # as lazy-loaded +Proc+'s values
10
+ class_attribute :defaults,
11
+ instance_reader: true,
12
+ instance_writer: false,
13
+ instance_predicate: false,
14
+ default: {}
15
+
16
+ # Create a new +Configuration+ instance with all settings populated
17
+ # with their respective defaults.
18
+ #
19
+ # @param args [Hash{Symbol => Mixed}] additional settings which
20
+ # overwrite the defaults
21
+ # @return [Configuration] the new configuration instance
22
+ def initialize(**args)
23
+ super()
24
+ defaults.each { |key, default| self[key] = instance_exec(&default) }
25
+ merge!(**args)
26
+ end
27
+
28
+ # A simple DSL method to define new configuration accessors/settings
29
+ # with their defaults. The defaults can be retrieved with
30
+ # +Configuration.defaults+ or +Configuration.new.defaults+.
31
+ #
32
+ # @param name [Symbol, String] the name of the configuration
33
+ # accessor/setting
34
+ # @param default [Mixed, nil] a non-lazy-loaded static value, serving
35
+ # as a default value for the setting
36
+ # @param block [Proc] when given, the default value will be lazy-loaded
37
+ # (result of the Proc)
38
+ def self.config_accessor(name, default = nil, &block)
39
+ # Save the given configuration accessor default value
40
+ defaults[name.to_sym] = block || -> { default }
41
+
42
+ # Compile reader/writer methods so we don't have to go through
43
+ # +ActiveSupport::OrderedOptions#method_missing+.
44
+ define_method(name) { self[name] }
45
+ define_method("#{name}=") { |value| self[name] = value }
46
+ end
9
47
 
10
48
  # The authenticator function which must be defined by the user to
11
49
  # verify the given JSON Web Token. Here comes all your logic to lookup
@@ -102,8 +102,6 @@ module Grape
102
102
  # interface.
103
103
  #
104
104
  # @param env [Hash{String => Mixed}] the Rack environment
105
- # because thats the auth handling core
106
- # :reek:TooManyStatements because reek counts exception
107
105
  def call(env)
108
106
  # Unfortunately Grape's middleware stack orders the error
109
107
  # handling higher than the formatter. So when a error is
@@ -5,7 +5,7 @@ module Grape
5
5
  # The gem version details.
6
6
  module Authentication
7
7
  # The version of the +grape-jwt-authentication+ gem
8
- VERSION = '3.0.0'
8
+ VERSION = '3.2.0'
9
9
 
10
10
  class << self
11
11
  # Returns the version of gem as a string.
@@ -4,8 +4,9 @@ require 'zeitwerk'
4
4
  require 'logger'
5
5
  require 'active_support'
6
6
  require 'active_support/concern'
7
- require 'active_support/configurable'
8
7
  require 'active_support/cache'
8
+ require 'active_support/ordered_options'
9
+ require 'active_support/core_ext/class/attribute'
9
10
  require 'active_support/core_ext/hash'
10
11
  require 'active_support/time'
11
12
  require 'active_support/time_with_zone'
@@ -18,7 +19,6 @@ module Grape
18
19
  # The Grape JWT authentication concern.
19
20
  module Authentication
20
21
  extend ActiveSupport::Concern
21
- include Grape::DSL::API
22
22
 
23
23
  # Setup a Zeitwerk autoloader instance and configure it
24
24
  loader = Zeitwerk::Loader.for_gem_extension(Grape::Jwt)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-jwt-authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hermann Mayer
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '1.0'
33
33
  - - "<"
34
34
  - !ruby/object:Gem::Version
35
- version: '3.0'
35
+ version: '4.0'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  version: '1.0'
43
43
  - - "<"
44
44
  - !ruby/object:Gem::Version
45
- version: '3.0'
45
+ version: '4.0'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: httparty
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -61,14 +61,14 @@ dependencies:
61
61
  name: jwt
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - "~>"
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
66
  version: '2.6'
67
67
  type: :runtime
68
68
  prerelease: false
69
69
  version_requirements: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - "~>"
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: '2.6'
74
74
  - !ruby/object:Gem::Dependency
@@ -77,28 +77,28 @@ dependencies:
77
77
  requirements:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
- version: '2.0'
80
+ version: '2.1'
81
81
  type: :runtime
82
82
  prerelease: false
83
83
  version_requirements: !ruby/object:Gem::Requirement
84
84
  requirements:
85
85
  - - "~>"
86
86
  - !ruby/object:Gem::Version
87
- version: '2.0'
87
+ version: '2.1'
88
88
  - !ruby/object:Gem::Dependency
89
89
  name: mutex_m
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - "~>"
92
+ - - ">="
93
93
  - !ruby/object:Gem::Version
94
- version: 0.3.0
94
+ version: '0.3'
95
95
  type: :runtime
96
96
  prerelease: false
97
97
  version_requirements: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - "~>"
99
+ - - ">="
100
100
  - !ruby/object:Gem::Version
101
- version: 0.3.0
101
+ version: '0.3'
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: recursive-open-struct
104
104
  requirement: !ruby/object:Gem::Requirement
@@ -160,10 +160,14 @@ files:
160
160
  - config/docker/.inputrc
161
161
  - doc/assets/project.svg
162
162
  - docker-compose.yml
163
+ - gemfiles/grape_1.gemfile
164
+ - gemfiles/grape_2.gemfile
165
+ - gemfiles/grape_3.gemfile
163
166
  - gemfiles/rails_6.1.gemfile
164
167
  - gemfiles/rails_7.1.gemfile
165
168
  - gemfiles/rails_7.2.gemfile
166
169
  - gemfiles/rails_8.0.gemfile
170
+ - gemfiles/rails_8.1.gemfile
167
171
  - grape-jwt-authentication.gemspec
168
172
  - lib/grape/jwt/authentication.rb
169
173
  - lib/grape/jwt/authentication/configuration.rb