jwt_sessions 2.7.0 → 2.7.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad42d33af309b3295e9aa6402179df2a9a0ac5e17618d133427e27edafca9578
4
- data.tar.gz: e67b97b9bf3a2aec4bba3f66cc517d4dad03bcb4ce73269147cce31bcd9d85d4
3
+ metadata.gz: 1382a5dd59aa20018fddf7489d73318e5fc217c2c7344e87cd9bea8f61452152
4
+ data.tar.gz: 0165234c70b5b5a411c7eefbb2c59aef0903bbf73bc8c0de611ace157742a341
5
5
  SHA512:
6
- metadata.gz: fe6bc8a993388688a85d6b86ea139ab8d3123b628db77181fa4db6ba68d92c0080ca16fdfcaeb3567be9f2a07896df711cb9edb9c7845d6a226408e6fda00de9
7
- data.tar.gz: 712ea681644f82710f5d561a96e78df86c1c3e4c225b8535a9d1cd2e03bcb363d93e4b42764847b786461e26f6f9440a3f85b026e02fa557c647a5866eef70dc
6
+ metadata.gz: 984be7f82567e3aebb090497c7dfbaee8900987fae0682fc89d98d23e5a1acaf07820a7a0133e360139bf007d16c2f4cde6c2e3e5192a25f0b42cec7ca85970a
7
+ data.tar.gz: 90a250db30b788624210a271c0c4778bd08c43ca71b00684a882dff631bcc6df31c49c5b1492f02ac20f5699cc86903c6e56713aef59cd2dad7016924bb74c19
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 2.7.2 (January 24, 2022)
2
+
3
+ Bugfixes:
4
+
5
+ - 2.7.1 version didn't include the correct patch
6
+
7
+ ## 2.7.1 (January 22, 2022)
8
+
9
+ Bugfixes:
10
+
11
+ - Correctly init namespaced refresh tokens when fetching all tokens from Redis
12
+
1
13
  ## 2.7.0 (October 05, 2021)
2
14
 
3
15
  Features:
@@ -61,7 +61,7 @@ module JWTSessions
61
61
  token_attrs[:access_uid],
62
62
  token_attrs[:access_expiration],
63
63
  store,
64
- namespace: namespace,
64
+ namespace: token_attrs[:namespace] || namespace,
65
65
  payload: {},
66
66
  uid: uid,
67
67
  expiration: token_attrs[:expiration]
@@ -40,7 +40,10 @@ module JWTSessions
40
40
  values = storage.hmget(key, *REFRESH_KEYS).compact
41
41
 
42
42
  return {} if values.length != REFRESH_KEYS.length
43
- REFRESH_KEYS.each_with_index.each_with_object({}) { |(key, index), acc| acc[key] = values[index] }
43
+ REFRESH_KEYS
44
+ .each_with_index
45
+ .each_with_object({}) { |(key, index), acc| acc[key] = values[index] }
46
+ .merge({ namespace: namespace })
44
47
  end
45
48
 
46
49
  def persist_refresh(uid:, access_expiration:, access_uid:, csrf:, expiration:, namespace: nil)
@@ -69,7 +72,10 @@ module JWTSessions
69
72
  keys_in_namespace = scan_keys(refresh_key("*", namespace))
70
73
  (keys_in_namespace || []).each_with_object({}) do |key, acc|
71
74
  uid = uid_from_key(key)
72
- acc[uid] = fetch_refresh(uid, namespace)
75
+ # to be able to properly initialize namespaced tokens extract their namespaces
76
+ # and pass down to fetch_refresh
77
+ token_namespace = namespace.to_s.empty? ? namespace_from_key(key) : namespace
78
+ acc[uid] = fetch_refresh(uid, token_namespace)
73
79
  end
74
80
  end
75
81
 
@@ -131,6 +137,14 @@ module JWTSessions
131
137
  key.split("_").last
132
138
  end
133
139
 
140
+ def namespace_from_key(key)
141
+ ns_regexp.match(key)&.[](:namespace)
142
+ end
143
+
144
+ def ns_regexp
145
+ @ns_regexp ||= Regexp.new("#{prefix}_(?<namespace>.+)_refresh")
146
+ end
147
+
134
148
  def scan_keys(key_pattern)
135
149
  cursor = 0
136
150
  all_keys = []
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JWTSessions
4
- VERSION = "2.7.0"
4
+ VERSION = "2.7.2"
5
5
  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.7.0
4
+ version: 2.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yulia Oletskaya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-05 00:00:00.000000000 Z
11
+ date: 2022-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt