cutelyst 3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
authentication.h
1/*
2 * SPDX-FileCopyrightText: (C) 2013-2022 Daniel Nicoletti <dantti12@gmail.com>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef AUTHENTICATION_H
6#define AUTHENTICATION_H
7
8#include <Cutelyst/Plugins/Authentication/authenticationuser.h>
9#include <Cutelyst/cutelyst_global.h>
10#include <Cutelyst/paramsmultimap.h>
11#include <Cutelyst/plugin.h>
12
13namespace Cutelyst {
14
15class Context;
18class CUTELYST_PLUGIN_AUTHENTICATION_EXPORT AuthenticationCredential : public QObject
19{
21public:
25 explicit AuthenticationCredential(QObject *parent = nullptr);
27
32 virtual AuthenticationUser
33 authenticate(Context *c, AuthenticationRealm *realm, const ParamsMultiMap &authinfo) = 0;
34};
35
36class AuthenticationPrivate;
37class CUTELYST_PLUGIN_AUTHENTICATION_EXPORT Authentication : public Plugin
38{
40 Q_DECLARE_PRIVATE(Authentication)
41public:
43 static char *defaultRealm;
44
49 virtual ~Authentication() override;
50
56
61 void addRealm(AuthenticationStore *store,
62 AuthenticationCredential *credential,
63 const QString &name = QLatin1String(defaultRealm));
64
69
73 static bool authenticate(Context *c,
74 const ParamsMultiMap &userinfo,
76
80 inline static bool authenticate(Context *c, const QString &realm = QLatin1String(defaultRealm));
81
87 const ParamsMultiMap &userinfo,
89
95
104 static bool userExists(Context *c);
105
110 static bool userInRealm(Context *c, const QString &realmName = QLatin1String(defaultRealm));
111
116 static void logout(Context *c);
117
118protected:
119 virtual bool setup(Application *app) override;
120
121 AuthenticationPrivate *d_ptr;
122};
123
128
129} // namespace Cutelyst
130
131#endif // AUTHENTICATION_H
The Cutelyst Application.
Definition application.h:43
virtual AuthenticationUser authenticate(Context *c, AuthenticationRealm *realm, const ParamsMultiMap &authinfo)=0
Tries to authenticate the authinfo using the give realm.
AuthenticationCredential(QObject *parent=nullptr)
Constructs a new AuthenticationCredential object with the given parent.
void addRealm(AuthenticationRealm *realm)
Adds the realm with name.
static bool userInRealm(Context *c, const QString &realmName=QLatin1String(defaultRealm))
static bool userExists(Context *c)
virtual bool setup(Application *app) override
static void logout(Context *c)
static bool authenticate(Context *c, const ParamsMultiMap &userinfo, const QString &realm=QLatin1String(defaultRealm))
static char * defaultRealm
default realm name
Authentication(Application *parent)
Constructs a new Authentication object with the given parent.
static AuthenticationUser user(Context *c)
static AuthenticationUser findUser(Context *c, const ParamsMultiMap &userinfo, const QString &realm=QLatin1String(defaultRealm))
Tries to find the user with userinfo using the realm, returning a non null AuthenticationUser on succ...
AuthenticationRealm * realm(const QString &name=QLatin1String(defaultRealm)) const
Returns an AuthenticationRealm object that was registered with name.
The Cutelyst Context.
Definition context.h:39
Plugin(Application *parent)
Definition plugin.cpp:12
The Cutelyst namespace holds all public Cutelyst API.
Definition Mainpage.dox:8
QMultiMap< QString, QString > ParamsMultiMap
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const