instance method
csrf_token_hmac
Ruby on Rails edge
Since v5.2.8.1 Private — implementation detail, not part of the public APISignature
csrf_token_hmac(session, identifier)
No documentation comment.
Parameters
-
sessionreq -
identifierreq
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