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

Authentication store backed by an LDAP directory. More...

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

Inheritance diagram for Cutelyst::StoreLDAP:
[legend]

Public Types

enum class  SearchScope { Base , OneLevel , SubTree }

Public Member Functions

 StoreLDAP ()
 ~StoreLDAP () override
QStringList attributes () const
QString bindDn () const
AuthenticationUser findUser (Context *c, const ParamsMultiMap &userInfo) override final
QVariant forSession (Context *c, const AuthenticationUser &user) override final
AuthenticationUser fromSession (Context *c, const QVariant &frozenUser) override final
QString idAttribute () const
QStringList serverUris () const
void setAttributes (const QStringList &attributes)
void setBindDn (const QString &bindDn)
void setBindPassword (const QString &bindPassword)
void setIdAttribute (const QString &idAttribute)
void setServerUris (const QStringList &serverUris)
void setStartTls (bool startTls)
void setUserBaseDn (const QString &baseDn)
void setUserField (const QString &userField)
void setUserFilter (const QString &userFilter)
void setUserScope (SearchScope scope)
bool startTls () const
QString userBaseDn () const
QString userField () const
QString userFilter () const
SearchScope userScope () const
bool validatePassword (Context *c, const AuthenticationUser &user, const QString &password) const override
Public Member Functions inherited from Cutelyst::AuthenticationStore
 AuthenticationStore ()
virtual ~AuthenticationStore ()
virtual AuthenticationUser autoCreateUser (Context *c, const ParamsMultiMap &userinfo) const
virtual AuthenticationUser autoUpdateUser (Context *c, const ParamsMultiMap &userinfo) const
virtual bool canAutoCreateUser () const
virtual bool canAutoUpdateUser () const

Detailed Description

This store is based on Catalyst::Authentication::Store::LDAP semantics: user data is searched in LDAP using the configured base DN and filter, then mapped to AuthenticationUser values.

Build with OpenLDAP development files available to enable LDAP support. If LDAP support is not available at build time, findUser() will always return a null AuthenticationUser and log a warning.

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

Definition at line 26 of file storeldap.h.

Member Enumeration Documentation

◆ SearchScope

LDAP search scope values.

Definition at line 32 of file storeldap.h.

Constructor & Destructor Documentation

◆ StoreLDAP()

StoreLDAP::StoreLDAP ( )

Constructs a new StoreLDAP object.

Definition at line 21 of file storeldap.cpp.

References StoreLDAP().

Referenced by StoreLDAP().

◆ ~StoreLDAP()

StoreLDAP::~StoreLDAP ( )
override

Destroys the StoreLDAP object.

Definition at line 30 of file storeldap.cpp.

Member Function Documentation

◆ attributes()

QStringList StoreLDAP::attributes ( ) const
nodiscard

Returns list of LDAP attributes requested during search.

Definition at line 210 of file storeldap.cpp.

Referenced by setAttributes().

◆ bindDn()

QString StoreLDAP::bindDn ( ) const
nodiscard

Returns bind DN used for LDAP searches.

Definition at line 145 of file storeldap.cpp.

Referenced by setBindDn().

◆ findUser()

AuthenticationUser StoreLDAP::findUser ( Context * c,
const ParamsMultiMap & userInfo )
finaloverridevirtual

Reimplemented from AuthenticationStore::findUser().

Implements Cutelyst::AuthenticationStore.

Definition at line 34 of file storeldap.cpp.

◆ forSession()

QVariant StoreLDAP::forSession ( Context * c,
const AuthenticationUser & user )
finaloverridevirtual

Reimplemented from AuthenticationStore::forSession().

Reimplemented from Cutelyst::AuthenticationStore.

Definition at line 45 of file storeldap.cpp.

References Cutelyst::AuthenticationUser::data().

◆ fromSession()

AuthenticationUser StoreLDAP::fromSession ( Context * c,
const QVariant & frozenUser )
finaloverridevirtual

Reimplemented from AuthenticationStore::fromSession().

Reimplemented from Cutelyst::AuthenticationStore.

Definition at line 52 of file storeldap.cpp.

