forked from fedora-infra/fedmsg
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signing and validating messages sent.
- Loading branch information
Showing
12 changed files
with
94 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
fedmsg/tests/test_certs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
import os | |||
import socket | |||
|
|||
SEP = os.path.sep | |||
here = os.getcwd() | |||
hostname = socket.gethostname() | |||
|
|||
config = dict( | |||
sign_messages=True, | |||
validate_signatures=True, | |||
ssldir=SEP.join([here, 'dev_certs']), | |||
|
|||
certnames={ | |||
hostname: "test_cert", | |||
# In prod/stg, map hostname to the name of the cert in ssldir. | |||
# Unfortunately, we can't use socket.getfqdn() | |||
#"app01.stg": "app01.stg.phx2.fedoraproject.org", | |||
}, | |||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,20 @@ | |||
import fedmsg.crypto | |||
import moksha.api.hub.consumer | |||
|
|||
class FedmsgConsumer(moksha.api.hub.consumer.Consumer): | |||
validate_signatures = False | |||
|
|||
def __init__(self, *args, **kwargs): | |||
super(FedmsgConsumer, self).__init__(*args, **kwargs) | |||
self.validate_signatures = self.hub.config.get('validate_signatures') | |||
|
|||
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 not fedmsg.crypto.validate(message['body'], **self.hub.config): | |||
raise RuntimeWarning("Failed to authn message.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters