instance method message_verifier

Ruby on Rails 8.0.4

Since v4.1.16

Available in: v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

message_verifier(verifier_name)

Returns a message verifier object.

This verifier can be used to generate and verify signed messages in the application.

It is recommended not to use the same verifier for different things, so you can get different verifiers passing the verifier_name argument.

For instance, ActiveStorage::Blob.signed_id_verifier is implemented using this feature, which assures that the IDs strings haven’t been tampered with and are safe to use in a finder.

See the ActiveSupport::MessageVerifier documentation for more information.

Parameters

  • verifier_name - the name of the message verifier.

Examples

message = Rails.application.message_verifier('my_purpose').generate('data to sign against tampering')
Rails.application.message_verifier('my_purpose').verify(message)
# => 'data to sign against tampering'

Parameters

verifier_name req
Source
# File railties/lib/rails/application.rb, line 240
    def message_verifier(verifier_name)
      message_verifiers[verifier_name]
    end

Defined in railties/lib/rails/application.rb line 240 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Rails::Application

Type at least 2 characters to search.

↑↓ navigate · open · esc close