-
Notifications
You must be signed in to change notification settings - Fork 947
Add option to skip signature verification #1635
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
base: master
Are you sure you want to change the base?
Add option to skip signature verification #1635
Conversation
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.
(unnecessary change)
|
||
/** | ||
* Creates a new instance. | ||
* | ||
* @param signatureValidator LINE messaging API's signature validator | ||
*/ | ||
public WebhookParser(SignatureValidator signatureValidator) { | ||
public WebhookParser(SignatureValidator signatureValidator, |
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.
can you update javadoc(comment) to explain when we should use SkipSignatureVerificationSupplier
?
|
||
/** | ||
* Creates a new instance. | ||
* | ||
* @param signatureValidator LINE messaging API's signature validator | ||
*/ | ||
public WebhookParser(SignatureValidator signatureValidator) { | ||
public WebhookParser(SignatureValidator signatureValidator, |
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.
Can you create another constructor that doesn't break the build, and keep current constructor? Alternatively, you could set a non-skipping SkipSignatureVerificationSupplier
as a default value.
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.
In cases other than temporary migration for channel secret, it should often be specified as true
.
Having it set to return true
by default in line-bot-sdk-java, with the possibility for users to override it if they wish, seems more convenient. It might not be necessary to require users to specify it, if we set default value.
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.
Did you mean to say this?
In cases other than temporary migration for the channel secret, it should often be specified as false.
I have made the change to set the default to false. Please review it. b9c3430
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.
oops, yes
/** | ||
* Special {@link BooleanSupplier} for Skip Signature Verification. | ||
* | ||
* <p>You can implement it to return whether to skip signature verification. |
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.
(add comment)
+ if true
is passed, webhook signature verification is skipped. This may be helpful when you update channel secret and you want to skip the verification temporarily.
new MockSkipSignatureVerificationSupplier(); | ||
|
||
static class MockSkipSignatureVerificationSupplier | ||
implements SkipSignatureVerificationSupplier { | ||
@Override | ||
public boolean getAsBoolean() { | ||
return false; | ||
} | ||
} |
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.
can we use FixedSkipSignatureVerificationSupplier.of(false)
instead of mock?
|
||
/** | ||
* Creates a new instance. | ||
* | ||
* @param signatureValidator LINE messaging API's signature validator | ||
*/ | ||
public WebhookParser(SignatureValidator signatureValidator) { | ||
public WebhookParser(SignatureValidator signatureValidator, |
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.
oops, yes
Changes
Motivation
The signature returned with webhooks is calculated using a single channel secret. If the bot owner changes their channel secret, the signature for webhooks starts being calculated using the new channel secret. To avoid signature verification failures, the bot owner must update the channel secret on their server, which is used for signature verification. However, if there is a timing mismatch in the update—and such a mismatch is almost unavoidable—verification will fail during that period.
In such cases, having an option to skip signature verification for webhooks would be a convenient way to avoid these issues.