|
cwist
Modern C web framework with libttak runtime
|
CSRF protection via double-submit cookie pattern. More...


Go to the source code of this file.
Functions | |
| cwist_middleware_func | cwist_mw_csrf (cwist_app *app) |
| CSRF middleware factory. | |
| const char * | cwist_csrf_token (cwist_http_request *req) |
| Get the CSRF token for the current request. | |
CSRF protection via double-submit cookie pattern.
Definition in file csrf.h.
| const char * cwist_csrf_token | ( | cwist_http_request * | req | ) |
Get the CSRF token for the current request.
Useful for rendering forms or meta tags. Returns NULL if the middleware has not yet populated the token.
| req | Current request. |
Get the CSRF token for the current request.
| req | Request to query. |
req is NULL or no token has been set. The returned pointer is owned by the request. Definition at line 240 of file csrf.c.
References cap, and cwist_http_request::csrf_token.
| cwist_middleware_func cwist_mw_csrf | ( | cwist_app * | app | ) |
CSRF middleware factory.
On safe requests (GET/HEAD/OPTIONS) a csrf_token cookie is issued if missing. On unsafe requests the X-CSRF-Token header, _csrf form field, or URL-encoded _csrf / csrf_token form field must match the cookie value. Query-string tokens are not accepted because URLs leak easily.
| app | Application context. |
CSRF middleware factory.
| app | Application instance; unused. |
Definition at line 230 of file csrf.c.
References cap.