instance method csrf_token_hmac

Ruby on Rails edge

Since v5.2.8.1 Private — implementation detail, not part of the public API

Available in: v5.2.8.1 v6.0.6.1 v6.1.7.10 v7.0.10 v7.1.6 v7.2.4 v8.0.5.1 v8.1.4 edge

Signature

csrf_token_hmac(session, identifier)

No documentation comment.

Parameters

session req
identifier req
Source
# File actionpack/lib/action_controller/metal/request_forgery_protection.rb, line 836
      def csrf_token_hmac(session, identifier) # :doc:
        key = real_csrf_token(session)

        # Keyed once per real token, then copied for each identifier: setting
        # up the key costs more than the digest, and a page computes one HMAC
        # per form it renders.
        keyed_with, hmac = @_csrf_token_hmac
        unless keyed_with.equal?(key)
          hmac = OpenSSL::HMAC.new(key, "SHA256")
          @_csrf_token_hmac = [key, hmac]
        end

        hmac.dup.update(identifier).digest
      end

Defined in actionpack/lib/action_controller/metal/request_forgery_protection.rb line 836 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionController::RequestForgeryProtection

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close