QHttpEngine
1.0.0
Simple and secure HTTP server for Qt applications
|
Middleware for local file-based authentication More...
#include <qhttpengine/localauthmiddleware.h>
Public Member Functions | |
LocalAuthMiddleware (QObject *parent=Q_NULLPTR) | |
Initialize local authentication. More... | |
bool | exists () const |
Determine whether the file exists. | |
QString | filename () const |
Retrieve the name of the file used for storing the token. | |
virtual bool | process (Socket *socket) |
Process the request. More... | |
void | setData (const QVariantMap &data) |
Set additional data to include with the token. | |
void | setHeaderName (const QByteArray &name) |
Set the name of the custom header used for confirming the token. More... | |
![]() | |
Middleware (QObject *parent=Q_NULLPTR) | |
Base constructor for middleware. | |
This class is intended for authenticating applications running under the same user account as the server. LocalFile is used to expose a token to connecting applications. The client passes the token in a special header and the request is permitted.
The file consists of a JSON object in the following format:
Additional data can be added to the object using the setData() method.
|
explicit |
To determine whether the local file was created successfully, call the exists() method.
|
virtual |
If the token supplied by the client matches, the request is allowed. Otherwise, an HTTP 403 error is returned.
Implements QHttpEngine::Middleware.
void QHttpEngine::LocalAuthMiddleware::setHeaderName | ( | const QByteArray & | name | ) |
The default value is "X-Auth-Token".