Skip to content
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

release: authorize webhook request using webhook secret token #46

Merged
merged 6 commits into from
Dec 12, 2024

Conversation

otegami
Copy link
Contributor

@otegami otegami commented Dec 12, 2024

GitHub: GH-43

In this PR, we set up the authorization flow for webhook requests.
At the following PRs, we will implement the logic of deployments.

GitHub: groongaGH-43

In this PR, we set up the authorization flow for webhook requests.
At the following PRs, we will implement the logic of deployments.
@otegami otegami force-pushed the release-verify-signature branch from 69632d9 to ed50a10 Compare December 12, 2024 02:45
Comment on lines +1 to +2
# Copyright (C) 2010-2019 Sutou Kouhei <[email protected]>
# Copyright (C) 2015 Kenji Okimoto <[email protected]>
Copy link
Contributor Author

@otegami otegami Dec 12, 2024

Choose a reason for hiding this comment

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

commit-email/webhook-mailer リポジトリのコードをそのまま使わせていただいたので、
ライセンスヘッダーをそのまま持ってきています 🙏🏾
https://gitlab.com/commit-email/webhook-mailer/-/blob/master/lib/webhook-mailer/response.rb?ref_type=heads

@otegami otegami marked this pull request as ready for review December 12, 2024 02:48
[200, {}, ["Hello deployer"]]
request = Rack::Request.new(env)
response = Response.new
process(request, response) or response.finish
Copy link
Member

Choose a reason for hiding this comment

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

必ずfinishするならこれでよくない?

Suggested change
process(request, response) or response.finish
process(request, response)
response.finish

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix: 0e38ab5 現状は必要ないのでシンプルな方に寄せておこうと思います。

return nil
end

unless verify_signature(request)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
unless verify_signature(request)
unless valid_signature?(request)

Copy link
Contributor Author

@otegami otegami Dec 12, 2024

Choose a reason for hiding this comment

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

fix: ae7cdd0 boolを返すので確かにこちらのほうがわかりやすいですね。

Comment on lines 45 to 47
signature = 'sha256=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'),
ENV['SECRET_TOKEN'],
request.body.read)
Copy link
Member

Choose a reason for hiding this comment

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

変数をもう一つ追加したほうが読みやすいんじゃないかな。

Suggested change
signature = 'sha256=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'),
ENV['SECRET_TOKEN'],
request.body.read)
hmac_sha256 = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'),
ENV['SECRET_TOKEN'],
request.body.read)
signature = "sha256=#{hmac}"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix: 53df47d

@otegami
Copy link
Contributor Author

otegami commented Dec 12, 2024

ここまで頂いたレビューコメントの対応をおこないました。

@kou kou merged commit 0c7cc5b into groonga:main Dec 12, 2024
@otegami otegami deleted the release-verify-signature branch December 12, 2024 04:14
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