Cross-Site Request Forgery (CSRF) protection middleware.
More...
#include <Csrf.hpp>
Cross-Site Request Forgery (CSRF) protection middleware.
◆ Csrf()
| middleware::Csrf::Csrf |
( |
const std::string & |
cookie_name = "csrf_token", |
|
|
const std::string & |
header_name = "X-CSRF-Token" |
|
) |
| |
Constructs a new Csrf middleware instance.
- Parameters
-
| cookie_name | The name of the cookie to store the CSRF token. |
| header_name | The name of the header expected in requests. |
◆ generate_random_token()
| std::string middleware::Csrf::generate_random_token |
( |
| ) |
|
|
static |
Generates a random CSRF token.
- Returns
- std::string The generated token.
◆ operator()()
Middleware execution operator.
- Parameters
-
| req | The HTTP request. |
| writer | The HTTP response writer. |
- Returns
- true If the request should continue to the next handler.
-
false If the request should be blocked.
The documentation for this class was generated from the following files: