cutelyst  3.9.1
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/Plugin>
10 #include <Cutelyst/cutelyst_global.h>
11 
12 namespace Cutelyst {
13 
14 class Context;
15 class CSRFProtectionPrivate;
16 
247 class CUTELYST_PLUGIN_CSRFPROTECTION_EXPORT CSRFProtection : public Plugin
248 {
249  Q_OBJECT
250  Q_DECLARE_PRIVATE(CSRFProtection)
251 public:
255  CSRFProtection(Application *parent);
256 
260  virtual ~CSRFProtection() override;
261 
268  void setDefaultDetachTo(const QString &actionNameOrPath);
269 
274  void setFormFieldName(const QString &fieldName);
275 
280  void setErrorMsgStashKey(const QString &keyName);
281 
287  void setIgnoredNamespaces(const QStringList &namespaces);
288 
296  void setUseSessions(bool useSessions);
297 
314  void setCookieHttpOnly(bool httpOnly);
315 
321  void setCookieName(const QString &cookieName);
322 
327  void setHeaderName(const QString &headerName);
328 
335  void setGenericErrorMessage(const QString &message);
336 
342  void setGenericErrorContentTyp(const QString &type);
343 
347  static QByteArray getToken(Context *c);
348 
360  static QString getTokenFormField(Context *c);
361 
369  static bool checkPassed(Context *c);
370 
371 protected:
372  CSRFProtectionPrivate *d_ptr;
373 
374  virtual bool setup(Application *app) override;
375 };
376 
377 } // namespace Cutelyst
378 
379 #endif // CSRFPROTECTION_H
The Cutelyst Context.
Definition: context.h:38
Protect input forms against Cross Site Request Forgery (CSRF/XSRF) attacks.
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
The Cutelyst Application.
Definition: application.h:42