-
Notifications
You must be signed in to change notification settings - Fork 521
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
Request middleware fails on validate set to false #460
Request middleware fails on validate set to false #460
Conversation
@childish-sambino Please review this. |
Instead of removing the check from |
Isn't X-Twilio-Signature is expected from Twilio only? How can someone create or set X-Twilio-Signature on dev environment or during testing? Why is it asked here in docs to disable validation during testing then ? |
If you move the header check to within the |
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
X-Twilio-Signature check is added before checking the validate option. The request will fail even if validate option is set to false. If a request is sent from POSTMAN on dev/test environment, which means the validate option is false, so there is no need to check if the header is present or not. Similarly, if a test is written for Express route in my code, the middleware will fail despite the fact that validate option is false.
It also checks for X-Twilio-Signature here which will not fail with validate option set to false. If validate option is true and X-Twilio-Signature is undefined, empty string is set as a default value which will then obviously differ from expected twilio signature and fail.
Contributing to Twilio