jwt_sessions 2.7.2 → 2.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/jwt_sessions/token.rb +1 -1
- data/lib/jwt_sessions/version.rb +1 -1
- data/lib/jwt_sessions.rb +1 -3
- data/test/units/jwt_sessions/test_token.rb +5 -5
- metadata +24 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed69732617f15f4c07c0fb37d3ad938807224b729f136d24755a90f58b7b28ab
|
4
|
+
data.tar.gz: 27bee3f1c2bd4b099b0dadea703143d70e6abf1aaa6e5556f67515dfbc6f2e5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0a81d8d8013a1393b441ddd15ec34fb57ceb0bd3198f9ee4a2554dff653efbe4379ad6992d1a8678895e0391f45626068a2f16b422ad8c658b7a086a08241d3
|
7
|
+
data.tar.gz: 46e744a4512da3d90b54f6552c42f35c7b3b3d25a9d73292058ac5782102ed9d9c77ac6a734a865b40e2fcccd675257cc5c41d27be45bd5fde758e8d6c97537f
|
data/CHANGELOG.md
CHANGED
data/lib/jwt_sessions/token.rb
CHANGED
@@ -13,7 +13,7 @@ module JWTSessions
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def decode(token, claims = {})
|
16
|
-
decode_options = { algorithm: JWTSessions.algorithm }.merge(JWTSessions.jwt_options
|
16
|
+
decode_options = { algorithm: JWTSessions.algorithm }.merge(JWTSessions.jwt_options).merge(claims)
|
17
17
|
JWT.decode(token, JWTSessions.public_key, JWTSessions.validate?, decode_options)
|
18
18
|
rescue JWT::ExpiredSignature => e
|
19
19
|
raise Errors::Expired, e.message
|
data/lib/jwt_sessions/version.rb
CHANGED
data/lib/jwt_sessions.rb
CHANGED
@@ -21,8 +21,6 @@ module JWTSessions
|
|
21
21
|
|
22
22
|
NONE = "none"
|
23
23
|
|
24
|
-
JWTOptions = Struct.new(*JWT::DefaultOptions::DEFAULT_OPTIONS.keys)
|
25
|
-
|
26
24
|
DEFAULT_SETTINGS_KEYS = %i[access_cookie
|
27
25
|
access_exp_time
|
28
26
|
access_header
|
@@ -66,7 +64,7 @@ module JWTSessions
|
|
66
64
|
end
|
67
65
|
|
68
66
|
def jwt_options
|
69
|
-
@jwt_options ||=
|
67
|
+
@jwt_options ||= JWT::Configuration::Container.new.decode.to_h
|
70
68
|
end
|
71
69
|
|
72
70
|
def algorithm=(algo)
|
@@ -24,7 +24,7 @@ class TestToken < Minitest::Test
|
|
24
24
|
|
25
25
|
def teardown
|
26
26
|
JWTSessions.algorithm = JWTSessions::DEFAULT_ALGORITHM
|
27
|
-
JWTSessions.instance_variable_set(:"@jwt_options",
|
27
|
+
JWTSessions.instance_variable_set(:"@jwt_options", JWT::Configuration::Container.new.decode.to_h)
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_rsa_token_decode
|
@@ -73,7 +73,7 @@ class TestToken < Minitest::Test
|
|
73
73
|
|
74
74
|
def test_token_sub_claim
|
75
75
|
JWTSessions.encryption_key = "abcdefghijklmnopqrstuvwxyzABCDEF"
|
76
|
-
JWTSessions.jwt_options
|
76
|
+
JWTSessions.jwt_options[:verify_sub] = true
|
77
77
|
token = JWTSessions::Token.encode(payload.merge(sub: "subject"))
|
78
78
|
decoded = JWTSessions::Token.decode(token, { sub: "subject" }).first
|
79
79
|
assert_equal payload["user_id"], decoded["user_id"]
|
@@ -85,7 +85,7 @@ class TestToken < Minitest::Test
|
|
85
85
|
|
86
86
|
def test_token_iss_claim
|
87
87
|
JWTSessions.encryption_key = "abcdefghijklmnopqrstuvwxyzABCDEF"
|
88
|
-
JWTSessions.jwt_options
|
88
|
+
JWTSessions.jwt_options[:verify_iss] = true
|
89
89
|
token = JWTSessions::Token.encode(payload.merge(iss: "Me"))
|
90
90
|
decoded = JWTSessions::Token.decode(token, { iss: "Me" }).first
|
91
91
|
assert_equal payload["user_id"], decoded["user_id"]
|
@@ -97,7 +97,7 @@ class TestToken < Minitest::Test
|
|
97
97
|
|
98
98
|
def test_token_aud_claim
|
99
99
|
JWTSessions.encryption_key = "abcdefghijklmnopqrstuvwxyzABCDEF"
|
100
|
-
JWTSessions.jwt_options
|
100
|
+
JWTSessions.jwt_options[:verify_aud] = true
|
101
101
|
token = JWTSessions::Token.encode(payload.merge(aud: ["young", "old"]))
|
102
102
|
decoded = JWTSessions::Token.decode(token, { aud: ["young"] }).first
|
103
103
|
assert_equal payload["user_id"], decoded["user_id"]
|
@@ -109,7 +109,7 @@ class TestToken < Minitest::Test
|
|
109
109
|
|
110
110
|
def test_token_leeway_decode
|
111
111
|
JWTSessions.encryption_key = "abcdefghijklmnopqrstuvwxyzABCDEF"
|
112
|
-
JWTSessions.jwt_options
|
112
|
+
JWTSessions.jwt_options[:leeway] = 50
|
113
113
|
token = JWTSessions::Token.encode(payload.merge("exp" => Time.now.to_i - 20))
|
114
114
|
decoded = JWTSessions::Token.decode(token).first
|
115
115
|
assert_equal payload["user_id"], decoded["user_id"]
|
metadata
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jwt_sessions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yulia Oletskaya
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: '2.5'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '3'
|
@@ -24,9 +24,9 @@ dependencies:
|
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.
|
29
|
+
version: '2.5'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '3'
|
@@ -58,6 +58,20 @@ dependencies:
|
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '12.3'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.11'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.11'
|
61
75
|
description: XSS/CSRF safe JWT auth designed for SPA
|
62
76
|
email: yulia.oletskaya@gmail.com
|
63
77
|
executables: []
|
@@ -98,7 +112,7 @@ metadata:
|
|
98
112
|
changelog_uri: https://github.com/tuwukee/jwt_sessions/blob/master/CHANGELOG.md
|
99
113
|
source_code_uri: https://github.com/tuwukee/jwt_sessions
|
100
114
|
bug_tracker_uri: https://github.com/tuwukee/jwt_sessions/issues
|
101
|
-
post_install_message:
|
115
|
+
post_install_message:
|
102
116
|
rdoc_options: []
|
103
117
|
require_paths:
|
104
118
|
- lib
|
@@ -113,8 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
127
|
- !ruby/object:Gem::Version
|
114
128
|
version: '0'
|
115
129
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
117
|
-
signing_key:
|
130
|
+
rubygems_version: 3.0.3.1
|
131
|
+
signing_key:
|
118
132
|
specification_version: 4
|
119
133
|
summary: JWT Sessions
|
120
134
|
test_files:
|