Skip to content

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

habara-k
Copy link
Contributor

Changes

  • Allow skipping signature verification for webhooks

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.

@habara-k habara-k requested a review from a team May 26, 2025 01:11
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.
Copy link
Contributor

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.

@habara-k habara-k requested a review from Yang-33 May 26, 2025 01:48
Comment on lines 55 to 63
new MockSkipSignatureVerificationSupplier();

static class MockSkipSignatureVerificationSupplier
implements SkipSignatureVerificationSupplier {
@Override
public boolean getAsBoolean() {
return false;
}
}
Copy link
Contributor

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,
Copy link
Contributor

Choose a reason for hiding this comment

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

oops, yes

@habara-k habara-k requested a review from Yang-33 June 3, 2025 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants