cutelyst 5.0.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/Plugins/authentication_export.h>
10#include <Cutelyst/paramsmultimap.h>
11#include <Cutelyst/plugin.h>
12
13namespace Cutelyst {
14
15class Context;
18
33class CUTELYST_PLUGIN_AUTHENTICATION_EXPORT AuthenticationCredential : public QObject
34{
36public:
40 explicit AuthenticationCredential(QObject *parent = nullptr);
41
46
54 virtual AuthenticationUser
55 authenticate(Context *c, AuthenticationRealm *realm, const ParamsMultiMap &authinfo) = 0;
56};
57
58class AuthenticationPrivate;
59
75class CUTELYST_PLUGIN_AUTHENTICATION_EXPORT Authentication : public Plugin
76{
78 Q_DECLARE_PRIVATE(Authentication)
79public:
84
89
93 virtual ~Authentication() override;
94
98 void addRealm(std::shared_ptr<AuthenticationRealm> realm);
99
103 void addRealm(std::shared_ptr<AuthenticationStore> store,
104 std::shared_ptr<AuthenticationCredential> credential,
106
110 [[nodiscard]] std::shared_ptr<AuthenticationRealm> realm(QStringView name = defaultRealm) const;
111
115 [[nodiscard]] static bool
117
121 [[nodiscard]] inline static bool authenticate(Context *c, QStringView realm = defaultRealm);
122
127 [[nodiscard]] static AuthenticationUser
129
134 [[nodiscard]] static AuthenticationUser user(Context *c);
135
144 [[nodiscard]] static bool userExists(Context *c);
145
150 [[nodiscard]] static bool userInRealm(Context *c, QStringView realmName = defaultRealm);
151
156 static void logout(Context *c);
157
158protected:
159 virtual bool setup(Application *app) override;
160
161 AuthenticationPrivate *d_ptr;
162};
163
168
169} // namespace Cutelyst
170
171#endif // AUTHENTICATION_H
The Cutelyst application.
Definition application.h:66
virtual AuthenticationUser authenticate(Context *c, AuthenticationRealm *realm, const ParamsMultiMap &authinfo)=0
AuthenticationCredential(QObject *parent=nullptr)
Combines user store and credential validation into a named realm.
Abstract class to retrieve user data from a store.
Container for user data retrieved from an AuthenticationStore.
void addRealm(std::shared_ptr< AuthenticationRealm > realm)
static bool userExists(Context *c)
static bool authenticate(Context *c, const ParamsMultiMap &userinfo, QStringView realm=defaultRealm)
virtual bool setup(Application *app) override
static void logout(Context *c)
std::shared_ptr< AuthenticationRealm > realm(QStringView name=defaultRealm) const
Authentication(Application *parent)
static AuthenticationUser user(Context *c)
static const QStringView defaultRealm
static bool userInRealm(Context *c, QStringView realmName=defaultRealm)
static AuthenticationUser findUser(Context *c, const ParamsMultiMap &userinfo, QStringView realm=defaultRealm)
The Cutelyst Context.
Definition context.h:42
Plugin(Application *parent)
Definition plugin.cpp:12
QMultiMap< QString, QString > ParamsMultiMap
The Cutelyst namespace holds all public Cutelyst API.
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const