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('sha1')
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
Returns a new instance of Signature.
10 11 12 13 14 15 |
# File 'lib/rack/github_webhooks.rb', line 10 def initialize(secret, hub_signature, payload_body) @secret = secret @hub_signature = hub_signature @signature = 'sha1=' + OpenSSL::HMAC.hexdigest(HMAC_DIGEST, secret, payload_body) end |
Instance Method Details
#valid? ⇒ Boolean
17 18 19 20 21 |
# File 'lib/rack/github_webhooks.rb', line 17 def valid? return true unless @secret return false unless @hub_signature Rack::Utils.secure_compare(@signature, @hub_signature) end |