10
10
11
11
from satosa .internal import InternalData
12
12
from ..exception import SATOSAAuthenticationError
13
- from ..logging_util import satosa_logging
14
13
from ..micro_services .base import ResponseMicroService
15
14
from ..response import Redirect
16
15
16
+ import satosa .logging_util as lu
17
17
logger = logging .getLogger (__name__ )
18
18
19
19
@@ -53,8 +53,9 @@ def _handle_al_response(self, context):
53
53
status_code , message = self ._get_uuid (context , internal_response .auth_info .issuer , internal_response .attributes ['issuer_user_id' ])
54
54
55
55
if status_code == 200 :
56
- satosa_logging (logger , logging .INFO , "issuer/id pair is linked in AL service" ,
57
- context .state )
56
+ msg = "issuer/id pair is linked in AL service"
57
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
58
+ logger .info (logline )
58
59
internal_response .subject_id = message
59
60
if self .id_to_attr :
60
61
internal_response .attributes [self .id_to_attr ] = [message ]
@@ -64,8 +65,9 @@ def _handle_al_response(self, context):
64
65
else :
65
66
# User selected not to link their accounts, so the internal.response.subject_id is based on the
66
67
# issuers id/sub which is fine
67
- satosa_logging (logger , logging .INFO , "User selected to not link their identity in AL service" ,
68
- context .state )
68
+ msg = "User selected to not link their identity in AL service"
69
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
70
+ logger .info (logline )
69
71
del context .state [self .name ]
70
72
return super ().process (context , internal_response )
71
73
@@ -94,15 +96,17 @@ def process(self, context, internal_response):
94
96
# Store the issuer subject_id/sub because we'll need it in handle_al_response
95
97
internal_response .attributes ['issuer_user_id' ] = internal_response .subject_id
96
98
if status_code == 200 :
97
- satosa_logging (logger , logging .INFO , "issuer/id pair is linked in AL service" ,
98
- context .state )
99
+ msg = "issuer/id pair is linked in AL service"
100
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
101
+ logger .info (logline )
99
102
internal_response .subject_id = message
100
103
data ['user_id' ] = message
101
104
if self .id_to_attr :
102
105
internal_response .attributes [self .id_to_attr ] = [message ]
103
106
else :
104
- satosa_logging (logger , logging .INFO , "issuer/id pair is not linked in AL service. Got a ticket" ,
105
- context .state )
107
+ msg = "issuer/id pair is not linked in AL service. Got a ticket"
108
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
109
+ logger .info (logline )
106
110
data ['ticket' ] = message
107
111
jws = JWS (json .dumps (data ), alg = self .signing_key .alg ).sign_compact ([self .signing_key ])
108
112
context .state [self .name ] = internal_response .to_dict ()
@@ -137,12 +141,14 @@ def _get_uuid(self, context, issuer, id):
137
141
response = requests .get (request )
138
142
except Exception as con_exc :
139
143
msg = "Could not connect to account linking service"
140
- satosa_logging (logger , logging .CRITICAL , msg , context .state , exc_info = True )
144
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
145
+ logger .critical (logline )
141
146
raise SATOSAAuthenticationError (context .state , msg ) from con_exc
142
147
143
148
if response .status_code not in [200 , 404 ]:
144
- msg = "Got status code '%s' from account linking service" % (response .status_code )
145
- satosa_logging (logger , logging .CRITICAL , msg , context .state )
149
+ msg = "Got status code '{}' from account linking service" .format (response .status_code )
150
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
151
+ logger .critical (logline )
146
152
raise SATOSAAuthenticationError (context .state , msg )
147
153
148
154
return response .status_code , response .text
0 commit comments