Grip::Middleware::CrossSiteRequestForgery
Inherits HTTP::Handler < Reference < Object
Constants
COOKIE_KEY = "csrf_token"
HEADER_KEY = "X-CSRF-Token"
PARAM_KEY = "_csrf"
TOKEN_LENGTH = 32
Constructors
Class methods
Returns the raw token from a valid signed cookie, or nil
XORs the raw token with a random one-time pad (pad + ciphertext), mitigating BREACH
Meta tag so JavaScript can read the token and send it as a header
secret
Sourcesecure?
SourceMasked token, different on every call; safe to embed in HTML
Reverses mask by XORing the ciphertext with the pad that prefixes it
Instance methods
call(context : HTTP::Server::Context)
Rejects unsafe requests whose submitted token doesn't match the cookie token