jwt_sessions 2.6.0 → 2.7.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad42d33af309b3295e9aa6402179df2a9a0ac5e17618d133427e27edafca9578
|
4
|
+
data.tar.gz: e67b97b9bf3a2aec4bba3f66cc517d4dad03bcb4ce73269147cce31bcd9d85d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe6bc8a993388688a85d6b86ea139ab8d3123b628db77181fa4db6ba68d92c0080ca16fdfcaeb3567be9f2a07896df711cb9edb9c7845d6a226408e6fda00de9
|
7
|
+
data.tar.gz: 712ea681644f82710f5d561a96e78df86c1c3e4c225b8535a9d1cd2e03bcb363d93e4b42764847b786461e26f6f9440a3f85b026e02fa557c647a5866eef70dc
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -153,11 +153,11 @@ end
|
|
153
153
|
```
|
154
154
|
|
155
155
|
Specify an encryption key for JSON Web Tokens in `config/initializers/jwt_session.rb` \
|
156
|
-
It is advisable to store the key itself within
|
156
|
+
It is advisable to store the key itself in a secure way, f.e. within app credentials.
|
157
157
|
|
158
158
|
```ruby
|
159
159
|
JWTSessions.algorithm = "HS256"
|
160
|
-
JWTSessions.encryption_key = Rails.application.
|
160
|
+
JWTSessions.encryption_key = Rails.application.credentials.secret_jwt_encryption_key
|
161
161
|
```
|
162
162
|
|
163
163
|
Most of the encryption algorithms require private and public keys to sign a token. However, HMAC requires only a single key and you can use the `encryption_key` shortcut to sign the token. For other algorithms you must specify private and public keys separately.
|
@@ -378,6 +378,12 @@ JWTSessions.token_store = :redis, {
|
|
378
378
|
}
|
379
379
|
```
|
380
380
|
|
381
|
+
If you already have a configured Redis client, you can pass it among the options to reduce opened connections to a Redis server:
|
382
|
+
|
383
|
+
```ruby
|
384
|
+
JWTSessions.token_store = :redis, {redis_client: Redis.current}
|
385
|
+
```
|
386
|
+
|
381
387
|
##### JWT signature
|
382
388
|
|
383
389
|
```ruby
|
@@ -7,16 +7,20 @@ module JWTSessions
|
|
7
7
|
|
8
8
|
REFRESH_KEYS = %i[csrf access_uid access_expiration expiration].freeze
|
9
9
|
|
10
|
-
def initialize(token_prefix: JWTSessions.token_prefix, **options)
|
10
|
+
def initialize(token_prefix: JWTSessions.token_prefix, redis_client: nil, **options)
|
11
11
|
@prefix = token_prefix
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
if redis_client
|
14
|
+
@storage = redis_client
|
15
|
+
else
|
16
|
+
begin
|
17
|
+
require "redis"
|
18
|
+
@storage = configure_redis_client(**options)
|
19
|
+
rescue LoadError => e
|
20
|
+
msg = "Could not load the 'redis' gem, please add it to your gemfile or " \
|
21
|
+
"configure a different adapter (e.g. JWTSessions.store_adapter = :memory)"
|
22
|
+
raise e.class, msg, e.backtrace
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
data/lib/jwt_sessions/version.rb
CHANGED
@@ -77,4 +77,10 @@ class TestRedisStoreAdapter < Minitest::Test
|
|
77
77
|
adapter = JWTSessions::StoreAdapters::RedisStoreAdapter.new
|
78
78
|
assert_equal "redis://127.0.0.2:6322/0", adapter.storage.connection[:id]
|
79
79
|
end
|
80
|
+
|
81
|
+
def test_configuration_via_redis_client
|
82
|
+
client = Object.new
|
83
|
+
adapter = JWTSessions::StoreAdapters::RedisStoreAdapter.new(redis_client: client)
|
84
|
+
assert_equal client, adapter.storage
|
85
|
+
end
|
80
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jwt_sessions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
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: 2021-
|
11
|
+
date: 2021-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -98,7 +98,7 @@ metadata:
|
|
98
98
|
changelog_uri: https://github.com/tuwukee/jwt_sessions/blob/master/CHANGELOG.md
|
99
99
|
source_code_uri: https://github.com/tuwukee/jwt_sessions
|
100
100
|
bug_tracker_uri: https://github.com/tuwukee/jwt_sessions/issues
|
101
|
-
post_install_message:
|
101
|
+
post_install_message:
|
102
102
|
rdoc_options: []
|
103
103
|
require_paths:
|
104
104
|
- lib
|
@@ -113,8 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
117
|
-
signing_key:
|
116
|
+
rubygems_version: 3.2.5
|
117
|
+
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: JWT Sessions
|
120
120
|
test_files:
|