class WarpEngine::CI::Gitlab::SignatureVerifier
Checks that a GitLab config request carries the configured webhook secret.
Public Class Methods
# File lib/warp_engine/ci/gitlab/signature_verifier.rb, line 8 def initialize(request, webhook_secret:) @request = request @webhook_secret = webhook_secret end
- request
-
the incoming ActionDispatch::Request
- webhook_secret
-
the expected value of the
X-Gitlab-Tokenheader
Public Instance Methods
Source
# File lib/warp_engine/ci/gitlab/signature_verifier.rb, line 15 def valid? token = @request.headers["X-Gitlab-Token"] return false if token.blank? || @webhook_secret.blank? ActiveSupport::SecurityUtils.secure_compare(token, @webhook_secret) end
Returns true when the X-Gitlab-Token header equals the webhook secret (constant-time comparison); false when either is blank or they differ.