-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conversation
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.
69632d9
to
ed50a10
Compare
# Copyright (C) 2010-2019 Sutou Kouhei <[email protected]> | ||
# Copyright (C) 2015 Kenji Okimoto <[email protected]> |
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.
commit-email/webhook-mailer リポジトリのコードをそのまま使わせていただいたので、
ライセンスヘッダーをそのまま持ってきています 🙏🏾
https://gitlab.com/commit-email/webhook-mailer/-/blob/master/lib/webhook-mailer/response.rb?ref_type=heads
[200, {}, ["Hello deployer"]] | ||
request = Rack::Request.new(env) | ||
response = Response.new | ||
process(request, response) or response.finish |
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.
必ずfinish
するならこれでよくない?
process(request, response) or response.finish | |
process(request, response) | |
response.finish |
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.
fix: 0e38ab5 現状は必要ないのでシンプルな方に寄せておこうと思います。
return nil | ||
end | ||
|
||
unless verify_signature(request) |
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.
unless verify_signature(request) | |
unless valid_signature?(request) |
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.
fix: ae7cdd0 boolを返すので確かにこちらのほうがわかりやすいですね。
signature = 'sha256=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), | ||
ENV['SECRET_TOKEN'], | ||
request.body.read) |
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.
変数をもう一つ追加したほうが読みやすいんじゃないかな。
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}" |
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.
fix: 53df47d
ここまで頂いたレビューコメントの対応をおこないました。 |
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.