Leosac
0.8.0
Open Source Access Control
|
This class is responsible for providing an API to manage authentication for Websocket client. More...
#include <APIAuth.hpp>
Public Member Functions | |
APIAuth (WSServer &srv) | |
Auth::TokenPtr | authenticate_credentials (const std::string &username, const std::string &password) const |
Attempt to authenticate with username/password credential and generate an authentication token. More... | |
Auth::TokenPtr | authenticate_token (const std::string &token_str) const |
Attempt to authenticate with an authentication token. More... | |
void | invalidate_token (Auth::TokenPtr token) const |
Invalidate the authentication token, removing it from the database. More... | |
Private Member Functions | |
void | enforce_user_enabled (const Auth::User &u) const |
Make sure the User u is authorized to log in. More... | |
Private Attributes | |
WSServer & | server_ |
Reference to the Websocket server. More... | |
This class is responsible for providing an API to manage authentication for Websocket client.
The object is instantiated for the lifetime of the WSServer object.
Definition at line 41 of file APIAuth.hpp.
APIAuth::APIAuth | ( | WSServer & | srv | ) |
Definition at line 44 of file APIAuth.cpp.
Auth::TokenPtr APIAuth::authenticate_credentials | ( | const std::string & | username, |
const std::string & | password | ||
) | const |
Attempt to authenticate with username/password credential and generate an authentication token.
On success return a new authentication token that will be valid when calling for further authentication. On error returns nullptr.
Definition at line 82 of file APIAuth.cpp.
Auth::TokenPtr APIAuth::authenticate_token | ( | const std::string & | token_str | ) | const |
Attempt to authenticate with an authentication token.
Authenticating with a valid token will update the expiration date of the token.
token | The token string used to perform the authentication. Returns the token object matching the token string on success, or nullptr on failure. |
Definition at line 60 of file APIAuth.cpp.
|
private |
Make sure the User u
is authorized to log in.
This means that we check that their ValidityInfo is valid.
Definition at line 123 of file APIAuth.cpp.
void APIAuth::invalidate_token | ( | Auth::TokenPtr | token | ) | const |
Invalidate the authentication token, removing it from the database.
Definition at line 49 of file APIAuth.cpp.
|
private |
Reference to the Websocket server.
The websocket server is guaranteed to outlive the APIAuth object.
Definition at line 89 of file APIAuth.hpp.