cutelyst  4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
authenticationrealm.h
1 /*
2  * SPDX-FileCopyrightText: (C) 2013-2022 Daniel Nicoletti <dantti12@gmail.com>
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #ifndef AUTHENTICATIONREALM_H
6 #define AUTHENTICATIONREALM_H
7 
8 #include <Cutelyst/Plugins/Authentication/authenticationuser.h>
9 #include <Cutelyst/component.h>
10 #include <Cutelyst/cutelyst_global.h>
11 
12 namespace Cutelyst {
13 
14 class Context;
15 class AuthenticationStore;
16 class AuthenticationCredential;
17 
30 class CUTELYST_PLUGIN_AUTHENTICATION_EXPORT AuthenticationRealm : public Component
31 {
32  Q_OBJECT
33 public:
37  static char *defaultRealm;
38 
43  explicit AuthenticationRealm(std::shared_ptr<AuthenticationStore> store,
44  std::shared_ptr<AuthenticationCredential> credential,
45  const QString &name = QLatin1String(defaultRealm),
46  QObject *parent = nullptr);
47  ~AuthenticationRealm() override;
48 
52  [[nodiscard]] std::shared_ptr<AuthenticationStore> store() const noexcept;
53 
57  [[nodiscard]] std::shared_ptr<AuthenticationCredential> credential() const noexcept;
58 
62  [[nodiscard]] virtual AuthenticationUser findUser(Context *c, const ParamsMultiMap &userinfo);
63 
68  [[nodiscard]] virtual AuthenticationUser authenticate(Context *c,
69  const ParamsMultiMap &authinfo);
70 
74  void removePersistedUser(Context *c);
75 
79  AuthenticationUser persistUser(Context *c, const AuthenticationUser &user);
80 
84  [[nodiscard]] AuthenticationUser restoreUser(Context *c, const QVariant &frozenUser);
85 
89  [[nodiscard]] QVariant userIsRestorable(Context *c);
90 
91 private:
92  friend class Authentication;
93  friend class AuthenticationPrivate;
94 
95  std::shared_ptr<AuthenticationStore> m_store;
96  std::shared_ptr<AuthenticationCredential> m_credential;
97 };
98 
99 } // namespace Cutelyst
100 
101 #endif // AUTHENTICATIONREALM_H
Main class to manage user authentication.
STL namespace.
Abstract class to validate authentication credentials like user name and password.
Combines user store and credential validation into a named realm.
The Cutelyst Context.
Definition: context.h:42
Abstract class to retrieve user data from a store.
The Cutelyst namespace holds all public Cutelyst API.
Container for user data retrieved from an AuthenticationStore.