12
12
from jwkest .jws import JWS
13
13
from requests .exceptions import ConnectionError
14
14
15
+ import satosa .logging_util as lu
15
16
from satosa .internal import InternalData
16
- from satosa .logging_util import satosa_logging
17
17
from satosa .micro_services .base import ResponseMicroService
18
18
from satosa .response import Redirect
19
19
20
+
20
21
logger = logging .getLogger (__name__ )
21
22
22
23
STATE_KEY = "CONSENT"
@@ -63,17 +64,22 @@ def _handle_consent_response(self, context):
63
64
try :
64
65
consent_attributes = self ._verify_consent (hash_id )
65
66
except ConnectionError as e :
66
- satosa_logging (logger , logging .ERROR ,
67
- "Consent service is not reachable, no consent given." , context .state )
67
+ msg = "Consent service is not reachable, no consent given."
68
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
69
+ logger .error (logline )
68
70
# Send an internal_response without any attributes
69
71
consent_attributes = None
70
72
71
73
if consent_attributes is None :
72
- satosa_logging (logger , logging .INFO , "Consent was NOT given" , context .state )
74
+ msg = "Consent was NOT given"
75
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
76
+ logger .info (logline )
73
77
# If consent was not given, then don't send any attributes
74
78
consent_attributes = []
75
79
else :
76
- satosa_logging (logger , logging .INFO , "Consent was given" , context .state )
80
+ msg = "Consent was given"
81
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
82
+ logger .info (logline )
77
83
78
84
internal_response .attributes = self ._filter_attributes (internal_response .attributes , consent_attributes )
79
85
return self ._end_consent (context , internal_response )
@@ -94,8 +100,9 @@ def _approve_new_consent(self, context, internal_response, id_hash):
94
100
try :
95
101
ticket = self ._consent_registration (consent_args )
96
102
except (ConnectionError , UnexpectedResponseError ) as e :
97
- satosa_logging (logger , logging .ERROR , "Consent request failed, no consent given: {}" .format (str (e )),
98
- context .state )
103
+ msg = "Consent request failed, no consent given: {}" .format (str (e ))
104
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
105
+ logger .error (logline )
99
106
# Send an internal_response without any attributes
100
107
internal_response .attributes = {}
101
108
return self ._end_consent (context , internal_response )
@@ -125,15 +132,18 @@ def process(self, context, internal_response):
125
132
# Check if consent is already given
126
133
consent_attributes = self ._verify_consent (id_hash )
127
134
except requests .exceptions .ConnectionError as e :
128
- satosa_logging (logger , logging .ERROR ,
129
- "Consent service is not reachable, no consent given." , context .state )
135
+ msg = "Consent service is not reachable, no consent is given."
136
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
137
+ logger .error (logline )
130
138
# Send an internal_response without any attributes
131
139
internal_response .attributes = {}
132
140
return self ._end_consent (context , internal_response )
133
141
134
142
# Previous consent was given
135
143
if consent_attributes is not None :
136
- satosa_logging (logger , logging .DEBUG , "Previous consent was given" , context .state )
144
+ msg = "Previous consent was given"
145
+ logline = lu .LOG_FMT .format (id = lu .get_session_id (context .state ), message = msg )
146
+ logger .debug (logline )
137
147
internal_response .attributes = self ._filter_attributes (internal_response .attributes , consent_attributes )
138
148
return self ._end_consent (context , internal_response )
139
149
0 commit comments