Class: Hooks::Plugins::Auth::TimestampValidator Private
- Inherits:
-
Object
- Object
- Hooks::Plugins::Auth::TimestampValidator
- Defined in:
- lib/hooks/plugins/auth/timestamp_validator.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Validates and parses timestamps for webhook authentication
This class provides secure timestamp validation supporting both ISO 8601 UTC format and Unix timestamp format. It includes strict validation to prevent various injection attacks.
Instance Method Summary collapse
-
#parse(timestamp_value) ⇒ Integer?
private
Parse timestamp value supporting both ISO 8601 UTC and Unix formats.
-
#valid?(timestamp_value, tolerance = 300) ⇒ Boolean
private
Validate timestamp against current time with tolerance.
Instance Method Details
#parse(timestamp_value) ⇒ Integer?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Security: Strict validation prevents various injection attacks
Parse timestamp value supporting both ISO 8601 UTC and Unix formats
41 42 43 44 45 |
# File 'lib/hooks/plugins/auth/timestamp_validator.rb', line 41 def parse() return nil if invalid_characters?() () || () end |
#valid?(timestamp_value, tolerance = 300) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Validate timestamp against current time with tolerance
26 27 28 29 30 31 32 33 34 |
# File 'lib/hooks/plugins/auth/timestamp_validator.rb', line 26 def valid?(, tolerance = 300) return false if .nil? || .strip.empty? = parse(.strip) return false unless .is_a?(Integer) now = Time.now.utc.to_i (now - ).abs <= tolerance end |