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

Combines user store and credential validation into a named realm. More...

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

Inheritance diagram for Cutelyst::AuthenticationRealm:

Public Member Functions

 AuthenticationRealm (std::shared_ptr< AuthenticationStore > store, std::shared_ptr< AuthenticationCredential > credential, QStringView name=defaultRealm, QObject *parent=nullptr)
 
virtual AuthenticationUser authenticate (Context *c, const ParamsMultiMap &authinfo)
 
std::shared_ptr< AuthenticationCredentialcredential () const noexcept
 
virtual AuthenticationUser findUser (Context *c, const ParamsMultiMap &userinfo)
 
AuthenticationUser persistUser (Context *c, const AuthenticationUser &user)
 
void removePersistedUser (Context *c)
 
AuthenticationUser restoreUser (Context *c, const QVariant &frozenUser)
 
std::shared_ptr< AuthenticationStorestore () const noexcept
 
QVariant userIsRestorable (Context *c)
 
- Public Member Functions inherited from Cutelyst::Component
 Component (QObject *parent=nullptr)
 
virtual ~Component () override
 
bool execute (Context *c)
 
virtual bool init (Application *application, const QVariantHash &args)
 
virtual Modifiers modifiers () const
 
QString name () const noexcept
 
QString reverse () const noexcept
 
void setName (const QString &name)
 
void setReverse (const QString &reverse)
 

Static Public Attributes

static const QStringView defaultRealm
 

Friends

class Authentication
 
class AuthenticationPrivate
 

Additional Inherited Members

- Public Types inherited from Cutelyst::Component
enum  Modifier {
  None , OnlyExecute , BeforeExecute , AroundExecute ,
  AfterExecute
}
 
- Protected Member Functions inherited from Cutelyst::Component
 Component (ComponentPrivate *d, QObject *parent=nullptr)
 
virtual bool afterExecute (Context *c)
 
void applyRoles (const QStack< Component * > &roles)
 
virtual bool aroundExecute (Context *c, QStack< Component * > stack)
 
virtual bool beforeExecute (Context *c)
 
virtual bool dispatcherReady (const Dispatcher *dispatch, Controller *controller)
 
virtual bool doExecute (Context *c)
 

Detailed Description

An AuthenticationRealm combines an AuthenticationStore with an AuthenticationCredential object to retrieve and validate user login data.

For an example implementation see Authentication overview.

Logging category
cutelyst.plugin.authentication.realm
Logging with Cutelyst

Definition at line 29 of file authenticationrealm.h.

Constructor & Destructor Documentation

◆ AuthenticationRealm()

AuthenticationRealm::AuthenticationRealm ( std::shared_ptr< AuthenticationStore > store,
std::shared_ptr< AuthenticationCredential > credential,
QStringView name = defaultRealm,
QObject * parent = nullptr )
explicit

Constructs a new AuthenticationRealm object with the given store, credential provider, name and parent.

Definition at line 20 of file authenticationrealm.cpp.

References Cutelyst::Component::Component(), credential(), Cutelyst::Component::name(), Cutelyst::Component::setName(), and store().

◆ ~AuthenticationRealm()

AuthenticationRealm::~AuthenticationRealm ( )
override

Definition at line 35 of file authenticationrealm.cpp.

Member Function Documentation

◆ authenticate()

AuthenticationUser AuthenticationRealm::authenticate ( Context * c,
const ParamsMultiMap & authinfo )
nodiscardvirtual

Tries to authenticate the user with authinfo returning a non null AuthenticationUser on success.

Definition at line 70 of file authenticationrealm.cpp.

◆ credential()

std::shared_ptr< AuthenticationCredential > AuthenticationRealm::credential ( ) const
nodiscardnoexcept

Returns the authentication credential object.

Definition at line 44 of file authenticationrealm.cpp.

Referenced by AuthenticationRealm().

◆ findUser()

AuthenticationUser AuthenticationRealm::findUser ( Context * c,
const ParamsMultiMap & userinfo )
nodiscardvirtual

◆ persistUser()

AuthenticationUser AuthenticationRealm::persistUser ( Context * c,
const AuthenticationUser & user )

Stores the user on the session.

Definition at line 82 of file authenticationrealm.cpp.

References Cutelyst::Session::setValue().

◆ removePersistedUser()

void AuthenticationRealm::removePersistedUser ( Context * c)

Removes the user from the session.

Definition at line 75 of file authenticationrealm.cpp.

References Cutelyst::Session::deleteValues().

◆ restoreUser()

AuthenticationUser AuthenticationRealm::restoreUser ( Context * c,
const QVariant & frozenUser )
nodiscard

Retrieves the user frozenUser from the store.

Definition at line 90 of file authenticationrealm.cpp.

References Cutelyst::AuthenticationUser::isNull(), Cutelyst::AuthenticationUser::setAuthRealm(), and userIsRestorable().

◆ store()

std::shared_ptr< AuthenticationStore > AuthenticationRealm::store ( ) const
nodiscardnoexcept

Returns the authentication store object.

Definition at line 39 of file authenticationrealm.cpp.

Referenced by AuthenticationRealm().

◆ userIsRestorable()

QVariant AuthenticationRealm::userIsRestorable ( Context * c)
nodiscard

Checks if user can be retrieved.

Definition at line 115 of file authenticationrealm.cpp.

References Cutelyst::Session::value().

Referenced by restoreUser().

Friends And Related Symbol Documentation

◆ Authentication

friend class Authentication
friend

Definition at line 91 of file authenticationrealm.h.

◆ AuthenticationPrivate

friend class AuthenticationPrivate
friend

Definition at line 92 of file authenticationrealm.h.

Member Data Documentation

◆ defaultRealm

const QStringView AuthenticationRealm::defaultRealm
static

Default realm name.

Definition at line 36 of file authenticationrealm.h.