![]() |
cutelyst 4.4.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 } |
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 19 of file credentialhttp.cpp.
|
virtual |
Destroys the CredentialHttp object.
Definition at line 25 of file credentialhttp.cpp.
|
finalvirtual |
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 108 of file credentialhttp.cpp.
References Cutelyst::AuthenticationUser::isNull(), and Cutelyst::Context::request.
| QString CredentialHttp::passwordField | ( | ) | const |
Returns the field to look for when authenticating the user.
Definition at line 42 of file credentialhttp.cpp.
| QString CredentialHttp::passwordPostSalt | ( | ) | const |
Returns the salt string to be appended to the password
Definition at line 78 of file credentialhttp.cpp.
Referenced by setPasswordPostSalt().
| QString CredentialHttp::passwordPreSalt | ( | ) | const |
Returns the salt string to be prepended to the password
Definition at line 66 of file credentialhttp.cpp.
Referenced by setPasswordPreSalt().
| CredentialHttp::PasswordType CredentialHttp::passwordType | ( | ) | const |
Returns the type of password this class will be dealing with.
Definition at line 54 of file credentialhttp.cpp.
| 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 36 of file credentialhttp.cpp.
| void CredentialHttp::setPasswordField | ( | const QString & | fieldName | ) |
Sets the field to look for when authenticating the user.
Definition at line 48 of file credentialhttp.cpp.
| void CredentialHttp::setPasswordPostSalt | ( | const QString & | passwordPostSalt | ) |
Sets the salt string to be appended to the password
Definition at line 84 of file credentialhttp.cpp.
References passwordPostSalt().
| void CredentialHttp::setPasswordPreSalt | ( | const QString & | passwordPreSalt | ) |
Sets the salt string to be prepended to the password
Definition at line 72 of file credentialhttp.cpp.
References passwordPreSalt().
| void CredentialHttp::setPasswordType | ( | CredentialHttp::PasswordType | type | ) |
Sets the type of password this class will be dealing with.
Definition at line 60 of file credentialhttp.cpp.
| 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 102 of file credentialhttp.cpp.
| 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 30 of file credentialhttp.cpp.
| void CredentialHttp::setUsernameField | ( | const QString & | fieldName | ) |
Sets the field to look for when authenticating the user.
Definition at line 96 of file credentialhttp.cpp.
| QString CredentialHttp::usernameField | ( | ) | const |
Returns the field to look for when authenticating the user.
Definition at line 90 of file credentialhttp.cpp.