References Cutelyst::AuthenticationUser::setData().

◆ idAttribute()

QString StoreLDAP::idAttribute ( ) const
nodiscard

Returns the LDAP attribute used as AuthenticationUser::id().

Definition at line 180 of file storeldap.cpp.

Referenced by setIdAttribute().

◆ serverUris()

QStringList StoreLDAP::serverUris ( ) const
nodiscard

Returns LDAP server URI list.

Definition at line 135 of file storeldap.cpp.

Referenced by setServerUris().

◆ setAttributes()

void StoreLDAP::setAttributes ( const QStringList & attributes)

Sets list of LDAP attributes to request. Empty list means all attributes.

Definition at line 205 of file storeldap.cpp.

References attributes().

◆ setBindDn()

void StoreLDAP::setBindDn ( const QString & bindDn)

Sets bind DN used to perform LDAP searches.

Definition at line 140 of file storeldap.cpp.

References bindDn().

◆ setBindPassword()

void StoreLDAP::setBindPassword ( const QString & bindPassword)

Sets bind password used to perform LDAP searches.

Definition at line 150 of file storeldap.cpp.

◆ setIdAttribute()

void StoreLDAP::setIdAttribute ( const QString & idAttribute)

Sets the LDAP attribute used as AuthenticationUser::id().

Definition at line 175 of file storeldap.cpp.

References idAttribute().

◆ setServerUris()

void StoreLDAP::setServerUris ( const QStringList & serverUris)

Sets LDAP server URI list (for example ldap://127.0.0.1:389).

Definition at line 130 of file storeldap.cpp.

References serverUris().

◆ setStartTls()

void StoreLDAP::setStartTls ( bool startTls)

Enables or disables STARTTLS before bind/search.

Definition at line 215 of file storeldap.cpp.

References startTls().

◆ setUserBaseDn()

void StoreLDAP::setUserBaseDn ( const QString & baseDn)

Sets the LDAP base DN where users are searched.

Definition at line 155 of file storeldap.cpp.

◆ setUserField()

void StoreLDAP::setUserField ( const QString & userField)

Sets the field used to get user name from auth/user info.

Definition at line 165 of file storeldap.cpp.

References userField().

◆ setUserFilter()

void StoreLDAP::setUserFilter ( const QString & userFilter)

Sets the LDAP filter template used to find a user.

The template may contain %1 placeholder for an escaped user value.

Definition at line 185 of file storeldap.cpp.

References userFilter().

◆ setUserScope()

void StoreLDAP::setUserScope ( StoreLDAP::SearchScope scope)

Sets LDAP search scope used to find users.

Definition at line 195 of file storeldap.cpp.

◆ startTls()

bool StoreLDAP::startTls ( ) const
nodiscard

Returns true when STARTTLS is enabled.

Definition at line 220 of file storeldap.cpp.

Referenced by setStartTls().

◆ userBaseDn()

QString StoreLDAP::userBaseDn ( ) const
nodiscard

Returns the LDAP base DN where users are searched.

Definition at line 160 of file storeldap.cpp.

◆ userField()

QString StoreLDAP::userField ( ) const
nodiscard

Returns the field used to get user name from auth/user info.

Definition at line 170 of file storeldap.cpp.

Referenced by setUserField().

◆ userFilter()

QString StoreLDAP::userFilter ( ) const
nodiscard

Returns the LDAP filter template used to find a user.

Definition at line 190 of file storeldap.cpp.

Referenced by setUserFilter().

◆ userScope()

StoreLDAP::SearchScope StoreLDAP::userScope ( ) const
nodiscard

Returns LDAP search scope used to find users.

Definition at line 200 of file storeldap.cpp.

◆ validatePassword()

bool StoreLDAP::validatePassword ( Context * c,
const AuthenticationUser & user,
const QString & password ) const
nodiscardoverridevirtual

Validates clear text password by binding to LDAP with the user DN.

Reimplemented from Cutelyst::AuthenticationStore.

Definition at line 64 of file storeldap.cpp.

References Cutelyst::AuthenticationUser::value().