isaca-rails 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isaca/rails/authentication.rb +25 -26
- data/lib/isaca/rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e44dfe8d028791c15af16dbff0c76fd7856c039549c38992fec7f3009f60949
|
4
|
+
data.tar.gz: 4c02af179978947338db02822a276e0bb7f399c6b58e9a489c6ab31d10e83585
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 646dc489fcab3ae19756a482f231a9d87ccc7282589535f49db71a9787a688c45bcb1fe08574a49243afcc11da804e39bc243a0757e108d3dd5d3142baef0cb5
|
7
|
+
data.tar.gz: 1150b56df2379d68f500a1af8fba5dab5cfd09ffb4017ee6b8fd527b8635e1cf274991b1067a5fa2561c2251107bad3b8a4224d0ea287bca1678f1b14c850e28
|
@@ -15,29 +15,22 @@ module Isaca
|
|
15
15
|
#
|
16
16
|
# @return nil
|
17
17
|
def authenticate_isaca_user
|
18
|
-
|
19
|
-
if
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
render json: {error: t('isaca.rails.sessions.sign_in_required')}.to_json, status: :unauthorized
|
33
|
-
end
|
18
|
+
if user_signed_in?
|
19
|
+
if request.path != user_consent_path && redirect_for_consent?
|
20
|
+
session[:after_sign_in_path] = request.fullpath if request.get? && request.format.html?
|
21
|
+
flash.alert = t('isaca.rails.user_consent.consent_required')
|
22
|
+
redirect_to user_consent_path
|
23
|
+
end
|
24
|
+
else
|
25
|
+
session[:after_sign_in_path] = request.fullpath if request.get?
|
26
|
+
flash.alert = t('isaca.rails.sessions.sign_in_required')
|
27
|
+
|
28
|
+
respond_to do |format|
|
29
|
+
format.html {redirect_to sign_in_path}
|
30
|
+
format.json do
|
31
|
+
render json: {error: t('isaca.rails.sessions.sign_in_required')}.to_json, status: :unauthorized
|
34
32
|
end
|
35
33
|
end
|
36
|
-
rescue Isaca::ServiceError => e
|
37
|
-
cookies.delete('Token', domain: :all) if token_cookie_exists?
|
38
|
-
@current_isaca_user = nil
|
39
|
-
reset_session
|
40
|
-
redirect_to sign_in_path, alert: "ISACA Service Error: #{e.message}"
|
41
34
|
end
|
42
35
|
end
|
43
36
|
|
@@ -127,12 +120,18 @@ module Isaca
|
|
127
120
|
# @raise [Isaca::ServiceError] An error can be raised by {Isaca::Request::GetUserDetailsByToken#get} or {Isaca::Request::GetUserByID#get}
|
128
121
|
def set_current_isaca_user
|
129
122
|
# Using the Token cookie we can fetch our users details from isaca
|
130
|
-
|
131
|
-
|
132
|
-
|
123
|
+
begin
|
124
|
+
if Isaca::Rails.configuration.cache_sso
|
125
|
+
isaca_user = ::Rails.cache.fetch("isaca/request/get_user_details_by_token/#{cookies['Token']}", expires_in: 2.minutes) do
|
126
|
+
Isaca::Request::GetUserDetailsByToken.get(cookies['Token'])
|
127
|
+
end
|
128
|
+
else
|
129
|
+
isaca_user = Isaca::Request::GetUserDetailsByToken.get(cookies['Token'])
|
133
130
|
end
|
134
|
-
|
135
|
-
|
131
|
+
rescue Isaca::ExpiredTokenError => e
|
132
|
+
cookies.delete('Token', domain: :all) if token_cookie_exists?
|
133
|
+
reset_session
|
134
|
+
return nil
|
136
135
|
end
|
137
136
|
|
138
137
|
# The GetUserDetailsByToken endpoint does not return everything we need, we need to supplement our attributes
|
data/lib/isaca/rails/version.rb
CHANGED