class Bezel::Plug::CSRF

include Bezel::Plug

Protects a browser pipeline against cross-site request forgery (after Plug::Session):

GET, HEAD and OPTIONS are not checked: they must not change anything.

src/plug/csrf.qz:27

Constants

KEY: String

The session key of the token.

src/plug/csrf.qz:31

UNSAFE: Array[String]

The methods that need a token.

src/plug/csrf.qz:34

Class methods

def self.new -> Bezel::Plug::CSRF

The plug.

src/plug/csrf.qz:37

def self.new_secret -> String

A new secret: 32 random bytes, URL-safe Base64 (what the session keeps).

src/plug/csrf.qz:61

def self.mask(secret: Bytes) -> String

secret masked with a fresh pad: the pad and the secret XORed with it, in URL-safe Base64.

src/plug/csrf.qz:65

def self.valid?(secret: Bytes, given: String) -> Bool

Whether given, a masked token, unmasks to secret.

src/plug/csrf.qz:72

Methods

def call(conn: Bezel::Conn) -> Bezel::Conn

The connection changed by this plug.

from Bezel::Plug

src/plug/csrf.qz:39