Represents a CSRFToken. You can use request extension to get it.
If you enable CSRF protection, the extension will guarantee the CSRF token is either
Freshly initialized and cookie is set
Or cookie seen, cookie value is valid, so we reuse the cookie
Generate a CSRF token in format of xxxx-yyyy
xxxx is the short uuid generated using uuid-short.
yyyy is the hmac signature of the uuid-short signed with the sign key set previously
(or default 32 char random key if not set)
Enable or disable secure cookie. Default is to disable so it works with HTTP and HTTPS.
Enabling secure cookie will make it only works with HTTPS
Default is disabled
Set the signing key for csrf token.
If not called, CSRF token will be signed by a random 32 char alphanumeric string.
Recommend to set a key with at least 32 characters.
Better to call before your server start. Otherwise some existing CSRF token will become invalid.
This is a verification function for sign_message. You can give input text, and a signature.
The code will in computed signature to match the signature and return true if signature maches.