strongmind-auth 1.1.104 → 1.1.107

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: e28c44ee15358c2cd005c765701a0bae728a8f731a26bd983cc89b98f22f93a0
4
- data.tar.gz: f9002365819bfc3cb943d6b432406d4aaf8c0874bf661abff9f86ffda05727a7
3
+ metadata.gz: 9fb08b31a5fa67f9ea7ea76871e6a7ebacf053bec0301b5dc769187db2cb9e77
4
+ data.tar.gz: 9c0d495a487895e7abc6a950228eebd7c6def1917cf4e87ba6bd0fde9b5dc4f0
5
5
  SHA512:
6
- metadata.gz: 4105b0026dab50a2394d3bdbd788bb4bb921fe268670b2a4020688568dbb34d02a47c4fc32ddea6c7aea8600226a3dc6fd1c7090d3e11f9b80730caf4f6c1036
7
- data.tar.gz: 0dbc0726df726ff5ae0baf5e1c6e3548d55b239f9da13ef48a248f4ffc16e24b267656a973a2572954d92bc982b09ae452a3ae8b9cde0ce5afe2370f33e02a8d
6
+ metadata.gz: dc4ea71c018cc9e30fdb3d6eec44e4c1f5c0edcf91b6ca9d0b8b167c586b411af87dff2356008c330cfb4d6e313413c58a2dd24a3b49fc705a5ea5ec7becaa22
7
+ data.tar.gz: 522cbc63024c6f6aa8d8a885a3519bebb3a322dcfbe25fb88e36dded321aa91229a9f5d44b2160e2ac85132b0c5ea8d82ff2ddc4db72a12bcbb4d753d969daf8
@@ -4,12 +4,14 @@ require "strongmind/exceptions"
4
4
  module StrongMindNav
5
5
  extend ActiveSupport::Concern
6
6
 
7
+ NAVBAR_CACHE_KEY_SUFFIX = 'navbar'
8
+
7
9
  def fetch_common_nav
8
10
  begin
9
11
  nav_items = build_nav_items
10
12
 
11
- user_cache_key_encoded = generate_user_cache_key(nav_items)
12
- navbar = Rails.cache.fetch(user_cache_key_encoded, expires_in: 30.seconds) do
13
+ user_cache_key_encoded = generate_user_navbar_cache_key(nav_items)
14
+ navbar = Rails.cache.fetch(user_cache_key_encoded, expires_in: 1.day) do
13
15
  Strongmind::CommonNavFetcher.new(current_user).retrieve(nav_items, common_nav_options)
14
16
  end
15
17
 
@@ -74,19 +76,27 @@ module StrongMindNav
74
76
  path_to_compare.include?(sanitized_path) || path_to_compare.include?(sanitized_path.pluralize)
75
77
  end
76
78
 
77
- def generate_user_cache_key(nav_items)
79
+ def generate_user_navbar_cache_key(nav_items)
78
80
  navbar_options_cache_key = nav_items.to_json
79
- session_token = session[:_csrf_token]
80
- user = "user_#{current_user.uid}"
81
81
 
82
82
  user_cache_key = if current_user.respond_to?(:selected_role_id)
83
83
  role = "role_#{current_user.selected_role_id}"
84
84
 
85
- [session_token, user, role, navbar_options_cache_key, 'navbar'].join('_')
85
+ [role, navbar_options_cache_key].join('_')
86
86
  else
87
- [session_token, user, navbar_options_cache_key, 'navbar'].join('_')
87
+ navbar_options_cache_key
88
88
  end
89
89
 
90
- Digest::SHA256.hexdigest(user_cache_key)
90
+ navbar_cache_key_prefix(current_user) + Digest::SHA256.hexdigest(user_cache_key) + NAVBAR_CACHE_KEY_SUFFIX
91
+ end
92
+
93
+ def invalidate_navbar_cache(user = current_user)
94
+ cache_key_matcher = navbar_cache_key_prefix(user) + "*" + NAVBAR_CACHE_KEY_SUFFIX
95
+
96
+ Rails.cache.delete_matched(cache_key_matcher)
97
+ end
98
+
99
+ def navbar_cache_key_prefix(user)
100
+ "user_#{user.uid}"
91
101
  end
92
102
  end
@@ -24,6 +24,7 @@ module Users
24
24
  user_identity = payload['sub']
25
25
  user = User.find_by(uid: user_identity)
26
26
  user.invalidate_all_sessions!
27
+ invalidate_navbar_cache(user)
27
28
  render json: {}, status: :ok, headers:
28
29
  else
29
30
  render json: {}, status: :bad_request, headers:
@@ -36,6 +37,7 @@ module Users
36
37
 
37
38
  id_token_hint = user_token_info[:id_token]
38
39
  current_user&.invalidate_all_sessions!
40
+ invalidate_navbar_cache
39
41
  identity_base_url = ENV['IDENTITY_BASE_URL']
40
42
  redirect_to "#{identity_base_url}/connect/endsession?id_token_hint=#{id_token_hint}", allow_other_host: true
41
43
  end
@@ -1,5 +1,5 @@
1
1
  module Strongmind
2
2
  module Auth
3
- VERSION = "1.1.104"
3
+ VERSION = "1.1.107"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strongmind-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.104
4
+ version: 1.1.107
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Belding
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-15 00:00:00.000000000 Z
11
+ date: 2024-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails