cutelyst 5.1.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
Cutelyst::AuthenticationUser Class Reference

Container for user data retrieved from an AuthenticationStore. More...

#include <Cutelyst/Plugins/Authentication/authenticationuser.h>

Public Member Functions

 AuthenticationUser ()
 
 AuthenticationUser (const QVariant &id)
 
virtual ~AuthenticationUser ()
 
QString authRealm ()
 
bool checkPassword (Context *c, AuthenticationRealm *realm, const QString &password, const QString &passwordField=QStringLiteral("password"))
 
QVariantMap data () const
 
QVariant id () const
 
void insert (const QString &key, const QVariant &value)
 
bool isNull () const
 
 operator QVariant () const
 
void setAuthRealm (const QString &authRealm)
 
void setData (const QVariantMap &data)
 
void setId (const QVariant &id)
 
QVariant value (const QString &key, const QVariant &defaultValue=QVariant()) const
 

Protected Attributes

QVariantMap m_data
 

Detailed Description

Create this object in your reimplementation of AuthenticationStore::findUser() and populate it with the data retrieved from your store.

For an example implementation see Authentication overview.

Definition at line 30 of file authenticationuser.h.

Constructor & Destructor Documentation

◆ AuthenticationUser() [1/2]

AuthenticationUser::AuthenticationUser ( )

Constructs a new AuthenticationUser object.

Definition at line 15 of file authenticationuser.cpp.

◆ AuthenticationUser() [2/2]

AuthenticationUser::AuthenticationUser ( const QVariant id)
explicit

Constructs a new AuthenticationUser object with the given id.

Definition at line 19 of file authenticationuser.cpp.

References setId().

◆ ~AuthenticationUser()

AuthenticationUser::~AuthenticationUser ( )
virtual

Destroys the AuthenticationUser object.

Definition at line 24 of file authenticationuser.cpp.

Member Function Documentation

◆ authRealm()

QString AuthenticationUser::authRealm ( )

Returns the authentication realm from which this user was retrieved.

Definition at line 43 of file authenticationuser.cpp.

Referenced by Cutelyst::AuthenticationRealm::findUser(), and setAuthRealm().

◆ checkPassword()

bool AuthenticationUser::checkPassword ( Context c,
AuthenticationRealm realm,
const QString password,
const QString passwordField = QStringLiteral("password") 
)

Validates the given password for this user in the specified realm.

This method delegates password validation to the realm, which may perform validation against the store (e.g., LDAP bind) or using the credential provider. Returns true if the password is valid.

Definition at line 53 of file authenticationuser.cpp.

References Cutelyst::AuthenticationRealm::checkPassword().

Referenced by Cutelyst::CredentialPassword::authenticate().

◆ data()

QVariantMap Cutelyst::AuthenticationUser::data ( ) const
inline

Returns the internal data object.

Definition at line 119 of file authenticationuser.h.

Referenced by Cutelyst::StoreLDAP::forSession(), and setData().

◆ id()

QVariant AuthenticationUser::id ( ) const

A unique ID by which a AuthenticationUser can be retrieved from the store.

Definition at line 28 of file authenticationuser.cpp.

Referenced by Cutelyst::StoreMinimal::findUser(), Cutelyst::StoreHtpasswd::forSession(), and Cutelyst::StoreMinimal::forSession().

◆ insert()

void Cutelyst::AuthenticationUser::insert ( const QString key,
const QVariant value 
)
inline

Inserts a new item with the key key and a value of value.

If there is already an item with the key key, that item's value is replaced with value.

Definition at line 129 of file authenticationuser.h.

References value().

Referenced by Cutelyst::StoreHtpasswd::findUser().

◆ isNull()

◆ operator QVariant()

Cutelyst::AuthenticationUser::operator QVariant ( ) const
inline

Definition at line 113 of file authenticationuser.h.

◆ setAuthRealm()

void AuthenticationUser::setAuthRealm ( const QString authRealm)

Sets the authentication realm from which this user was retrieved.

Definition at line 48 of file authenticationuser.cpp.

References authRealm().

Referenced by Cutelyst::AuthenticationRealm::findUser(), and Cutelyst::AuthenticationRealm::restoreUser().

◆ setData()

void Cutelyst::AuthenticationUser::setData ( const QVariantMap &  data)
inline

Directly sets the internal data object.

Definition at line 124 of file authenticationuser.h.

References data().

Referenced by Cutelyst::StoreLDAP::fromSession().

◆ setId()

void AuthenticationUser::setId ( const QVariant id)

Sets the unique user id restored from the store

Definition at line 33 of file authenticationuser.cpp.

Referenced by AuthenticationUser(), and Cutelyst::StoreHtpasswd::findUser().

◆ value()

QVariant Cutelyst::AuthenticationUser::value ( const QString key,
const QVariant defaultValue = QVariant() 
) const
inline

Returns the value associated with the key key.

If the internal map contains no item with key key, the function returns defaultValue. If no defaultValue is specified, the function returns a default-constructed value.

Definition at line 134 of file authenticationuser.h.

Referenced by Cutelyst::RoleACL::canVisit(), insert(), Cutelyst::Authentication::user(), and Cutelyst::StoreLDAP::validatePassword().

Member Data Documentation

◆ m_data

QVariantMap Cutelyst::AuthenticationUser::m_data
protected

Definition at line 116 of file authenticationuser.h.