Leosac  0.8.0
Open Source Access Control
Leosac::Module::WebSockAPI::APIAuth Class Reference

This class is responsible for providing an API to manage authentication for Websocket client. More...

#include <APIAuth.hpp>

+ Collaboration diagram for Leosac::Module::WebSockAPI::APIAuth:

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

WSServerserver_
 Reference to the Websocket server. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ APIAuth()

APIAuth::APIAuth ( WSServer srv)

Definition at line 44 of file APIAuth.cpp.

Member Function Documentation

◆ authenticate_credentials()

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.

Note
Username is case isensitive and will be converted to lower case.

Definition at line 82 of file APIAuth.cpp.

◆ authenticate_token()

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.

Parameters
tokenThe 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.

◆ enforce_user_enabled()

void APIAuth::enforce_user_enabled ( const Auth::User u) const
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.

◆ invalidate_token()

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.

Member Data Documentation

◆ server_

WSServer& Leosac::Module::WebSockAPI::APIAuth::server_
private

Reference to the Websocket server.

The websocket server is guaranteed to outlive the APIAuth object.

Definition at line 89 of file APIAuth.hpp.


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