jwt-authenticator 1.0.0 → 1.0.1
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/Gemfile.lock +1 -1
- data/lib/jwt-authenticator.rb +15 -14
- data/lib/jwt-authenticator/version.rb +1 -1
- data/test/helper.rb +8 -0
- data/test/{jwt-authenticator-test.rb → test-jwt-authenticator.rb} +6 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0aaf041548d6b16756d9cadbccf38afa83f5eeaaa7954bc41f00c9a99c21ce12
|
4
|
+
data.tar.gz: 1e796bbd42368f5c76fbfe31416b847ebd983e76aa664cd051a8aedf119be754
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a420c305744cb0e49dd685e9f572b5f2dc374e1fa0101fb836ae6440861f70113db30ba9ffca205aeaa584a5c5e579e3db23a7922abf731c673ef8cd20c84797
|
7
|
+
data.tar.gz: 336e1dccc210c359c7e94995eda94c24c45ce0a038287f82e1349deae4252a053f692dedb00dd251fc638191cff0f24118d49977564441a84f5be4dacede205c
|
data/Gemfile.lock
CHANGED
data/lib/jwt-authenticator.rb
CHANGED
@@ -14,7 +14,7 @@ class JWT::Authenticator
|
|
14
14
|
|
15
15
|
def initialize
|
16
16
|
@verification_options = token_verification_options_from_environment \
|
17
|
-
self.class.name.split("::").
|
17
|
+
self.class.name.split("::")[0...-1].join("_").underscore.upcase.gsub(/_?JWT\z/, "") + "_JWT"
|
18
18
|
end
|
19
19
|
|
20
20
|
def call(token)
|
@@ -33,19 +33,20 @@ protected
|
|
33
33
|
method_not_implemented
|
34
34
|
end
|
35
35
|
|
36
|
-
def token_verification_options_from_environment(
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
36
|
+
def token_verification_options_from_environment(namespace)
|
37
|
+
namespace = namespace.gsub(/_+\z/, "")
|
38
|
+
{ verify_expiration: ENV["#{namespace}_VERIFY_EXP"] != "false",
|
39
|
+
verify_not_before: ENV["#{namespace}_VERIFY_NBF"] != "false",
|
40
|
+
iss: ENV["#{namespace}_ISS"].to_s.squish.presence,
|
41
|
+
verify_iat: ENV["#{namespace}_VERIFY_IAT"] != "false",
|
42
|
+
verify_jti: ENV["#{namespace}_VERIFY_JTI"] != "false",
|
43
|
+
aud: ENV["#{namespace}_AUD"].to_s.split(",").map(&:squish).reject(&:blank?).presence, # Comma-separated values.
|
44
|
+
sub: ENV["#{namespace}_SUB"].to_s.squish.presence,
|
45
|
+
algorithms: ENV["#{namespace}_ALG"].to_s.split(",").map(&:squish).reject(&:blank?).presence, # Comma-separated values.
|
46
|
+
leeway: ENV["#{namespace}_LEEWAY"].to_s.squish.yield_self { |n| n.to_i if n.present? },
|
47
|
+
iat_leeway: ENV["#{namespace}_IAT_LEEWAY"].to_s.squish.yield_self { |n| n.to_i if n.present? },
|
48
|
+
exp_leeway: ENV["#{namespace}_EXP_LEEWAY"].to_s.squish.yield_self { |n| n.to_i if n.present? },
|
49
|
+
nbf_leeway: ENV["#{namespace}_NBF_LEEWAY"].to_s.squish.yield_self { |n| n.to_i if n.present? }
|
49
50
|
}.tap { |options|
|
50
51
|
options.merge! \
|
51
52
|
verify_sub: options[:sub].present?,
|
data/test/helper.rb
CHANGED
@@ -155,6 +155,12 @@ class JWTAuthenticatorTest < Test::Unit::TestCase
|
|
155
155
|
assert_equal(103, error.code)
|
156
156
|
end
|
157
157
|
|
158
|
+
test "loading token verification options from environment (authenticator nested under multiple modules)" do
|
159
|
+
ENV["MY_API_V3_JWT_ISS"] = "bar"
|
160
|
+
authenticator = MyAPI::V3::JWTAuthenticator.instance
|
161
|
+
assert_equal(ENV["MY_API_V3_JWT_ISS"], authenticator.instance_variable_get(:@verification_options)[:iss])
|
162
|
+
end
|
163
|
+
|
158
164
|
private
|
159
165
|
|
160
166
|
def my_api_v1_token_verification_options
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jwt-authenticator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Konoplov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -89,7 +89,7 @@ files:
|
|
89
89
|
- lib/jwt-authenticator.rb
|
90
90
|
- lib/jwt-authenticator/version.rb
|
91
91
|
- test/helper.rb
|
92
|
-
- test/jwt-authenticator
|
92
|
+
- test/test-jwt-authenticator.rb
|
93
93
|
homepage: https://github.com/ruby-jwt/jwt-authenticator
|
94
94
|
licenses:
|
95
95
|
- Apache-2.0
|
@@ -116,4 +116,4 @@ specification_version: 4
|
|
116
116
|
summary: JSON Web Token authentication Ruby service.
|
117
117
|
test_files:
|
118
118
|
- test/helper.rb
|
119
|
-
- test/jwt-authenticator
|
119
|
+
- test/test-jwt-authenticator.rb
|