QHttpEngine  1.0.0
Simple and secure HTTP server for Qt applications
 All Classes Functions Typedefs Enumerations Enumerator Pages
Public Member Functions | Protected Member Functions | List of all members
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. More...
 
void add (const QString &username, const QString &password)
 Add credentials to the list. More...
 
virtual bool process (Socket *socket)
 Process the request. More...
 
- 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

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

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.

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: