jwt_sessions 3.1.0 → 3.1.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/CHANGELOG.md +7 -1
- data/README.md +4 -4
- data/lib/jwt_sessions/store_adapters/redis_store_adapter.rb +2 -1
- data/lib/jwt_sessions/version.rb +1 -1
- data/test/units/jwt_sessions/test_session.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1264eae87a9f5dc03028ee842e83da499f4d9d3f819d10b676f1bcde974cc2a
|
4
|
+
data.tar.gz: a29d5d6d8a07d24f275072536c7cd912e041aeec6d4c9392eeebf30b9c6337a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4abc1c449bd2692b00797c42c235d52dd4f67e30176e77d04da79a29fd5828ee73696908745ce8432af2cc8514523b24d4128158822ce412f2e9d6092550ad91
|
7
|
+
data.tar.gz: 6b7006560ab05859b51c9add771f029b68c0f09a391fe576c47b6e97ba72b1bdbabb8c787262a07553962e24bdccb2148c2bf960f614af56e497f8c18e9a4c7a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -119,7 +119,7 @@ Available `JWTSessions::Session.new` options:
|
|
119
119
|
|
120
120
|
- **payload**: a hash object with session data which will be included into an access token payload. Default is an empty hash.
|
121
121
|
- **refresh_payload**: a hash object with session data which will be included into a refresh token payload. Default is the value of the access payload.
|
122
|
-
- **access_claims**: a hash object with [JWT claims](https://github.com/jwt/ruby-jwt#support-for-reserved-claim-names) which will be validated within the access token payload. For example, `{ aud
|
122
|
+
- **access_claims**: a hash object with [JWT claims](https://github.com/jwt/ruby-jwt#support-for-reserved-claim-names) which will be validated within the access token payload. For example, `{ "aud" => ["admin"], "verify_aud" => true }` means that the token can be used only by "admin" audience. Also, the endpoint can automatically validate claims instead. See `token_claims` method.
|
123
123
|
- **refresh_claims**: a hash object with [JWT claims](https://github.com/jwt/ruby-jwt#support-for-reserved-claim-names) which will be validated within the refresh token payload.
|
124
124
|
- **namespace**: a string object which helps to group sessions by a custom criteria. For example, sessions can be grouped by user ID, making it possible to logout the user from all devices. More info [Sessions Namespace](#sessions-namespace).
|
125
125
|
- **refresh_by_access_allowed**: a boolean value. Default is false. It links access and refresh tokens (adds refresh token ID to access payload), making it possible to perform a session refresh by the last expired access token. See [Refresh with access token](#refresh-with-access-token).
|
@@ -426,9 +426,9 @@ class UsersController < ApplicationController
|
|
426
426
|
|
427
427
|
def token_claims
|
428
428
|
{
|
429
|
-
aud
|
430
|
-
verify_aud
|
431
|
-
exp_leeway
|
429
|
+
"aud" => ["admin", "staff"],
|
430
|
+
"verify_aud" => true, # can be used locally instead of a global setting
|
431
|
+
"exp_leeway" => 15 # will be used instead of default leeway only for exp claim
|
432
432
|
}
|
433
433
|
end
|
434
434
|
end
|
@@ -78,7 +78,8 @@ module JWTSessions
|
|
78
78
|
# to be able to properly initialize namespaced tokens extract their namespaces
|
79
79
|
# and pass down to fetch_refresh
|
80
80
|
token_namespace = namespace.to_s.empty? ? namespace_from_key(key) : namespace
|
81
|
-
|
81
|
+
token_attrs = fetch_refresh(uid, token_namespace)
|
82
|
+
acc[uid] = token_attrs unless token_attrs.empty?
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
data/lib/jwt_sessions/version.rb
CHANGED
@@ -326,6 +326,16 @@ class TestSession < Minitest::Test
|
|
326
326
|
assert_equal access_token.expiration.to_s, refresh_token.access_expiration
|
327
327
|
end
|
328
328
|
|
329
|
+
def test_flush_namespaced_access_tokens_after_flush_namespaced
|
330
|
+
namespace = "test_namespace"
|
331
|
+
session = JWTSessions::Session.new(payload: payload, namespace: namespace)
|
332
|
+
session.login
|
333
|
+
|
334
|
+
assert_equal 1, session.flush_namespaced
|
335
|
+
# it should not throw an error
|
336
|
+
assert_equal 0, session.flush_namespaced_access_tokens
|
337
|
+
end
|
338
|
+
|
329
339
|
def test_flush_all
|
330
340
|
refresh_token = @session.instance_variable_get(:"@_refresh")
|
331
341
|
flushed_count = JWTSessions::Session.flush_all
|
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: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julija Alieckaja
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
|
-
rubygems_version: 3.4.
|
130
|
+
rubygems_version: 3.4.12
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: JWT Sessions
|