grape-jwt-authentication 2.6.0 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 806ea5f8a57adf5d7f5f108b520a1907596686c3594d330dc9660bb90156e48b
4
- data.tar.gz: 52d600d07ec641f69e58b448205ea9f9534bab6525044000cc15b1cd98578207
3
+ metadata.gz: bafce52c8e698421232325dfe9f003a9251b5100bddaa3cc5698f61033e557b9
4
+ data.tar.gz: c0f3224f38a1c814e67c73087edac614e7557aa9204c0e594b7855c8357af912
5
5
  SHA512:
6
- metadata.gz: d67750bc92e94121aeb3ab225b9ede7d0f54334cd8e382e093819a3fc5c824cdfaddada8d49575bf350c6709b48aad527ddfa9a6c2a16f881c3dc6f560f9bf06
7
- data.tar.gz: 04d4eba3d28f9a95648baa72a2d087ddc21271ea409846505c20d04a960353da070dea25dc446bf905954d7b053289657b492e867e06cebbb234e0364be2cb98
6
+ metadata.gz: ff0cb1bfb59949634037f53ac28f1b3b461556842d6076a807da33a1d12184a88242b276d33f06e437f8b3973678f8001c06ab6476f50b001b84fc980712a54c
7
+ data.tar.gz: 1fd927cdf3b6565773aee13c02c744aa8b9041adaabc888d7d37ca2836f98e4a6b68cd7bc3e5296f4d4442c1b4e4af4b78b0412e40c1b3ed41521e5d03cfc084
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  * TODO: Replace this bullet point with an actual description of a change.
4
4
 
5
+ ### 2.7.1 (17 January 2025)
6
+
7
+ * Added the logger dependency (#18)
8
+
9
+ ### 2.7.0 (11 January 2025)
10
+
11
+ * Switched to Zeitwerk as autoloader (#17)
12
+
5
13
  ### 2.6.0 (3 January 2025)
6
14
 
7
15
  * Raised minimum supported Ruby/Rails version to 2.7/6.1 (#16)
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency 'grape', '>= 1.0', '< 3.0'
38
38
  spec.add_dependency 'httparty', '>= 0.21'
39
39
  spec.add_dependency 'jwt', '~> 2.6'
40
- spec.add_dependency 'keyless', '~> 1.4'
40
+ spec.add_dependency 'keyless', '~> 1.6'
41
41
  spec.add_dependency 'recursive-open-struct', '~> 2.0'
42
+ spec.add_dependency 'zeitwerk', '~> 2.6'
42
43
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Grape
4
+ module Jwt
5
+ module Authentication
6
+ module Extensions
7
+ # Root-level handling of dependencies.
8
+ module Dependencies
9
+ # Specifies which configuration keys are shared between keyless
10
+ # and grape-jwt-authentication, so that we can easily pass through
11
+ # our configuration to keyless.
12
+ KEYLESS_CONFIGURATION = %i[
13
+ authenticator rsa_public_key_url rsa_public_key_caching
14
+ rsa_public_key_expiration jwt_issuer jwt_beholder jwt_options
15
+ jwt_verification_key
16
+ ].freeze
17
+
18
+ # (Re)configure our gem dependencies. We take care of setting up
19
+ # +Keyless+, which has been extracted from this gem.
20
+ def configure_dependencies
21
+ configure_keyless
22
+ end
23
+
24
+ # Configure the +Keyless+ gem with our configuration.
25
+ def configure_keyless
26
+ configuration = Grape::Jwt::Authentication.configuration
27
+
28
+ Keyless.configure do |keyless|
29
+ KEYLESS_CONFIGURATION.each do |option|
30
+ keyless.send("#{option}=", configuration.send(option))
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -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 = '2.6.0'
8
+ VERSION = '2.7.1'
9
9
 
10
10
  class << self
11
11
  # Returns the version of gem as a string.
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'zeitwerk'
4
+ require 'logger'
3
5
  require 'active_support'
4
6
  require 'active_support/concern'
5
7
  require 'active_support/configurable'
@@ -10,10 +12,6 @@ require 'active_support/time_with_zone'
10
12
  require 'jwt'
11
13
  require 'keyless'
12
14
  require 'grape'
13
- require 'grape/jwt/authentication/version'
14
- require 'grape/jwt/authentication/configuration'
15
- require 'grape/jwt/authentication/dependencies'
16
- require 'grape/jwt/authentication/jwt_handler'
17
15
 
18
16
  module Grape
19
17
  module Jwt
@@ -22,32 +20,44 @@ module Grape
22
20
  extend ActiveSupport::Concern
23
21
  include Grape::DSL::API
24
22
 
23
+ # Setup a Zeitwerk autoloader instance and configure it
24
+ loader = Zeitwerk::Loader.for_gem_extension(Grape::Jwt)
25
+
26
+ # Finish the auto loader configuration
27
+ loader.setup
28
+
29
+ # Make sure to eager load all constants
30
+ loader.eager_load
31
+
25
32
  class << self
26
33
  attr_writer :configuration
27
- end
28
34
 
29
- # Retrieve the current configuration object.
30
- #
31
- # @return [Configuration]
32
- def self.configuration
33
- @configuration ||= Configuration.new
34
- end
35
+ # Include top-level features
36
+ include Extensions::Dependencies
35
37
 
36
- # Configure the concern by providing a block which takes
37
- # care of this task. Example:
38
- #
39
- # Grape::Jwt::Authentication.configure do |conf|
40
- # # conf.xyz = [..]
41
- # end
42
- def self.configure
43
- yield(configuration)
44
- configure_dependencies
45
- end
38
+ # Retrieve the current configuration object.
39
+ #
40
+ # @return [Configuration]
41
+ def configuration
42
+ @configuration ||= Configuration.new
43
+ end
46
44
 
47
- # Reset the current configuration with the default one.
48
- def self.reset_configuration!
49
- self.configuration = Configuration.new
50
- configure_dependencies
45
+ # Configure the concern by providing a block which takes
46
+ # care of this task. Example:
47
+ #
48
+ # Grape::Jwt::Authentication.configure do |conf|
49
+ # # conf.xyz = [..]
50
+ # end
51
+ def configure
52
+ yield(configuration)
53
+ configure_dependencies
54
+ end
55
+
56
+ # Reset the current configuration with the default one.
57
+ def reset_configuration!
58
+ self.configuration = Configuration.new
59
+ configure_dependencies
60
+ end
51
61
  end
52
62
 
53
63
  included do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-jwt-authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hermann Mayer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-03 00:00:00.000000000 Z
11
+ date: 2025-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '1.4'
81
+ version: '1.6'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '1.4'
88
+ version: '1.6'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: recursive-open-struct
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -100,6 +100,20 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '2.0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: zeitwerk
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '2.6'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '2.6'
103
117
  description: A reusable Grape JWT authentication concern
104
118
  email:
105
119
  - hermann.mayer92@gmail.com
@@ -138,7 +152,7 @@ files:
138
152
  - grape-jwt-authentication.gemspec
139
153
  - lib/grape/jwt/authentication.rb
140
154
  - lib/grape/jwt/authentication/configuration.rb
141
- - lib/grape/jwt/authentication/dependencies.rb
155
+ - lib/grape/jwt/authentication/extensions/dependencies.rb
142
156
  - lib/grape/jwt/authentication/jwt_handler.rb
143
157
  - lib/grape/jwt/authentication/version.rb
144
158
  homepage:
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grape
4
- module Jwt
5
- # The Grape JWT authentication concern.
6
- module Authentication
7
- # Specifies which configuration keys are shared between keyless
8
- # and grape-jwt-authentication, so that we can easily pass through
9
- # our configuration to keyless.
10
- KEYLESS_CONFIGURATION = %i[
11
- authenticator rsa_public_key_url rsa_public_key_caching
12
- rsa_public_key_expiration jwt_issuer jwt_beholder jwt_options
13
- jwt_verification_key
14
- ].freeze
15
-
16
- # (Re)configure our gem dependencies. We take care of setting up
17
- # +Keyless+, which has been extracted from this gem.
18
- def self.configure_dependencies
19
- configure_keyless
20
- end
21
-
22
- # Configure the +Keyless+ gem with our configuration.
23
- def self.configure_keyless
24
- configuration = Grape::Jwt::Authentication.configuration
25
-
26
- Keyless.configure do |keyless|
27
- KEYLESS_CONFIGURATION.each do |option|
28
- keyless.send("#{option}=", configuration.send(option))
29
- end
30
- end
31
- end
32
- end
33
- end
34
- end