strongmind-auth 1.1.104 → 1.1.109
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: 146ed93c0c8bf7dbe2e89d40ded7b296b6b9837898e5fa4cb5ff585554b2a952
|
4
|
+
data.tar.gz: fc3c36b3a9068a31d114eed4c12b846e2bbf8b64fd2ed553d2c62fe42f62483a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c87a80912078481e0ffde87a1ba092b57a88cbb47532c7fd402e57a778dfad4feb91048eb5f831d86d0756374ceed4e32f214991def78d01cc8b08a8aa261ce1
|
7
|
+
data.tar.gz: c7fb97f23269754f91b7ddddbbb128578bc9612572edece18555c864accc68388c9b8938b33780212022d8b7bffaf8d437c606d55b3af9871f758f863e338d24
|
@@ -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 =
|
12
|
-
navbar = Rails.cache.fetch(user_cache_key_encoded, expires_in:
|
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
|
|
@@ -17,7 +19,7 @@ module StrongMindNav
|
|
17
19
|
@bottom_navbar_html = navbar[:bottom_navbar_html]
|
18
20
|
@theme_css = navbar[:theme_css]
|
19
21
|
rescue Strongmind::Exceptions::TokenNotFoundError, Strongmind::Exceptions::UserNotFoundError, Strongmind::Exceptions::RefreshTokenExpiredError => e
|
20
|
-
Sentry.capture_exception(e)
|
22
|
+
Sentry.capture_exception(e) if e.is_a? Strongmind::Exceptions::UserNotFoundError
|
21
23
|
Rails.logger.error(e)
|
22
24
|
flash[:alert] = e.inspect if Rails.env.development? || Rails.env.test?
|
23
25
|
@stop_redirect = true if Rails.env.development? || Rails.env.test?
|
@@ -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
|
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
|
-
[
|
85
|
+
[role, navbar_options_cache_key].join('_')
|
86
86
|
else
|
87
|
-
|
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
|
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.
|
4
|
+
version: 1.1.109
|
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-
|
11
|
+
date: 2024-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|