https://github.com/zircote/bona-fides
A Python lib for validation of AWS SNS Notification signatures.
https://github.com/zircote/bona-fides
Last synced: about 1 year ago
JSON representation
A Python lib for validation of AWS SNS Notification signatures.
- Host: GitHub
- URL: https://github.com/zircote/bona-fides
- Owner: zircote
- License: apache-2.0
- Created: 2015-02-07T21:36:40.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-09T03:56:34.000Z (over 11 years ago)
- Last Synced: 2025-02-17T00:45:45.490Z (over 1 year ago)
- Language: Python
- Size: 141 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# SNS Signatory
TODO: still needs work, ie logging, error handling and expanded configuration details/options. And Docs
### Example Usage
Using the AWS SNS Notification example from http://docs.aws.amazon.com/sns/latest/dg/json-formats.html:
```json
{
"Type" : "Notification",
"MessageId" : "22b80b92-fdea-4c2c-8f9d-bdfb0c7bf324",
"TopicArn" : "arn:aws:sns:us-west-2:123456789012:MyTopic",
"Subject" : "My First Message",
"Message" : "Hello world!",
"Timestamp" : "2012-05-02T00:54:06.655Z",
"SignatureVersion" : "1",
"Signature" : "EXAMPLEw6JRNwm1LFQL4ICB0bnXrdB8ClRMTQFGBqwLpGbM78tJ4etTwC5zU7O3tS6tGpey3ejedNdOJ+1fkIp9F2/LmNVKb5aFlYq+9rk9ZiPph5YlLmWsDcyC5T+Sy9/umic5S0UQc2PEtgdpVBahwNOdMW4JPwk0kAJJztnc=",
"SigningCertURL" : "https://sns.us-west-2.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",
"UnsubscribeURL" : "https://sns.us-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-2:123456789012:MyTopic:c9135db0-26c4-47ec-8998-413945fb5a96"
}
```
```python
json_string =
OPTIONS = {
"white_list": [
"arn:aws:sns:us-east-1:199999999999:blah_blah", # Accept for a specific topic/arn
],
"validate_signature": True
}
sns_validation = bona_fides.Validator(OPTIONS)
notification = sns_validation.handle(m)
if notification.is_valid:
assert(notification.message)
```