Skip to content

Commit b9e9836

Browse files
committed
IAM: reduce verbosity
Some messages are only needed when debugging, not in production.
1 parent 26273b6 commit b9e9836

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

swift3/iam.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ def do_explicit_check(self, effect, action, req_res, req):
256256
for num, statement in enumerate(self._rules['Statement']):
257257
# Statement ID is optional
258258
sid = statement.get('Sid', 'statement-id-%d' % num)
259-
self.logger.info("===> Checking statement %s (%s)",
260-
sid, statement['Effect'])
259+
self.logger.debug("===> Checking statement %s (%s)",
260+
sid, statement['Effect'])
261261
if statement['Effect'] != effect:
262262
continue
263263

@@ -272,8 +272,8 @@ def do_explicit_check(self, effect, action, req_res, req):
272272
# Found a wildcard match
273273
break
274274
else:
275-
self.logger.info('Skipping %s, action %s is not in the list',
276-
sid, action)
275+
self.logger.debug('Skipping %s, action %s is not in the list',
276+
sid, action)
277277
continue
278278

279279
for resource_str in statement['Resource']:
@@ -282,25 +282,25 @@ def do_explicit_check(self, effect, action, req_res, req):
282282
# check wildcards before everything else
283283
if (rule_res.arn == ARN_WILDCARD_BUCKET and
284284
self.check_condition(statement, req)):
285-
self.logger.info('%s: matches everything', sid)
285+
self.logger.debug('%s: matches everything', sid)
286286
return True, sid
287287

288288
# Ensure the requested and the current resource are of the
289289
# same type. The specification says that a wildcard in the
290290
# bucket name should not match objects (stop at first slash).
291291
if rule_res.type != req_res.type:
292-
self.logger.info('%s: skip, resource types do not match',
293-
sid)
292+
self.logger.debug('%s: skip, resource types do not match',
293+
sid)
294294
continue
295295

296296
# Do a case-sensitive match between the requested resource
297297
# and the resource of the current rule.
298298
if (fnmatchcase(req_res.arn, rule_res.arn) and
299299
self.check_condition(statement, req)):
300-
self.logger.info('%s: wildcard or exact match', sid)
300+
self.logger.debug('%s: wildcard or exact match', sid)
301301
return True, sid
302302

303-
self.logger.info('No %s match found', effect)
303+
self.logger.debug('No %s match found', effect)
304304
return False, None
305305

306306
def match_explicit_deny(self, action, resource, req):
@@ -343,9 +343,9 @@ def wrapper(*args, **kwargs):
343343
else:
344344
rsc = None
345345

346-
effect, _sid = matcher(rsc, action, req)
347-
# TODO(IAM): log sid, the ID of the rule statement which matched
346+
effect, sid = matcher(rsc, action, req)
348347
if effect != EXPLICIT_ALLOW:
348+
matcher.logger.info("Request denied by IAM (sid=%s)", sid)
349349
raise AccessDenied()
350350

351351
return func(*args, **kwargs)

0 commit comments

Comments
 (0)