class ActiveSupport::MessageVerifier

Defined in:

active_support/message_verifier.cr

Constant Summary

SEPARATOR = "--"

Separator placed between the encoded payload and its digest.

Constructors

Instance Method Summary

Constructor Detail

def self.new(secret : Slice(UInt8), algorithm : OpenSSL::Algorithm = OpenSSL::Algorithm::SHA256, url_safe : Bool = true) #

Instance Method Detail

def create_message(value, purpose : String = "", expires_at : Time | Nil = nil) #

https://github.com/rails/rails/blob/main/activesupport/lib/active_support/message_verifier.rb#L308


def digest_matches_data?(digest : String, encoded : String) : Bool #

https://github.com/rails/rails/blob/v8.1.3/activesupport/lib/active_support/message_verifier.rb


def encoded(data, url_safe = @url_safe) #

https://github.com/rails/rails/blob/e7c0592cd2944caf9d70c3fabe9ec6877f1f951b/activesupport/lib/active_support/messages/codec.rb#L25


def generate(value, purpose : String = "", expires_at : Time | Nil = nil) #

def generate_digest(encoded : String) #

https://github.com/rails/rails/blob/e7c0592cd2944caf9d70c3fabe9ec6877f1f951b/activesupport/lib/active_support/message_verifier.rb#L343


def serialize_with_metadata(value, purpose : String = "", expires_at : Time | Nil = nil) #

def sign_encoded(encoded) #

https://github.com/rails/rails/blob/main/activesupport/lib/active_support/message_verifier.rb#L321C7-L324C10


def valid_message?(message : String | Nil) : Bool #

Returns true if the digest of the passed message matches its payload.

This checks the signature only: the purpose and the expiry are not looked at.


def verified(message : String | Nil, purpose : String = "") : JSON::Any | Nil #

Returns the data carried by a signed message, or nil when the message cannot be verified.

A message is rejected when its digest does not match, when its purpose differs from the expected one, or when it carries an expiry that has passed. https://github.com/rails/rails/blob/v8.1.3/activesupport/lib/active_support/message_verifier.rb


def verified?(message : String | Nil, purpose : String = "") : JSON::Any | Nil #

Alias of #verified.


def verify(message : String | Nil, purpose : String = "") : JSON::Any #

Returns the data carried by a signed message, raising InvalidSignature when it cannot be verified.