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-08-17 14:19:55 +02:00
|
|
|
#include "core/string/ustring.h"
|
2022-08-17 13:17:12 +02:00
|
|
|
#include "core/variant/variant.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:
|
2022-06-26 20:54:26 +02:00
|
|
|
PoolStringArray get_ignored_urls();
|
|
|
|
void set_ignored_urls(const PoolStringArray &val);
|
|
|
|
|
2022-06-25 01:55:54 +02:00
|
|
|
//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
|
|
|
|
2022-06-26 20:54:26 +02:00
|
|
|
PoolStringArray 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
|