mirror of
https://github.com/github/rails.git
synced 2026-01-09 14:48:08 -05:00
MessageVerifier#verify raises InvalidSignature if the signature is blank
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
This commit is contained in:
committed by
Jeremy Kemper
parent
b480da5cd6
commit
9212138ad0
@@ -26,6 +26,8 @@ module ActiveSupport
|
||||
end
|
||||
|
||||
def verify(signed_message)
|
||||
raise InvalidSignature if signed_message.blank?
|
||||
|
||||
data, digest = signed_message.split("--")
|
||||
if secure_compare(digest, generate_digest(data))
|
||||
Marshal.load(ActiveSupport::Base64.decode64(data))
|
||||
|
||||
@@ -18,6 +18,11 @@ class MessageVerifierTest < Test::Unit::TestCase
|
||||
assert_equal @data, @verifier.verify(message)
|
||||
end
|
||||
|
||||
def test_missing_signature_raises
|
||||
assert_not_verified(nil)
|
||||
assert_not_verified("")
|
||||
end
|
||||
|
||||
def test_tampered_data_raises
|
||||
data, hash = @verifier.generate(@data).split("--")
|
||||
assert_not_verified("#{data.reverse}--#{hash}")
|
||||
|
||||
Reference in New Issue
Block a user