5 #include "authenticationrealm.h" 7 #include "authenticationstore.h" 11 #include <Cutelyst/Plugins/Session/session.h> 15 Q_LOGGING_CATEGORY(C_AUTH_REALM,
"cutelyst.plugin.authentication.realm", QtWarningMsg)
17 #define SESSION_AUTHENTICATION_USER "__authentication_user" 18 #define SESSION_AUTHENTICATION_USER_REALM "__authentication_user_realm" // in authentication.cpp 26 , m_credential(credential)
34 AuthenticationRealm::~AuthenticationRealm()
77 {QStringLiteral(SESSION_AUTHENTICATION_USER),
78 QStringLiteral(SESSION_AUTHENTICATION_USER_REALM)});
93 if (_frozenUser.
isNull()) {
97 if (_frozenUser.
isNull()) {
107 qCWarning(C_AUTH_REALM) <<
"Store claimed to have a restorable user, but restoration " 108 "failed. Did you change the user's id_field?";
118 return Session::value(c, QStringLiteral(SESSION_AUTHENTICATION_USER));
121 #include "moc_authenticationrealm.cpp" void setName(const QString &name)
AuthenticationUser restoreUser(Context *c, const QVariant &frozenUser)
Retrieves the user from the store.
virtual AuthenticationUser findUser(Context *c, const ParamsMultiMap &userinfo)=0
virtual QVariant forSession(Context *c, const AuthenticationUser &user)
virtual AuthenticationUser findUser(Context *c, const ParamsMultiMap &userinfo)
Tries to find the user with authinfo returning a non null AuthenticationUser on success.
AuthenticationUser persistUser(Context *c, const AuthenticationUser &user)
Stores the user on the session.
bool isNull() const
Returns true if the object is null.
virtual AuthenticationUser autoUpdateUser(Context *c, const ParamsMultiMap &userinfo) const
virtual AuthenticationUser authenticate(Context *c, const ParamsMultiMap &authinfo)
Tries to authenticate the user with authinfo returning a non null AuthenticationUser on success...
virtual bool canAutoUpdateUser() const
virtual bool canAutoCreateUser() const
The Cutelyst Component base class.
QVariant userIsRestorable(Context *c)
Checks if user can be retrieved.
AuthenticationCredential * credential() const
Returns the authentication credential object.
bool isNull() const const
QString objectName() const const
void setObjectName(QAnyStringView name)
static void setValue(Context *c, const QString &key, const QVariant &value)
The Cutelyst namespace holds all public Cutelyst API.
void setParent(QObject *parent)
virtual AuthenticationUser authenticate(Context *c, AuthenticationRealm *realm, const ParamsMultiMap &authinfo)=0
Tries to authenticate the authinfo using the give realm.
AuthenticationStore * store() const
Returns the authentication store object.
static void deleteValues(Context *c, const QStringList &keys)
virtual AuthenticationUser autoCreateUser(Context *c, const ParamsMultiMap &userinfo) const
static QVariant value(Context *c, const QString &key, const QVariant &defaultValue=QVariant())
virtual AuthenticationUser fromSession(Context *c, const QVariant &frozenUser)
AuthenticationRealm(AuthenticationStore *store, AuthenticationCredential *credential, const QString &name=QLatin1String(defaultRealm), QObject *parent=nullptr)
Constructs a new AuthenticationRealm object with the given parent.
QString authRealm()
Returns the authentication realm from which this user was retrieved.
void setAuthRealm(const QString &authRealm)
Sets the authentication realm from which this user was retrieved.
void removePersistedUser(Context *c)
Removes the user from the session.