Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorServiceLock::PamAuthenticator Class Reference

IAuthenticator backed by PAM (pam_authenticate + pam_acct_mgmt). More...

#include <PhosphorServiceLock/PamAuthenticator.h>

Inheritance diagram for PhosphorServiceLock::PamAuthenticator:
[legend]

Public Member Functions

 PamAuthenticator (QString service=QStringLiteral("login"), QObject *parent=nullptr)
 ~PamAuthenticator () override
QString service () const
 The PAM service name (the /etc/pam.d/<service> stack) this authenticator validates against.
void authenticate (const QString &username, const QString &password) override
 Asynchronously verify password for username.
Public Member Functions inherited from PhosphorServiceLock::IAuthenticator
 IAuthenticator (QObject *parent=nullptr)
 ~IAuthenticator () override

Additional Inherited Members

Signals inherited from PhosphorServiceLock::IAuthenticator
void succeeded ()
 The credentials were accepted.
void failed (const QString &reason)
 The credentials were rejected (or the attempt could not complete); reason is a human-readable, non-sensitive explanation.

Detailed Description

IAuthenticator backed by PAM (pam_authenticate + pam_acct_mgmt).

Runs the blocking PAM transaction on the global thread pool and delivers the outcome on the GUI thread, so an authentication stack that sleeps (faildelay, a network module) never stalls the event loop. One transaction at a time: a call made while another is outstanding fails fast rather than racing two.

The PAM service name (which /etc/pam.d/<service> stack validates the password) is configurable; it defaults to login, which exists on every system so the service authenticates out of the box. A shell would point this at its own stack.

Threading: construct and call from the GUI thread.

Constructor & Destructor Documentation

◆ PamAuthenticator()

PhosphorServiceLock::PamAuthenticator::PamAuthenticator ( QString service = QStringLiteral("login"),
QObject * parent = nullptr )
explicit

◆ ~PamAuthenticator()

PhosphorServiceLock::PamAuthenticator::~PamAuthenticator ( )
override

Member Function Documentation

◆ authenticate()

void PhosphorServiceLock::PamAuthenticator::authenticate ( const QString & username,
const QString & password )
overridevirtual

Asynchronously verify password for username.

Contract: every authenticate() MUST eventually emit exactly one succeeded or failed. The check runs off the GUI thread so a slow authentication stack never blocks the event loop, and the result signal is delivered on the GUI thread. Implementations should reject (as a failed) a call made while a previous one is still outstanding rather than run two transactions concurrently.

Implements PhosphorServiceLock::IAuthenticator.

◆ service()

QString PhosphorServiceLock::PamAuthenticator::service ( ) const
nodiscard

The PAM service name (the /etc/pam.d/<service> stack) this authenticator validates against.


The documentation for this class was generated from the following file: