strongmind-auth 1.1.73 → 1.1.74
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/jwt_utilities.rb +5 -6
- data/app/controllers/concerns/strong_mind_nav.rb +1 -1
- data/app/controllers/users/omniauth_callbacks_controller.rb +1 -1
- data/app/controllers/users/sessions_controller.rb +1 -5
- data/app/models/user_base.rb +2 -3
- data/lib/strongmind/auth/version.rb +1 -1
- data/lib/strongmind/common_nav_fetcher.rb +6 -14
- data/lib/strongmind/exceptions.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5045731638769140a75bf68a154d0974ec973384233c100fdef35222440b414a
|
4
|
+
data.tar.gz: 166214edf8924600b71b37f32a475775e7117a3231db37ffb4cebd083d60eb7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e1e56c92fd97a41be2a5d7d40bbfabf75cf4fb18338a1e0f846cf840f8a5a536dd788ad569e8e3cdcd7d484f9908d573ea574d6e0ed1f9453e2e78d98a3477d
|
7
|
+
data.tar.gz: 02b89568977e51d1f516c0ed3ba29ae8dd05b2ef03573ccbd29e34173e7e66c6505e99614a74601c391fd383e0692af751d598d615802b3187694e5e65e3ebaa
|
@@ -69,16 +69,15 @@ module JwtUtilities
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def user_jwt(session_data)
|
72
|
-
tokens = current_user.nil? ? nil : Rails.cache.read(current_user
|
72
|
+
tokens = current_user.nil? ? nil : Rails.cache.read(current_user.uid)
|
73
73
|
validate_tokens(tokens) unless tokens.nil?
|
74
74
|
|
75
75
|
if tokens.nil?
|
76
|
-
tokens = generate_tokens(session_data)
|
76
|
+
tokens = generate_tokens(session_data[:refresh_token])
|
77
77
|
validate_tokens(tokens)
|
78
78
|
|
79
79
|
unless current_user.nil?
|
80
|
-
|
81
|
-
Rails.cache.write(current_user&.uid, tokens, expires_in: tokens[:expires_in].seconds - 10.minutes.in_seconds)
|
80
|
+
Rails.cache.write(current_user.uid, tokens)
|
82
81
|
end
|
83
82
|
end
|
84
83
|
session_data[:refresh_token] = tokens[:refresh_token]
|
@@ -92,14 +91,14 @@ module JwtUtilities
|
|
92
91
|
raise Strongmind::Exceptions::RefreshTokenExpiredError, tokens[:error]
|
93
92
|
end
|
94
93
|
|
95
|
-
def generate_tokens(
|
94
|
+
def generate_tokens(refresh_token)
|
96
95
|
identity_base_url = ENV['IDENTITY_BASE_URL']
|
97
96
|
identity_client_id = ENV['IDENTITY_CLIENT_ID']
|
98
97
|
response = Faraday.post("#{identity_base_url}/connect/token", {
|
99
98
|
client_id: identity_client_id,
|
100
99
|
client_secret: ENV['IDENTITY_CLIENT_SECRET'],
|
101
100
|
grant_type: 'refresh_token',
|
102
|
-
refresh_token:
|
101
|
+
refresh_token: refresh_token
|
103
102
|
})
|
104
103
|
|
105
104
|
JSON.parse(response.body, symbolize_names: true)
|
@@ -11,7 +11,7 @@ module StrongMindNav
|
|
11
11
|
@top_navbar_html = navbar[:top_navbar_html]
|
12
12
|
@bottom_navbar_html = navbar[:bottom_navbar_html]
|
13
13
|
@theme_css = navbar[:theme_css]
|
14
|
-
rescue Strongmind::Exceptions::
|
14
|
+
rescue Strongmind::Exceptions::TokenNotFoundError, Strongmind::Exceptions::UserNotFoundError, Strongmind::Exceptions::RefreshTokenExpiredError => e
|
15
15
|
Sentry.capture_exception(e)
|
16
16
|
Rails.logger.error(e)
|
17
17
|
flash[:alert] = e.inspect if Rails.env.development? || Rails.env.test?
|
@@ -12,7 +12,7 @@ module Users
|
|
12
12
|
|
13
13
|
render plain: "You do not have permission to access this application.", status: :unauthorized and return if @user.nil?
|
14
14
|
|
15
|
-
session[:refresh_token] =
|
15
|
+
session[:refresh_token] = auth.credentials['refresh_token']
|
16
16
|
flash.delete(:notice)
|
17
17
|
|
18
18
|
if @user.persisted?
|
@@ -34,13 +34,9 @@ module Users
|
|
34
34
|
user_token_info = fetch_user_token_info
|
35
35
|
|
36
36
|
id_token_hint = user_token_info[:id_token]
|
37
|
-
token = user_token_info[:access_token]
|
38
37
|
current_user&.invalidate_all_sessions!
|
39
38
|
identity_base_url = ENV['IDENTITY_BASE_URL']
|
40
|
-
redirect_to "#{identity_base_url}/connect/endsession?id_token_hint=#{id_token_hint}",
|
41
|
-
'Content-Type' => 'application/json',
|
42
|
-
'Authorization' => "Bearer #{token}"
|
43
|
-
}, allow_other_host: true
|
39
|
+
redirect_to "#{identity_base_url}/connect/endsession?id_token_hint=#{id_token_hint}", allow_other_host: true
|
44
40
|
end
|
45
41
|
|
46
42
|
end
|
data/app/models/user_base.rb
CHANGED
@@ -12,9 +12,8 @@ class UserBase < ApplicationRecord
|
|
12
12
|
{
|
13
13
|
id_token: auth.credentials.id_token,
|
14
14
|
access_token: auth.credentials.token,
|
15
|
-
refresh_token: auth.credentials.refresh_token
|
16
|
-
}
|
17
|
-
expires_in: auth.credentials.expires_in.seconds - 10.minutes
|
15
|
+
refresh_token: auth.credentials.refresh_token,
|
16
|
+
}
|
18
17
|
)
|
19
18
|
end
|
20
19
|
|
@@ -48,8 +48,8 @@ module Strongmind
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def fetch_navbar_data(nav_items)
|
51
|
-
refresh_session
|
52
|
-
access_token =
|
51
|
+
session = refresh_session
|
52
|
+
access_token = session[:access_token]
|
53
53
|
|
54
54
|
connection.post(navbar_endpoint, nav_items.to_json, 'Authorization' => "Bearer #{access_token}")
|
55
55
|
end
|
@@ -63,24 +63,16 @@ module Strongmind
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
def token
|
67
|
-
cache_data = Rails.cache.fetch(user.uid)
|
68
|
-
cache_missing_message = " - check your caching settings (switch to file or redis)" if Rails.env.development?
|
69
|
-
unless cache_data&.key?(:access_token)
|
70
|
-
raise Strongmind::Exceptions::TokenNotFoundError, "Token not found for user #{user.uid}#{cache_missing_message}"
|
71
|
-
end
|
72
|
-
|
73
|
-
cache_data[:access_token]
|
74
|
-
end
|
75
|
-
|
76
66
|
def refresh_session
|
77
67
|
session = Rails.cache.fetch(user.uid)
|
68
|
+
cache_missing_message = " - check your caching settings (switch to file or redis)" if Rails.env.development?
|
78
69
|
unless session&.key?(:access_token)
|
79
|
-
raise Strongmind::Exceptions::
|
70
|
+
raise Strongmind::Exceptions::TokenNotFoundError, "Token not found for user #{user.uid}#{cache_missing_message}"
|
80
71
|
end
|
81
72
|
|
82
73
|
auth_client.refresh_session(session:)
|
83
|
-
Rails.cache.write(user.uid, session
|
74
|
+
Rails.cache.write(user.uid, session)
|
75
|
+
session
|
84
76
|
rescue PlatformSdk::Identity::ClientError => e
|
85
77
|
handle_refresh_error(e)
|
86
78
|
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.74
|
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-04-
|
11
|
+
date: 2024-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|