0055-misc-fix-logging-not-lazy-pylint-error-56982.patch
src/authentic2/backends/ldap_backend.py | ||
---|---|---|
1299 | 1299 |
if extra_attribute_config['loop_over_attribute'] not in attribute_map: |
1300 | 1300 |
log.debug( |
1301 | 1301 |
'loop_over_attribute %s not present (or empty) in retrieved user object attributes.' |
1302 |
' Pass.' % extra_attribute_config['loop_over_attribute'] |
|
1302 |
' Pass.', |
|
1303 |
extra_attribute_config['loop_over_attribute'], |
|
1303 | 1304 |
) |
1304 | 1305 |
continue |
1305 | 1306 |
if 'filter' not in extra_attribute_config and 'basedn' not in extra_attribute_config: |
1306 | 1307 |
log.warning( |
1307 | 1308 |
'Extra attribute %s not correctly configured : you need to defined at least one of' |
1308 |
' filter or basedn parameters' % extra_attribute_name |
|
1309 |
' filter or basedn parameters', |
|
1310 |
extra_attribute_name, |
|
1309 | 1311 |
) |
1310 | 1312 |
for item in attribute_map[extra_attribute_config['loop_over_attribute']]: |
1311 | 1313 |
ldap_filter = extra_attribute_config.get('filter', 'objectClass=*').format( |
... | ... | |
1325 | 1327 |
results = conn.search_s(ldap_basedn, ldap_scope, ldap_filter, ldap_attributes_names) |
1326 | 1328 |
except ldap.LDAPError: |
1327 | 1329 |
log.exception( |
1328 |
'unable to retrieve extra attribute %s for item %s' % (extra_attribute_name, item)
|
|
1330 |
'unable to retrieve extra attribute %s for item %s', extra_attribute_name, item
|
|
1329 | 1331 |
) |
1330 | 1332 |
continue |
1331 | 1333 |
else: |
... | ... | |
1333 | 1335 |
item_value = {} |
1334 | 1336 |
for dn, attrs in results: |
1335 | 1337 |
log.debug( |
1336 |
'Object retrieved for extra attr %s with item %s : %s %s' |
|
1337 |
% (extra_attribute_name, item, dn, attrs) |
|
1338 |
'Object retrieved for extra attr %s with item %s : %s %s', |
|
1339 |
extra_attribute_name, |
|
1340 |
item, |
|
1341 |
dn, |
|
1342 |
attrs, |
|
1338 | 1343 |
) |
1339 | 1344 |
for key in ldap_attributes_mapping: |
1340 | 1345 |
item_value[key] = attrs.get(ldap_attributes_mapping[key].lower()) |
1341 | 1346 |
log.debug( |
1342 |
'Object attribute %s value retrieved for extra attr %s with item %s : %s' |
|
1343 |
% (ldap_attributes_mapping[key], extra_attribute_name, item, item_value[key]) |
|
1347 |
'Object attribute %s value retrieved for extra attr %s with item %s : %s', |
|
1348 |
ldap_attributes_mapping[key], |
|
1349 |
extra_attribute_name, |
|
1350 |
item, |
|
1351 |
item_value[key], |
|
1344 | 1352 |
) |
1345 | 1353 |
if not item_value[key]: |
1346 | 1354 |
del item_value[key] |
... | ... | |
1348 | 1356 |
item_value[key] = item_value[key][0] |
1349 | 1357 |
extra_attribute_values.append(item_value) |
1350 | 1358 |
else: |
1351 |
log.warning('loop_over_attribute not defined for extra attribute %s' % extra_attribute_name)
|
|
1359 |
log.warning('loop_over_attribute not defined for extra attribute %s', extra_attribute_name)
|
|
1352 | 1360 |
extra_attribute_serialization = extra_attribute_config.get('serialization', None) |
1353 | 1361 |
if extra_attribute_serialization is None: |
1354 | 1362 |
attribute_map[extra_attribute_name] = extra_attribute_values |
... | ... | |
1356 | 1364 |
attribute_map[extra_attribute_name] = json.dumps(extra_attribute_values) |
1357 | 1365 |
else: |
1358 | 1366 |
log.warning( |
1359 |
'Invalid serialization type "%s" for extra attribute %s' |
|
1360 |
% (extra_attribute_serialization, extra_attribute_name) |
|
1367 |
'Invalid serialization type "%s" for extra attribute %s', |
|
1368 |
extra_attribute_serialization, |
|
1369 |
extra_attribute_name, |
|
1361 | 1370 |
) |
1362 | 1371 |
return attribute_map |
1363 | 1372 | |
... | ... | |
1568 | 1577 |
count += 1 |
1569 | 1578 |
user = backend._return_user(dn, None, conn, block, attrs) |
1570 | 1579 |
if not user: |
1571 |
log.warning('unable to retrieve user for dn %s' % dn)
|
|
1580 |
log.warning('unable to retrieve user for dn %s', dn)
|
|
1572 | 1581 |
continue |
1573 | 1582 |
if user._changed or user._created: |
1574 | 1583 |
log.info( |
src/authentic2/disco_service/disco_responder.py | ||
---|---|---|
152 | 152 | |
153 | 153 |
if not is_known_idp(idp_selected): |
154 | 154 |
message = 'The idp is unknown.' |
155 |
logger.warn("disco: Unknown selected idp %s" % idp_selected)
|
|
155 |
logger.warn("disco: Unknown selected idp %s", idp_selected)
|
|
156 | 156 |
save_key_values(request, entityID, _return, policy, returnIDParam, isPassive) |
157 | 157 |
return HttpResponseRedirect(reverse(idp_selection)) |
158 | 158 |
src/authentic2/idp/saml/backend.py | ||
---|---|---|
97 | 97 | |
98 | 98 |
def logout_list(self, request): |
99 | 99 |
all_sessions = models.LibertySession.objects.filter(django_session_key=request.session.session_key) |
100 |
self.logger.debug("all_sessions %r" % all_sessions)
|
|
100 |
self.logger.debug("all_sessions %r", all_sessions)
|
|
101 | 101 |
provider_ids = {s.provider_id for s in all_sessions} |
102 |
self.logger.debug("provider_ids %r" % provider_ids)
|
|
102 |
self.logger.debug("provider_ids %r", provider_ids)
|
|
103 | 103 |
result = [] |
104 | 104 |
for provider_id in provider_ids: |
105 | 105 |
name = provider_id |
src/authentic2/idp/saml/saml2_endpoints.py | ||
---|---|---|
487 | 487 |
kwargs['entity_id'] = login.remoteProviderId |
488 | 488 |
kwargs['user'] = request.user |
489 | 489 |
logger.debug( |
490 |
'sending nameID %(name_id_format)r: %(name_id_content)r to %(entity_id)s for user %(user)s' % kwargs |
|
490 |
'sending nameID %r: %r to %s for user %s', |
|
491 |
kwargs['name_id_format'], |
|
492 |
kwargs['name_id_content'], |
|
493 |
kwargs['entity_id'], |
|
494 |
kwargs['user'], |
|
491 | 495 |
) |
492 | 496 |
register_new_saml2_session(request, login) |
493 | 497 |
add_attributes(request, entity_id, assertion, provider, nid_format) |
... | ... | |
559 | 563 |
logger.debug('processAuthnRequestMsg not successful') |
560 | 564 |
log_info_authn_request_details(login) |
561 | 565 |
provider_id = login.remoteProviderId |
562 |
logger.debug('loading provider %s' % provider_id)
|
|
566 |
logger.debug('loading provider %s', provider_id)
|
|
563 | 567 |
provider_loaded = load_provider(request, provider_id, server=login.server, autoload=True) |
564 | 568 |
if not provider_loaded: |
565 | 569 |
add_url = reverse('admin:saml_libertyprovider_add_from_url') |
... | ... | |
812 | 816 |
# We catch denied decisions i.e. dic['authz'] = False |
813 | 817 |
access_granted = True |
814 | 818 |
for decision in decisions: |
815 |
logger.debug('authorize_service connected to function %s' % decision[0].__name__)
|
|
819 |
logger.debug('authorize_service connected to function %s', decision[0].__name__)
|
|
816 | 820 |
dic = decision[1] |
817 | 821 |
if dic and 'authz' in dic: |
818 | 822 |
logger.debug('decision is %s', dic['authz']) |
... | ... | |
1230 | 1234 |
latest = x.latest('creation') |
1231 | 1235 |
result.append(latest) |
1232 | 1236 |
if lib_session1: |
1233 |
logger.debug('last session %s' % lib_session1)
|
|
1237 |
logger.debug('last session %s', lib_session1)
|
|
1234 | 1238 |
return lib_session1, result, django_session_keys |
1235 | 1239 | |
1236 | 1240 | |
... | ... | |
1614 | 1618 |
'format': nameIdPolicy.format, |
1615 | 1619 |
'spNameQualifier': nameIdPolicy.spNameQualifier, |
1616 | 1620 |
} |
1617 |
logger.debug('%r' % details)
|
|
1621 |
logger.debug('%r', details)
|
|
1618 | 1622 | |
1619 | 1623 | |
1620 | 1624 |
def check_destination(request, req_or_res): |
src/authentic2/saml/common.py | ||
---|---|---|
504 | 504 |
if not logger: |
505 | 505 |
logger = logging |
506 | 506 |
if warning: |
507 |
logging.warning('Showing message %r on an error page' % message)
|
|
507 |
logging.warning('Showing message %r on an error page', message)
|
|
508 | 508 |
else: |
509 |
logging.error('Showing message %r on an error page' % message)
|
|
509 |
logging.error('Showing message %r on an error page', message)
|
|
510 | 510 |
if back is None: |
511 | 511 |
referer = request.META.get('HTTP_REFERER') |
512 | 512 |
if referer: |
src/authentic2/utils/spooler.py | ||
---|---|---|
69 | 69 |
try: |
70 | 70 |
func(*args, **kwargs) |
71 | 71 |
except Exception: |
72 |
logger.exception('spooler: exception during %s(%s, %s)' % (func.__name__, args, kwargs))
|
|
72 |
logger.exception('spooler: exception during %s(%s, %s)', func.__name__, args, kwargs)
|
|
73 | 73 |
else: |
74 |
logger.info('spooler: success of %s(%s, %s)' % (func.__name__, args, kwargs))
|
|
74 |
logger.info('spooler: success of %s(%s, %s)', func.__name__, args, kwargs)
|
|
75 | 75 | |
76 | 76 |
# pass arguments as pickles |
77 | 77 |
base_spooler = spool(pass_arguments=True)(spooler_func) |
src/authentic2/views.py | ||
---|---|---|
617 | 617 |
targets.append(next_url) |
618 | 618 |
# Put redirection targets in session (after local logout) |
619 | 619 |
request.session['logout_redirections'] = targets |
620 |
logger.debug(f'All planned redirections : {targets}')
|
|
620 |
logger.debug('All planned redirections : %s', targets)
|
|
621 | 621 |
# Full logout by redirections if any |
622 | 622 |
targets = request.session.pop('logout_redirections', None) |
623 | 623 |
if targets: |
src/authentic2_auth_oidc/views.py | ||
---|---|---|
208 | 208 |
error = None |
209 | 209 |
error_description = None |
210 | 210 |
logger.warning( |
211 |
'auth_oidc: token_endpoint returned HTTP error status %(status_code)s for %(issuer)s with' |
|
212 |
' content %(content)s' |
|
213 |
% { |
|
214 |
'issuer': provider.issuer, |
|
215 |
'status_code': status_code, |
|
216 |
'content': content, |
|
217 |
} |
|
211 |
'auth_oidc: token_endpoint returned HTTP error status %s for %s with content %s', |
|
212 |
provider.issuer, |
|
213 |
status_code, |
|
214 |
content, |
|
218 | 215 |
) |
219 | 216 |
if error: |
220 | 217 |
messages.warning( |
... | ... | |
241 | 238 |
return self.continue_to_next_url(request) |
242 | 239 | |
243 | 240 |
except requests.RequestException as e: |
244 |
logger.warning( |
|
245 |
'auth_oidc: failed to contact the token_endpoint for %(issuer)s, %(exception)s' |
|
246 |
% { |
|
247 |
'issuer': provider.issuer, |
|
248 |
'exception': e, |
|
249 |
} |
|
250 |
) |
|
241 |
logger.warning('auth_oidc: failed to contact the token_endpoint for %s, %s', provider.issuer, e) |
|
251 | 242 |
messages.warning( |
252 | 243 |
request, |
253 | 244 |
_('Provider %(name)s is down, report %(request_id)s to an administrator. ') |
... | ... | |
261 | 252 |
result = response.json() |
262 | 253 |
except ValueError as e: |
263 | 254 |
logger.warning( |
264 |
'auth_oidc: response from %s is not a JSON document, %s, %r' |
|
265 |
% (provider.token_endpoint, e, response.content) |
|
255 |
'auth_oidc: response from %s is not a JSON document, %s, %r', |
|
256 |
provider.token_endpoint, |
|
257 |
e, |
|
258 |
response.content, |
|
266 | 259 |
) |
267 | 260 |
messages.warning( |
268 | 261 |
request, |
... | ... | |
281 | 274 |
or 'id_token' not in result |
282 | 275 |
): |
283 | 276 |
logger.warning( |
284 |
'auth_oidc: invalid token endpoint response from %s: %r' % (provider.token_endpoint, result)
|
|
277 |
'auth_oidc: invalid token endpoint response from %s: %r', provider.token_endpoint, result
|
|
285 | 278 |
) |
286 | 279 |
messages.warning( |
287 | 280 |
request, |
288 |
- |