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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7740c76d1bba04e91c960b59d8dd248d09adbecbea3359e09e49b9ec82cd4a98
4
- data.tar.gz: 43192bbcb08751f07216e84939a2b025239cb13b641c4563567b551626df79ae
3
+ metadata.gz: e1264eae87a9f5dc03028ee842e83da499f4d9d3f819d10b676f1bcde974cc2a
4
+ data.tar.gz: a29d5d6d8a07d24f275072536c7cd912e041aeec6d4c9392eeebf30b9c6337a1
5
5
  SHA512:
6
- metadata.gz: c96b79c7ba0a8952766d3d5501a34e5877f0f8bcebb9a3210318b42e86eaf3370c15b0a534e980cbb699493633fe2b7652ec1797f8c467a1838e76fdb246530c
7
- data.tar.gz: aa1d46b6890bf7d5907ad9a190598c91855db0f90e3f6f5522d4b0390ccc92a797d8977162980a072db8fc0fb9553961683eb59896c1cc7881111fe48413f1e6
6
+ metadata.gz: 4abc1c449bd2692b00797c42c235d52dd4f67e30176e77d04da79a29fd5828ee73696908745ce8432af2cc8514523b24d4128158822ce412f2e9d6092550ad91
7
+ data.tar.gz: 6b7006560ab05859b51c9add771f029b68c0f09a391fe576c47b6e97ba72b1bdbabb8c787262a07553962e24bdccb2148c2bf960f614af56e497f8c18e9a4c7a
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
- ## 3.1.0 (February 18, 20222)
1
+ ## 3.1.1 (May 6, 2023)
2
+
3
+ Bugfixes:
4
+
5
+ - fix bug with flushing empty refresh tokens (Unsupported command argument type: NilClass (TypeError))
6
+
7
+ ## 3.1.0 (February 18, 2023)
2
8
 
3
9
  Features:
4
10
 
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: ["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.
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: ["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
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
- acc[uid] = fetch_refresh(uid, token_namespace)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JWTSessions
4
- VERSION = "3.1.0"
4
+ VERSION = "3.1.1"
5
5
  end
@@ -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.0
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-02-18 00:00:00.000000000 Z
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.6
130
+ rubygems_version: 3.4.12
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: JWT Sessions