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 
231 class CUTELYST_PLUGIN_CSRFPROTECTION_EXPORT CSRFProtection : public Plugin
232 {
233  Q_OBJECT
234  Q_DECLARE_PRIVATE(CSRFProtection)
235 public:
239  CSRFProtection(Application *parent);
240 
244  virtual ~CSRFProtection() override;
245 
251  void setDefaultDetachTo(const QString &actionNameOrPath);
252 
257  void setFormFieldName(const QString &fieldName);
258 
262  void setErrorMsgStashKey(const QString &keyName);
263 
269  void setIgnoredNamespaces(const QStringList &namespaces);
270 
278  void setUseSessions(bool useSessions);
279 
294  void setCookieHttpOnly(bool httpOnly);
295 
300  void setCookieName(const QString &cookieName);
301 
306  void setHeaderName(const QString &headerName);
307 
314  void setGenericErrorMessage(const QString &message);
315 
321  void setGenericErrorContentTyp(const QString &type);
322 
326  static QByteArray getToken(Context *c);
327 
337  static QString getTokenFormField(Context *c);
338 
345  static bool checkPassed(Context *c);
346 
347 protected:
348  CSRFProtectionPrivate *d_ptr;
349 
350  virtual bool setup(Application *app) override;
351 };
352 
353 }
354 
355 #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