Skip to content

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.

Related PRs

Comment on lines 41 to 43
cb, err := webhook.ParseRequestWithOption(channelSecret, req, &webhook.ParseOption{
SkipSignatureValidation: func() bool { return true },
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Normally, webhook signature verification "should" be done. Providing examples that skip it might lead to uninformed users using this, so please do not offer it as an example.

func ParseRequest(channelSecret string, r *http.Request) (*CallbackRequest, error) {
return ParseRequestWithOption(channelSecret, r, nil)
}

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 do these like the Java SDK?

  • Write comments explaining why users need this option in ParseRequestWithOption /when it should be used.
  • Indicate to ParseRequest users that there is a version where the option can be utilized.
  • Write sufficient tests.

@habara-k habara-k force-pushed the allow-to-skip-signature-verification branch from 4fe9ebf to fa77c70 Compare July 4, 2025 07:07
@habara-k habara-k requested a review from Yang-33 July 4, 2025 07:13
Comment on lines +18 to +26
type ParseOption struct {
// SkipSignatureValidation is a function that determines whether to skip
// webhook signature verification.
//
// If the function returns true, the signature verification step is skipped.
// This can be useful in scenarios such as when you're in the process of updating
// the channel secret and need to temporarily bypass verification to avoid disruptions.
SkipSignatureValidation func() bool
}
Copy link
Contributor

Choose a reason for hiding this comment

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

When adding another option later, would it always require a major version upgrade? I think it's better to ensure the code works seamlessly with users' existing builds, even when adding another option.

Copy link
Contributor Author

@habara-k habara-k Jul 25, 2025

Choose a reason for hiding this comment

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

To make sure this change doesn't break existing code that uses the current line-bot-sdk-go, I also added tests for the existing ParseRequest (without options). d12c7df

Copy link
Contributor

Choose a reason for hiding this comment

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

thank you.

Once again: Would adding an option in another change cause any issues in your land(like compile fails)?

type ParseOption struct {
	SkipSignatureValidation func() bool
+      SomethingNew func() bool // Adding this later may cause compile error in your land? or not?
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Confirmed that there is no issues like compile error with the above changes in local.

@habara-k habara-k requested a review from Yang-33 September 18, 2025 02:35
github-merge-queue bot pushed a commit to line/line-bot-sdk-python that referenced this pull request Sep 18, 2025
## 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.

## Related PRs

- line-bot-sdk-java: line/line-bot-sdk-java#1635
- line-bot-sdk-go: line/line-bot-sdk-go#595
@habara-k habara-k requested a review from a team September 19, 2025 02:01
@habara-k habara-k added this pull request to the merge queue Sep 22, 2025
Merged via the queue into line:master with commit 9bcee20 Sep 22, 2025
5 checks passed
@habara-k habara-k deleted the allow-to-skip-signature-verification branch September 22, 2025 05:48
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