2022-06-26 19:43:31 +02:00
|
|
|
#ifndef CSRF_TOKEN_MIDDLEWARE_H
|
|
|
|
#define CSRF_TOKEN_MIDDLEWARE_H
|
2022-06-25 01:55:54 +02:00
|
|
|
|
2022-06-26 19:43:31 +02:00
|
|
|
#include "web_server_middleware.h"
|
2022-06-25 01:55:54 +02:00
|
|
|
|
2022-06-26 19:43:31 +02:00
|
|
|
#include "core/ustring.h"
|
|
|
|
#include "core/vector.h"
|
2022-06-25 01:55:54 +02:00
|
|
|
|
2022-06-26 19:43:31 +02:00
|
|
|
class WebServerRequest;
|
2022-06-25 01:55:54 +02:00
|
|
|
|
2022-06-26 15:00:25 +02:00
|
|
|
class CSRFTokenWebServerMiddleware : public WebServerMiddleware {
|
2022-06-26 19:43:31 +02:00
|
|
|
GDCLASS(CSRFTokenWebServerMiddleware, WebServerMiddleware);
|
2022-06-25 01:55:54 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
//returnring true means handled, false means continue
|
2022-06-26 19:43:31 +02:00
|
|
|
bool _on_before_handle_request_main(Ref<WebServerRequest> request);
|
2022-06-25 01:55:54 +02:00
|
|
|
|
2022-06-26 19:43:31 +02:00
|
|
|
bool shold_ignore(Ref<WebServerRequest> request);
|
2022-06-25 01:55:54 +02:00
|
|
|
|
|
|
|
virtual String create_token();
|
|
|
|
|
2022-06-26 15:00:25 +02:00
|
|
|
CSRFTokenWebServerMiddleware();
|
|
|
|
~CSRFTokenWebServerMiddleware();
|
2022-06-25 01:55:54 +02:00
|
|
|
|
|
|
|
Vector<String> ignored_urls;
|
2022-06-26 19:43:31 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2022-06-25 01:55:54 +02:00
|
|
|
};
|
|
|
|
|
2022-06-26 15:00:25 +02:00
|
|
|
#endif
|