Skip to content

Support notification signature validation #9

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

Open
judgej opened this issue Jan 19, 2019 · 1 comment
Open

Support notification signature validation #9

judgej opened this issue Jan 19, 2019 · 1 comment
Assignees

Comments

@judgej
Copy link
Member

judgej commented Jan 19, 2019

The notification message comes with a signature in the header, for example:

X-Anet-Signature: sha512=8EB900743516AC9415516FF0A1813BB38FBB5CCE6D4256B3FC56BD1FE661258F8CEF6AED0899B9095DFB66596E3F71340CD7A0BB44930618D383266242C70499

This should be used to validate the notification has not been tampered with.

Some details:

The documentation does lack some details about how the notification is actually verified. I think the SDK is probably the main source of information for this.

@judgej judgej self-assigned this Jan 19, 2019
@judgej judgej changed the title Support notifcation signature validation Support notification signature validation Jan 20, 2019
judgej added a commit that referenced this issue Jan 31, 2019
No tests yet. Will write some tests before releasing, but here
it is if you want to play with it in the meantime.
@judgej
Copy link
Member Author

judgej commented Jan 31, 2019

Without tests, the main functionality is available.

Where signatures are validated in notification handlers is a little unclear in Omnipay across the drivers. It cannot be done in message instantiation, as the constructor does not have access to the gateway parameters (these are set using initialize() after instantiation. It could be done at that point, however, throwing an exception here means there is no object to inspect and log when debugging.

The approach I have taken, is to assert the signature validity at the point the transaction result is fetched - all the methods in the NotificationInterface. Until that point, the object will be instantiated, you can extract the raw and parsed data, and can manually do a check isSignatureValid().

judgej added a commit that referenced this issue Feb 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant