26 #include "core/auth/Group_odb.h"    27 #include "core/auth/Token_odb.h"    29 #include "core/auth/UserGroupMembership_odb.h"    30 #include "core/auth/User_odb.h"    36 #include <odb/session.hxx>    61     std::string username = req.at(
"username");
    62     std::string password = req.at(
"password");
    69         rep[
"user_id"] = token->owner()->id();
    70         rep[
"token"]   = token->token();
    76         rep[
"message"] = 
"Invalid credentials";
    91         rep[
"user_id"]  = token->owner()->id();
    92         rep[
"username"] = token->owner()->username();
    98         rep[
"message"] = 
"Invalid credentials";
   118     rep[
"instance_name"]  = core_api.instance_name();
   119     rep[
"config_version"] = core_api.config_version();
   120     rep[
"uptime"]         = core_api.uptime();
   121     rep[
"modules"]        = core_api.modules_names();
   128     if (cmd == 
"get_leosac_version")
   130     if (cmd == 
"create_auth_token" || cmd == 
"authenticate_with_token")
   139         odb::core::transaction t(
server_.
db()->begin());
   146         catch (
const odb::object_changed &e)
   195         std::make_unique<UserSecurityContext>(
server_.
dbsrv(), token->owner()->id());
 json system_overview(const json &req)
Presents an overview of the system to the end user. 
 
std::shared_ptr< Token > TokenPtr
 
Acts like an odb::session, with the exception that it will save the current active session (if any) a...
 
WSServer & server_
The API server. 
 
void abort_session()
Abort the current websocket session. 
 
This is the header file for a generated source file, GitSHA1.cpp. 
 
void mark_authenticated(Auth::TokenPtr token)
 
void invalidate_token(Auth::TokenPtr token) const
Invalidate the authentication token, removing it from the database. 
 
SecurityContext & security_context() const
 
void clear_authentication()
 
A SecurityContext with no permission. 
 
Auth::TokenPtr authenticate_token(const std::string &token_str) const
Attempt to authenticate with an authentication token. 
 
json logout(const json &req)
Log an user out. 
 
APIAuth & auth()
Retrieve the authentication helper. 
 
json get_leosac_version(const json &)
Retrieve the current version number of Leosac. 
 
The implementation class that runs the websocket server. 
 
DBPtr db()
Retrieve database handle. 
 
std::shared_ptr< User > UserPtr
 
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...
 
All modules that provides features to Leosac shall be in this namespace. 
 
A SecurityContext is used to query permission while doing an operation. 
 
AuthStatus
Enumeration describing the authentication status of a client. 
 
CoreUtilsPtr core_utils()
Retrieve the CoreUtils pointer. 
 
std::unique_ptr< SecurityContext > security_
 
#define ASSERT_LOG(cond, msg)
 
APISession(WSServer &server)
 
json authenticate_with_token(const json &req)
Attempt to authenticate with a (previously generated) authentication token. 
 
Auth::UserId current_user_id() const
Retrieve the UserId of the user associated with this API session. 
 
Auth::TokenPtr current_auth_token_
The token we are authenticated with. 
 
json create_auth_token(const json &req)
Generate an authentication token using the user credential, and logs the user in on success...
 
void hook_before_request()
A hook that is called before a request processing method will be invoked. 
 
DBServicePtr dbsrv()
Retrieve database service pointer. 
 
Auth::UserPtr current_user() const
Retrieve the user associated with the session, or nullptr. 
 
bool allowed(const std::string &cmd)
Is this API client allowed to perform the request cmd ? 
 
Auth::TokenPtr current_token() const
Retrieve the currently in-use token, or nullptr.