Skip to content

Commit

Permalink
Return earlier when validate_signatures is turned off
Browse files Browse the repository at this point in the history
When connecting to a bus without messages being signed, an exception would be raised with the message "Topic envelope mismatch". If signing is turned off, none of the message c
ontents should be examined in the `validate` function.
  • Loading branch information
mprahl committed Nov 10, 2016
1 parent caa5cc9 commit 0e1189c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions fedmsg/consumers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ def _make_query(page=1):

def validate(self, message):
""" This needs to raise an exception, caught by moksha. """
# If we're not validating, then everything is valid.
# If this is turned on globally, our child class can override it.
if not self.validate_signatures:
return

if hasattr(message, '__json__'):
message = message.__json__()
Expand All @@ -214,11 +218,6 @@ def validate(self, message):
if not message['topic'] == message['body']['topic']:
raise RuntimeWarning("Topic envelope mismatch.")

# If we're not validating, then everything is valid.
# If this is turned on globally, our child class can override it.
if not self.validate_signatures:
return

if not fedmsg.crypto.validate(message['body'], **self.hub.config):
raise RuntimeWarning("Failed to authn message.")

Expand Down

0 comments on commit 0e1189c

Please sign in to comment.