grape-jwt-authentication 2.6.0 → 2.7.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/grape-jwt-authentication.gemspec +2 -1
- data/lib/grape/jwt/authentication/extensions/dependencies.rb +38 -0
- data/lib/grape/jwt/authentication/version.rb +1 -1
- data/lib/grape/jwt/authentication.rb +34 -25
- metadata +19 -5
- data/lib/grape/jwt/authentication/dependencies.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18bf4cf6b306fb0c9bc7e4661d06ec1ad1c06ca5b98f8dd4c903abbbbece763e
|
4
|
+
data.tar.gz: 63ec416166cb35583f664d2b30c0c8a96fcb708ad83ca6a1f62599d475a278f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eedd2923aa5da56a699323be30d240c045c53dfefa80f7fb69d7c629a0ec7cbddc66028db7de74f275accd91e1be885577c1f74023ee1f61b39684219c04ac98
|
7
|
+
data.tar.gz: 13724dfa53421372f14387778b7a59cd5772e30632e5404a5f585189692683fead0e413641b5937f9f88e73276a4066dbe54d95a3cd04c176db7331b03b4be72
|
data/CHANGELOG.md
CHANGED
@@ -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.
|
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
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'zeitwerk'
|
3
4
|
require 'active_support'
|
4
5
|
require 'active_support/concern'
|
5
6
|
require 'active_support/configurable'
|
@@ -10,10 +11,6 @@ require 'active_support/time_with_zone'
|
|
10
11
|
require 'jwt'
|
11
12
|
require 'keyless'
|
12
13
|
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
14
|
|
18
15
|
module Grape
|
19
16
|
module Jwt
|
@@ -22,32 +19,44 @@ module Grape
|
|
22
19
|
extend ActiveSupport::Concern
|
23
20
|
include Grape::DSL::API
|
24
21
|
|
22
|
+
# Setup a Zeitwerk autoloader instance and configure it
|
23
|
+
loader = Zeitwerk::Loader.for_gem_extension(Grape::Jwt)
|
24
|
+
|
25
|
+
# Finish the auto loader configuration
|
26
|
+
loader.setup
|
27
|
+
|
28
|
+
# Make sure to eager load all SDK constants
|
29
|
+
loader.eager_load
|
30
|
+
|
25
31
|
class << self
|
26
32
|
attr_writer :configuration
|
27
|
-
end
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
# @return [Configuration]
|
32
|
-
def self.configuration
|
33
|
-
@configuration ||= Configuration.new
|
34
|
-
end
|
34
|
+
# Include top-level features
|
35
|
+
include Extensions::Dependencies
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
def self.configure
|
43
|
-
yield(configuration)
|
44
|
-
configure_dependencies
|
45
|
-
end
|
37
|
+
# Retrieve the current configuration object.
|
38
|
+
#
|
39
|
+
# @return [Configuration]
|
40
|
+
def configuration
|
41
|
+
@configuration ||= Configuration.new
|
42
|
+
end
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
44
|
+
# Configure the concern by providing a block which takes
|
45
|
+
# care of this task. Example:
|
46
|
+
#
|
47
|
+
# Grape::Jwt::Authentication.configure do |conf|
|
48
|
+
# # conf.xyz = [..]
|
49
|
+
# end
|
50
|
+
def configure
|
51
|
+
yield(configuration)
|
52
|
+
configure_dependencies
|
53
|
+
end
|
54
|
+
|
55
|
+
# Reset the current configuration with the default one.
|
56
|
+
def reset_configuration!
|
57
|
+
self.configuration = Configuration.new
|
58
|
+
configure_dependencies
|
59
|
+
end
|
51
60
|
end
|
52
61
|
|
53
62
|
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.
|
4
|
+
version: 2.7.0
|
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-
|
11
|
+
date: 2025-01-11 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.
|
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.
|
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
|