10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/mach/validation/request_validator.rb', line 10
def valid?(rack_request)
hmac_request = Mach::Request.new(rack_request.env)
raise Mach::Error::RequestNotMacAuthenticatedError unless hmac_request.mac_authorization?
valid = hmac_request.mac_id &&
Mach::Validation::TimestampValidator.valid?(hmac_request) &&
Mach::Validation::NonceValidator.valid?(hmac_request) &&
Mach::Validation::SignatureValidator.valid?(hmac_request)
Nonce.persist(hmac_request.mac_id, hmac_request.mac_nonce, hmac_request.mac_timestamp.to_i) if valid
logger.warn("WARNING: Request Validation failed") unless valid
if !valid && Mach.configuration.ignore_validation_failure
logger.warn("WARNING: Ignoring Request Validation failure, Are you sure you want to do it?")
return true
end
valid
end
|