Class: Rack::GithubWebhooks::Signature
- Inherits:
-
Object
- Object
- Rack::GithubWebhooks::Signature
- Defined in:
- lib/rack/github_webhooks.rb
Constant Summary collapse
- HMAC_DIGEST =
OpenSSL::Digest.new('sha256')
Instance Method Summary collapse
-
#initialize(secret, hub_signature, payload_body) ⇒ Signature
constructor
A new instance of Signature.
- #valid? ⇒ Boolean
Constructor Details
#initialize(secret, hub_signature, payload_body) ⇒ Signature
10 11 12 13 14 |
# File 'lib/rack/github_webhooks.rb', line 10 def initialize(secret, hub_signature, payload_body) @secret = secret @hub_signature = hub_signature @signature = "sha256=#{OpenSSL::HMAC.hexdigest(HMAC_DIGEST, secret, payload_body)}" end |
Instance Method Details
#valid? ⇒ Boolean
16 17 18 19 20 |
# File 'lib/rack/github_webhooks.rb', line 16 def valid? return true unless @secret return false unless @hub_signature Rack::Utils.secure_compare(@signature, @hub_signature) end |