QHttpEngine  1.0.0
Simple and secure HTTP server for Qt applications
Public Member Functions | List of all members
QHttpEngine::LocalAuthMiddleware Class Reference

Middleware for local file-based authentication More...

#include <qhttpengine/localauthmiddleware.h>

Inheritance diagram for QHttpEngine::LocalAuthMiddleware:
QHttpEngine::Middleware

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...
 
- Public Member Functions inherited from QHttpEngine::Middleware
 Middleware (QObject *parent=Q_NULLPTR)
 Base constructor for middleware.
 

Detailed Description

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:

{
"token": "{8a34d0f0-29d0-4e54-b3aa-ce8f8ad65527}"
}

Additional data can be added to the object using the setData() method.

Constructor & Destructor Documentation

§ LocalAuthMiddleware()

QHttpEngine::LocalAuthMiddleware::LocalAuthMiddleware ( QObject *  parent = Q_NULLPTR)
explicit

To determine whether the local file was created successfully, call the exists() method.

Member Function Documentation

§ process()

virtual bool QHttpEngine::LocalAuthMiddleware::process ( Socket socket)
virtual

If the token supplied by the client matches, the request is allowed. Otherwise, an HTTP 403 error is returned.

Implements QHttpEngine::Middleware.

§ setHeaderName()

void QHttpEngine::LocalAuthMiddleware::setHeaderName ( const QByteArray &  name)

The default value is "X-Auth-Token".


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