cutelyst  3.7.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
csrfprotection.h
1 /*
2  * SPDX-FileCopyrightText: (C) 2017-2022 Matthias Fehring <mf@huessenbergnetz.de>
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef CSRFPROTECTION_H
7 #define CSRFPROTECTION_H
8 
9 #include <Cutelyst/cutelyst_global.h>
10 #include <Cutelyst/Plugin>
11 
12 namespace Cutelyst {
13 
14 class Context;
15 class CSRFProtectionPrivate;
16 
222 class CUTELYST_PLUGIN_CSRFPROTECTION_EXPORT CSRFProtection : public Plugin
223 {
224  Q_OBJECT
225  Q_DECLARE_PRIVATE(CSRFProtection)
226 public:
230  CSRFProtection(Application *parent);
231 
235  virtual ~CSRFProtection() override;
236 
242  void setDefaultDetachTo(const QString &actionNameOrPath);
243 
248  void setFormFieldName(const QString &fieldName);
249 
253  void setErrorMsgStashKey(const QString &keyName);
254 
260  void setIgnoredNamespaces(const QStringList &namespaces);
261 
269  void setUseSessions(bool useSessions);
270 
285  void setCookieHttpOnly(bool httpOnly);
286 
291  void setCookieName(const QString &cookieName);
292 
297  void setHeaderName(const QString &headerName);
298 
305  void setGenericErrorMessage(const QString &message);
306 
312  void setGenericErrorContentTyp(const QString &type);
313 
317  static QByteArray getToken(Context *c);
318 
328  static QString getTokenFormField(Context *c);
329 
336  static bool checkPassed(Context *c);
337 
338 protected:
339  CSRFProtectionPrivate *d_ptr;
340 
341  virtual bool setup(Application *app) override;
342 };
343 
344 }
345 
346 #endif // CSRFPROTECTION_H
The Cutelyst Application.
Definition: application.h:43
Protect input forms against Cross Site Request Forgery (CSRF/XSRF) attacks.
The Cutelyst Context.
Definition: context.h:39
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:8