Commit 602c2a3f by Carlos Andrés Rocha

[34078525] Log openid root_trust validation failures as errors

parent 0099749a
...@@ -353,39 +353,36 @@ def validate_trust_root(openid_request): ...@@ -353,39 +353,36 @@ def validate_trust_root(openid_request):
trusted_roots = getattr(settings, 'OPENID_PROVIDER_TRUSTED_ROOT', None) trusted_roots = getattr(settings, 'OPENID_PROVIDER_TRUSTED_ROOT', None)
if trusted_roots is None: if not trusted_roots:
log.debug('not using trusted roots')
# not using trusted roots # not using trusted roots
return True return True
log.debug('validating trusted roots')
# don't allow empty trust roots # don't allow empty trust roots
if (not hasattr(openid_request, 'trust_root') or if (not hasattr(openid_request, 'trust_root') or
openid_request.trust_root is None): not openid_request.trust_root):
log.debug('no trust_root') log.error('no trust_root')
return False return False
# ensure trust root parses cleanly (one wildcard, of form *.foo.com, etc.) # ensure trust root parses cleanly (one wildcard, of form *.foo.com, etc.)
trust_root = TrustRoot.parse(openid_request.trust_root) trust_root = TrustRoot.parse(openid_request.trust_root)
if trust_root is None: if not trust_root:
log.debug('invalid trust_root') log.error('invalid trust_root')
return False return False
# don't allow empty return tos # don't allow empty return tos
if (not hasattr(openid_request, 'return_to') or if (not hasattr(openid_request, 'return_to') or
openid_request.return_to is None): not openid_request.return_to):
log.debug('empty return_to') log.error('empty return_to')
return False return False
# ensure return to is within trust root # ensure return to is within trust root
if not trust_root.validateURL(openid_request.return_to): if not trust_root.validateURL(openid_request.return_to):
log.debug('invalid return_to') log.error('invalid return_to')
return False return False
# check that the root matches the ones we trust # check that the root matches the ones we trust
if not any(r for r in trusted_roots if fnmatch.fnmatch(trust_root, r)): if not any(r for r in trusted_roots if fnmatch.fnmatch(trust_root, r)):
log.debug('non-trusted root') log.error('non-trusted root')
return False return False
return True return True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment