Skip to content

Feature/sns validator #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 27, 2017
Merged

Feature/sns validator #27

merged 5 commits into from
Jul 27, 2017

Conversation

jeskew
Copy link
Contributor

@jeskew jeskew commented Jun 23, 2017

This PR adds a TS port of https://github.com/aws/aws-js-sns-message-validator The test fixtures include the same message captured on an HTTP endpoint and in a lambda function, and a functional test ensuring those known-valid signatures are correctly validated is included.

Once this gets reviewed, I would like to release it as version 0.4.0 of the sns-validator package, whose readme should be updated to say "This package has been merged into the official AWS SDK for JavaScript" or the like once v3 is in developer preview.

@jeskew
Copy link
Contributor Author

jeskew commented Jun 24, 2017

Upon further testing, I found that messages without a subject will have no Subject key in the canonical form used to generate the signature and then sent to HTTP(S) endpoints, but will be rendered with a Subject of null when included in an event passed to a Lambda handler. The last commit addresses that, and I've captured a couple messages (one with and one without a subject) sent to both a lambda function and an HTTP endpoint to verify that the signature can be validated for both using the canonical message format.

Copy link
Contributor Author

@jeskew jeskew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transcribed over-the-shoulder review by @stealthycoin and @AllanFly120

});


it('should produce a canonical string from subscription confirmations', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/subscription confirmations/unsubscription confirmations/

{
"name": "@aws/sns-message-validator",
"private": true,
"version": "0.0.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should match what's in the existing library and be version 0.4.0

(
toSign: string,
key: keyof T
): string => `${toSign}${key}\n${message[key]}\n`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formatting is terrible.

@jeskew jeskew requested a review from stealthycoin July 27, 2017 00:44
@jeskew
Copy link
Contributor Author

jeskew commented Jul 27, 2017

@stealthycoin says #shipit

@jeskew jeskew merged commit 63ba221 into aws:master Jul 27, 2017
@jeskew jeskew deleted the feature/sns-validator branch July 27, 2017 19:33
trivikr referenced this pull request in trivikr/aws-sdk-js-v3 Dec 10, 2018
* WIP commit

* Add tests for getCertificate

* Wire up certificate fetching and signature verification and round out the test suite

* Remove `null` Subject fields in the convertLambdaNotification function

* Improve formatting and fix typos
@lock
Copy link

lock bot commented Sep 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant