cutelyst  4.4.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 
11 namespace Cutelyst {
12 
13 class Context;
14 class AuthenticationStore;
15 class AuthenticationCredential;
16 
29 class CUTELYST_PLUGIN_AUTHENTICATION_EXPORT AuthenticationRealm : public Component
30 {
31  Q_OBJECT
32 public:
36  static char *defaultRealm;
37 
42  explicit AuthenticationRealm(std::shared_ptr<AuthenticationStore> store,
43  std::shared_ptr<AuthenticationCredential> credential,
44  const QString &name = QLatin1String(defaultRealm),
45  QObject *parent = nullptr);
46  ~AuthenticationRealm() override;
47 
51  [[nodiscard]] std::shared_ptr<AuthenticationStore> store() const noexcept;
52 
56  [[nodiscard]] std::shared_ptr<AuthenticationCredential> credential() const noexcept;
57 
61  [[nodiscard]] virtual AuthenticationUser findUser(Context *c, const ParamsMultiMap &userinfo);
62 
67  [[nodiscard]] virtual AuthenticationUser authenticate(Context *c,
68  const ParamsMultiMap &authinfo);
69 
73  void removePersistedUser(Context *c);
74 
78  AuthenticationUser persistUser(Context *c, const AuthenticationUser &user);
79 
83  [[nodiscard]] AuthenticationUser restoreUser(Context *c, const QVariant &frozenUser);
84 
88  [[nodiscard]] QVariant userIsRestorable(Context *c);
89 
90 private:
91  friend class Authentication;
92  friend class AuthenticationPrivate;
93 
94  std::shared_ptr<AuthenticationStore> m_store;
95  std::shared_ptr<AuthenticationCredential> m_credential;
96 };
97 
98 } // namespace Cutelyst
99 
100 #endif // AUTHENTICATIONREALM_H
Abstract class to validate authentication credentials like user name and password.
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.
Main class to manage user authentication.
The Cutelyst Component base class.
Definition: component.h:30
The Cutelyst Context.
Definition: context.h:42
The Cutelyst namespace holds all public Cutelyst API.