mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-19 19:55:16 +00:00
Attempt to fix slack signing secret always passing
This commit is contained in:
parent
c8115f1386
commit
e8718e7bfb
1 changed files with 3 additions and 4 deletions
|
|
@ -50,7 +50,7 @@ class SlackController < ApplicationController
|
|||
|
||||
def verify_slack_request
|
||||
timestamp = request.headers["X-Slack-Request-Timestamp"]
|
||||
signature = request.headers["X-Slack-Signature"]
|
||||
received_signature = request.headers["X-Slack-Signature"]
|
||||
|
||||
# Skip verification in development
|
||||
return true if Rails.env.development?
|
||||
|
|
@ -61,15 +61,14 @@ class SlackController < ApplicationController
|
|||
|
||||
sig_basestring = "v0:#{timestamp}:#{request.raw_post}"
|
||||
|
||||
# Try both signing secrets
|
||||
signature = "v0=" + OpenSSL::HMAC.hexdigest(
|
||||
computed_signature = "v0=" + OpenSSL::HMAC.hexdigest(
|
||||
"SHA256",
|
||||
signing_secret,
|
||||
sig_basestring
|
||||
)
|
||||
|
||||
# Check if the request matches signature
|
||||
unless ActiveSupport::SecurityUtils.secure_compare(signature, signature)
|
||||
unless ActiveSupport::SecurityUtils.secure_compare(received_signature, computed_signature)
|
||||
head :unauthorized
|
||||
nil
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue