Leosac  0.8.0
Open Source Access Control
Leosac::Module::Auth::AuthFileInstance Class Reference

An instance of an authentication handler that use files to check whether or not access is granted or denied. More...

#include <AuthFileInstance.hpp>

+ Inheritance diagram for Leosac::Module::Auth::AuthFileInstance:
+ Collaboration diagram for Leosac::Module::Auth::AuthFileInstance:

Public Member Functions

 AuthFileInstance (zmqpp::context &ctx, const std::string &auth_ctx_name, const std::list< std::string > &auth_sources_names, const std::string &auth_target_name, const std::string &input_file, CoreUtilsPtr core_utils)
 Create a new Authenticator that watch a device and emit authentication message. More...
 
 ~AuthFileInstance ()
 
 AuthFileInstance (const AuthFileInstance &)=delete
 
AuthFileInstanceoperator= (const AuthFileInstance &)=delete
 
void handle_bus_msg ()
 Something happened on the bus that we have interest into. More...
 
zmqpp::socket & bus_sub ()
 Returns the socket subscribed to the message bus. More...
 
const std::string & auth_file_name () const
 Return the name of the file associated with the authenticator. More...
 
std::string auth_file_content () const
 Return the content of the configuration file use for user/group and permission mapping. More...
 

Private Member Functions

bool handle_kernel_message (const zmqpp::message &msg)
 Handle the message if its from Leosac's kernel, or does nothing. More...
 
void reload_auth_config ()
 Schedule an asynchronous reload of the module configuration file. More...
 
AuthResult handle_auth (zmqpp::message *msg) noexcept
 Prepare auth source object, map them to profile and check if access is granted. More...
 

Private Attributes

std::mutex mutex_
 A mutex used only internally. More...
 
FileAuthSourceMapperPtr mapper_
 Authentication config file parser. More...
 
zmqpp::socket bus_push_
 Socket to write to the bus. More...
 
zmqpp::socket bus_sub_
 Socket to read from the bus. More...
 
std::string name_
 Name of this auth context instance. More...
 
std::string target_name_
 Name of the target we auth against. More...
 
std::string file_path_
 Path to the auth data file. More...
 
CoreUtilsPtr core_utils_
 

Detailed Description

An instance of an authentication handler that use files to check whether or not access is granted or denied.

This class is for INTERNAL use only (by AuthFileModule).

Definition at line 71 of file AuthFileInstance.hpp.

Constructor & Destructor Documentation

◆ AuthFileInstance() [1/2]

AuthFileInstance::AuthFileInstance ( zmqpp::context &  ctx,
const std::string &  auth_ctx_name,
const std::list< std::string > &  auth_sources_names,
const std::string &  auth_target_name,
const std::string &  input_file,
CoreUtilsPtr  core_utils 
)

Create a new Authenticator that watch a device and emit authentication message.

Parameters
ctxthe ZeroMQ context
auth_ctx_namename of this authentication context.
auth_sources_namesnames of the sources devices we watch (ie wiegand reader).
auth_target_namename of the target (ie door) we auth against.
input_filepath to file contain auth configuration
core_utilsCore utilities

Definition at line 37 of file AuthFileInstance.cpp.

◆ ~AuthFileInstance()

AuthFileInstance::~AuthFileInstance ( )

Definition at line 62 of file AuthFileInstance.cpp.

◆ AuthFileInstance() [2/2]

Leosac::Module::Auth::AuthFileInstance::AuthFileInstance ( const AuthFileInstance )
delete

Member Function Documentation

◆ auth_file_content()

std::string AuthFileInstance::auth_file_content ( ) const

Return the content of the configuration file use for user/group and permission mapping.

Definition at line 155 of file AuthFileInstance.cpp.

◆ auth_file_name()

const std::string & AuthFileInstance::auth_file_name ( ) const

Return the name of the file associated with the authenticator.

Definition at line 164 of file AuthFileInstance.cpp.

◆ bus_sub()

zmqpp::socket & AuthFileInstance::bus_sub ( )

Returns the socket subscribed to the message bus.

Definition at line 104 of file AuthFileInstance.cpp.

◆ handle_auth()

AuthResult AuthFileInstance::handle_auth ( zmqpp::message *  msg)
privatenoexcept

Prepare auth source object, map them to profile and check if access is granted.

Note
This is a noexcept method. Will return false in case something went wrong.
Returns
A pair of boolean and profile. A true value for the boolean means access shall be granted, otherwise it shall not. The IAccessProfilePtr points to the profile used to resolve the authentication request: it may be null.

Definition at line 109 of file AuthFileInstance.cpp.

◆ handle_bus_msg()

void AuthFileInstance::handle_bus_msg ( )

Something happened on the bus that we have interest into.

Definition at line 67 of file AuthFileInstance.cpp.

◆ handle_kernel_message()

bool AuthFileInstance::handle_kernel_message ( const zmqpp::message &  msg)
private

Handle the message if its from Leosac's kernel, or does nothing.

Returns true if the message was handled.

Definition at line 201 of file AuthFileInstance.cpp.

◆ operator=()

AuthFileInstance& Leosac::Module::Auth::AuthFileInstance::operator= ( const AuthFileInstance )
delete

◆ reload_auth_config()

void AuthFileInstance::reload_auth_config ( )
private

Schedule an asynchronous reload of the module configuration file.

Definition at line 169 of file AuthFileInstance.cpp.

Member Data Documentation

◆ bus_push_

zmqpp::socket Leosac::Module::Auth::AuthFileInstance::bus_push_
private

Socket to write to the bus.

Definition at line 158 of file AuthFileInstance.hpp.

◆ bus_sub_

zmqpp::socket Leosac::Module::Auth::AuthFileInstance::bus_sub_
private

Socket to read from the bus.

Definition at line 163 of file AuthFileInstance.hpp.

◆ core_utils_

CoreUtilsPtr Leosac::Module::Auth::AuthFileInstance::core_utils_
private

Definition at line 180 of file AuthFileInstance.hpp.

◆ file_path_

std::string Leosac::Module::Auth::AuthFileInstance::file_path_
private

Path to the auth data file.

Definition at line 178 of file AuthFileInstance.hpp.

◆ mapper_

FileAuthSourceMapperPtr Leosac::Module::Auth::AuthFileInstance::mapper_
private

Authentication config file parser.

Definition at line 153 of file AuthFileInstance.hpp.

◆ mutex_

std::mutex Leosac::Module::Auth::AuthFileInstance::mutex_
private

A mutex used only internally.

It's needed in order to safely replace the mapper_ when reloading the configuration.

Definition at line 148 of file AuthFileInstance.hpp.

◆ name_

std::string Leosac::Module::Auth::AuthFileInstance::name_
private

Name of this auth context instance.

Definition at line 168 of file AuthFileInstance.hpp.

◆ target_name_

std::string Leosac::Module::Auth::AuthFileInstance::target_name_
private

Name of the target we auth against.

Definition at line 173 of file AuthFileInstance.hpp.


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