![]() |
cutelyst 4.9.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
|
Use HTTP basic authentication to authenticate a user. More...
#include <Cutelyst/Plugins/Authentication/credentialhttp.h>

Public Types | |
| enum | AuthType { Any , Basic } |
| enum | PasswordType { None , Clear , Hashed } |
Public Member Functions | |
| CredentialHttp (QObject *parent=nullptr) | |
| virtual | ~CredentialHttp () |
| AuthenticationUser | authenticate (Context *c, AuthenticationRealm *realm, const ParamsMultiMap &authinfo) final |
| QString | passwordField () const |
| QString | passwordPostSalt () const |
| QString | passwordPreSalt () const |
| PasswordType | passwordType () const |
| void | setAuthorizationRequiredMessage (const QString &message) |
| void | setPasswordField (const QString &fieldName) |
| void | setPasswordPostSalt (const QString &passwordPostSalt) |
| void | setPasswordPreSalt (const QString &passwordPreSalt) |
| void | setPasswordType (PasswordType type) |
| void | setRequireSsl (bool require) |
| void | setType (CredentialHttp::AuthType type) |
| void | setUsernameField (const QString &fieldName) |
| QString | usernameField () const |
Public Member Functions inherited from Cutelyst::AuthenticationCredential | |
| AuthenticationCredential (QObject *parent=nullptr) | |
| virtual | ~AuthenticationCredential () |
This credential provider authenticates a user using HTTP basic authentication as described in RFC 76147. It tries to read the user name and the password from the Authorization header send by the user agent. If the authorization fails or if no Authorization header is available, it will respond with a 401 Unauthorized status code and will set the WWW-Authenticate header requesting basic authentication with the used realm.
For an example implementation see Authentication overview.
Definition at line 32 of file credentialhttp.h.
The authentication type.
Definition at line 51 of file credentialhttp.h.
The used password type.
| Enumerator | |
|---|---|
| None | Ignore password check. |
| Clear | Clear text password. |
| Hashed | Derived password hash using PBKDF2 method. |
Definition at line 40 of file credentialhttp.h.
|
explicit |
Constructs a new CredentialHttp object with the given parent.
Definition at line 20 of file credentialhttp.cpp.
References Cutelyst::AuthenticationCredential::AuthenticationCredential(), and CredentialHttp().
Referenced by CredentialHttp(), authenticate(), passwordField(), passwordPostSalt(), passwordPreSalt(), passwordType(), setAuthorizationRequiredMessage(), setPasswordField(), setPasswordPostSalt(), setPasswordPreSalt(), setPasswordType(), setRequireSsl(), setType(), setUsernameField(), and usernameField().
|
virtual |
Destroys the CredentialHttp object.
Definition at line 26 of file credentialhttp.cpp.
|
nodiscardfinalvirtual |
Gets the user data from the Authorization HTTP header field and tries to find it in the realm. On success, this returns a not null AuthenticationUser object. If authentication fails, the HTTP response status code will be set to 401 Unauthorized and the WWW-Authenticate header will be set with the required authentication method and realm name while a null AuthenticationUser object is returned.
Implements Cutelyst::AuthenticationCredential.
Definition at line 109 of file credentialhttp.cpp.
References CredentialHttp(), Cutelyst::AuthenticationUser::isNull(), and Cutelyst::Context::request.
|
nodiscard |
Returns the field to look for when authenticating the user.
Definition at line 43 of file credentialhttp.cpp.
References CredentialHttp().
|
nodiscard |
Returns the salt string to be appended to the password
Definition at line 79 of file credentialhttp.cpp.
References CredentialHttp().
Referenced by setPasswordPostSalt().
|
nodiscard |
Returns the salt string to be prepended to the password
Definition at line 67 of file credentialhttp.cpp.
References CredentialHttp().
Referenced by setPasswordPreSalt().
|
nodiscard |
Returns the type of password this class will be dealing with.
Definition at line 55 of file credentialhttp.cpp.
References CredentialHttp().
| void CredentialHttp::setAuthorizationRequiredMessage | ( | const QString & | message | ) |
Set this to a string to override the default body content "Authorization required.", or set to undef to suppress body content being generated.
Definition at line 37 of file credentialhttp.cpp.
References CredentialHttp().
| void CredentialHttp::setPasswordField | ( | const QString & | fieldName | ) |
Sets the field to look for when authenticating the user.
Definition at line 49 of file credentialhttp.cpp.
References CredentialHttp().
| void CredentialHttp::setPasswordPostSalt | ( | const QString & | passwordPostSalt | ) |
Sets the salt string to be appended to the password
Definition at line 85 of file credentialhttp.cpp.
References CredentialHttp(), and passwordPostSalt().
| void CredentialHttp::setPasswordPreSalt | ( | const QString & | passwordPreSalt | ) |
Sets the salt string to be prepended to the password
Definition at line 73 of file credentialhttp.cpp.
References CredentialHttp(), and passwordPreSalt().
| void CredentialHttp::setPasswordType | ( | CredentialHttp::PasswordType | type | ) |
Sets the type of password this class will be dealing with.
Definition at line 61 of file credentialhttp.cpp.
References CredentialHttp().
| void CredentialHttp::setRequireSsl | ( | bool | require | ) |
If this configuration is true then authentication will be denied (and a 401 issued in normal circumstances) unless the request is via https.
Definition at line 103 of file credentialhttp.cpp.
References CredentialHttp().
| void CredentialHttp::setType | ( | CredentialHttp::AuthType | type | ) |
Can be either any (the default), basic.
This controls authorization_required_response and authenticate, but not the "manual" methods.
Definition at line 31 of file credentialhttp.cpp.
References CredentialHttp().
| void CredentialHttp::setUsernameField | ( | const QString & | fieldName | ) |
Sets the field to look for when authenticating the user.
Definition at line 97 of file credentialhttp.cpp.
References CredentialHttp().
|
nodiscard |
Returns the field to look for when authenticating the user.
Definition at line 91 of file credentialhttp.cpp.
References CredentialHttp().