Skip to content

Commit b46868b

Browse files
committed
Refactor timestamp validator usage: move to base class and remove from HMAC
1 parent 4b0c058 commit b46868b

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

lib/hooks/plugins/auth/base.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require_relative "../../core/log"
55
require_relative "../../core/global_components"
66
require_relative "../../core/component_access"
7+
require_relative "timestamp_validator"
78

89
module Hooks
910
module Plugins
@@ -53,6 +54,13 @@ def self.fetch_secret(config, secret_env_key_name: :secret_env_key)
5354
return secret.strip
5455
end
5556

57+
# Get timestamp validator instance
58+
#
59+
# @return [TimestampValidator] Singleton timestamp validator instance
60+
def self.timestamp_validator
61+
@timestamp_validator ||= TimestampValidator.new
62+
end
63+
5664
# Find a header value by name with case-insensitive matching
5765
#
5866
# @param headers [Hash] HTTP headers from the request

lib/hooks/plugins/auth/hmac.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require "openssl"
44
require "time"
55
require_relative "base"
6-
require_relative "timestamp_validator"
76

87
module Hooks
98
module Plugins
@@ -271,14 +270,6 @@ def self.valid_timestamp?(headers, config)
271270
timestamp_validator.valid?(timestamp_value, tolerance)
272271
end
273272

274-
# Get timestamp validator instance
275-
#
276-
# @return [TimestampValidator] Singleton timestamp validator instance
277-
# @api private
278-
def self.timestamp_validator
279-
@timestamp_validator ||= TimestampValidator.new
280-
end
281-
282273
# Compute HMAC signature based on configuration requirements
283274
#
284275
# Generates the expected HMAC signature for the given payload using the

0 commit comments

Comments
 (0)