QHttpEngine 1.0.1
Simple and secure HTTP server for Qt applications
Loading...
Searching...
No Matches
QHttpEngine::BasicAuthMiddleware Class Reference

Middleware for HTTP basic authentication More...

#include <qhttpengine/basicauthmiddleware.h>

Inheritance diagram for QHttpEngine::BasicAuthMiddleware:
QHttpEngine::Middleware

Public Member Functions

 BasicAuthMiddleware (const QString &realm, QObject *parent=Q_NULLPTR)
 Base constructor for the middleware.
void add (const QString &username, const QString &password)
 Add credentials to the list.
virtual bool process (Socket *socket)
 Process the request.
Public Member Functions inherited from QHttpEngine::Middleware
 Middleware (QObject *parent=Q_NULLPTR)
 Base constructor for middleware.

Protected Member Functions

virtual bool verify (const QString &username, const QString &password)
 Determine if the client is authorized.

Detailed Description

HTTP Basic authentication allows access to specific resources to be restricted. This class uses a map to store accepted username/password combinations, which are then used for authenticating requests. To use a different method of authentication, override the verify() method in a derived class.

Constructor & Destructor Documentation

◆ BasicAuthMiddleware()

QHttpEngine::BasicAuthMiddleware::BasicAuthMiddleware ( const QString & realm,
QObject * parent = Q_NULLPTR )

The realm string is shown to a client when credentials are requested.

Member Function Documentation

◆ add()

void QHttpEngine::BasicAuthMiddleware::add ( const QString & username,
const QString & password )

If the username has already been added, its password will be replaced with the new one provided.

◆ process()

virtual bool QHttpEngine::BasicAuthMiddleware::process ( Socket * socket)
virtual

If the verify() method returns true, the client will be granted access to the resources. Otherwise, 401 Unauthorized will be returned.

Implements QHttpEngine::Middleware.


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