Leosac
0.8.0
Open Source Access Control
|
Use a file to map auth source (card, PIN, etc) to user. More...
#include <FileAuthSourceMapper.hpp>
Public Member Functions | |
FileAuthSourceMapper (const std::string &auth_file) | |
virtual void | visit (::Leosac::Cred::RFIDCard &src) override |
Try to map a wiegand card_id to a user. More... | |
virtual void | visit (::Leosac::Cred::PinCode &src) override |
Try to map a PIN code to a user. More... | |
virtual void | visit (::Leosac::Cred::RFIDCardPin &src) override |
Try to map a card id + a PIN code to a user. More... | |
virtual void | mapToUser (Leosac::Cred::ICredentialPtr auth_source) |
Must map the ICredential data to a User. More... | |
virtual Leosac::Auth::IAccessProfilePtr | buildProfile (Leosac::Cred::ICredentialPtr cred) |
Build an AccessProfile object given a Credential. More... | |
std::vector< Leosac::Auth::GroupPtr > | groups () const override |
Return the groups this mapper is aware of. More... | |
Public Member Functions inherited from Leosac::Auth::IAuthSourceMapper | |
virtual | ~IAuthSourceMapper ()=default |
Public Member Functions inherited from Leosac::Tools::Visitor< WiegandCard > | |
virtual void | visit (const VisitableT &) |
virtual void | visit (VisitableT &visitable) |
Public Member Functions inherited from Leosac::Tools::BaseVisitor | |
virtual | ~BaseVisitor ()=default |
virtual void | cannot_visit (const IVisitable &) |
Invoked when the visitable cannot be visited by the visitor. More... | |
Public Member Functions inherited from Leosac::Tools::Visitor< PINCode > | |
virtual void | visit (const VisitableT &) |
virtual void | visit (VisitableT &visitable) |
Public Member Functions inherited from Leosac::Tools::Visitor< WiegandCardPin > | |
virtual void | visit (const VisitableT &) |
virtual void | visit (VisitableT &visitable) |
Public Member Functions inherited from Leosac::Tools::Visitor<::Leosac::Cred::RFIDCard > | |
virtual void | visit (const VisitableT &) |
virtual void | visit (VisitableT &visitable) |
Public Member Functions inherited from Leosac::Tools::Visitor<::Leosac::Cred::PinCode > | |
virtual void | visit (const VisitableT &) |
virtual void | visit (VisitableT &visitable) |
Public Member Functions inherited from Leosac::Tools::Visitor<::Leosac::Cred::RFIDCardPin > | |
virtual void | visit (const VisitableT &) |
virtual void | visit (VisitableT &visitable) |
Private Member Functions | |
Cred::ICredentialPtr | find_cred_by_alias (const std::string &alias) |
Lookup a credentials by ID. More... | |
Leosac::Auth::SimpleAccessProfilePtr | build_user_profile (Leosac::Auth::UserPtr u) |
Build an access for a user. More... | |
Leosac::Auth::SimpleAccessProfilePtr | build_group_profile (Leosac::Auth::GroupPtr g) |
Leosac::Auth::SimpleAccessProfilePtr | build_cred_profile (Leosac::Cred::ICredentialPtr c) |
void | add_cred_to_id_map (Leosac::Cred::ICredentialPtr credential) |
Store the credential to the id <-> credential map if the id is non-empty. More... | |
void | load_users (const boost::property_tree::ptree &users) |
Load users from configuration tree, storing them in the users_ map. More... | |
void | load_schedules (const boost::property_tree::ptree &schedules) |
Load the schedules information from the config tree. More... | |
void | map_schedules (const boost::property_tree::ptree &schedules_mapping) |
Interpret the schedule mapping content of the config file. More... | |
void | load_groups (const boost::property_tree::ptree &group_mapping) |
Extract group membership. More... | |
void | load_credentials (const boost::property_tree::ptree &credentials) |
Eager loading of credentials to avoid walking through the ptree whenever we have to grant/deny an access. More... | |
std::vector< Leosac::Auth::GroupPtr > | get_user_groups (Leosac::Auth::UserPtr u) |
Naive method that bruteforce groups to try to find membership for an user. More... | |
Leosac::Auth::IAccessProfilePtr | merge_profiles (const std::vector< Leosac::Auth::IAccessProfilePtr > profiles) |
Merge a bunch of profiles together and returns a new profile. More... | |
Leosac::Auth::ValidityInfo | extract_credentials_validity (const boost::property_tree::ptree &node) |
Private Attributes | |
std::string | config_file_ |
Store the name of the configuration file. More... | |
std::map< std::string, Leosac::Auth::UserPtr > | users_ |
Maps user id (or name) to object. More... | |
std::map< std::string, Leosac::Auth::GroupPtr > | groups_ |
Maps group name to object. More... | |
std::unordered_map< std::string, Leosac::Cred::RFIDCardPtr > | rfid_cards_ |
Maps card_id to object. More... | |
std::unordered_map< std::string, Leosac::Cred::PinCodePtr > | pin_codes_ |
Maps PIN code to object. More... | |
std::map< std::pair< std::string, std::string >, Leosac::Cred::RFIDCardPinPtr > | rfid_cards_pin |
Maps WiegandCard + PIN code to object. More... | |
std::unordered_map< std::string, Leosac::Cred::ICredentialPtr > | id_to_cred_ |
Maps credentials ID (from XML) to object. More... | |
Tools::XmlScheduleLoader | xml_schedules_ |
std::vector< Tools::ScheduleMappingPtr > | mappings_ |
List of mappings defined in the configuration file. More... | |
std::vector< Leosac::Auth::DoorPtr > | doors_ |
We store doors object, but really we only use the name property. More... | |
Tools::XmlNodeNameEnforcer | xmlnne_ |
Additional Inherited Members | |
Public Types inherited from Leosac::Tools::Visitor< WiegandCard > | |
using | VisitableT = std::remove_reference_t< std::remove_const_t< WiegandCard > > |
Public Types inherited from Leosac::Tools::Visitor< PINCode > | |
using | VisitableT = std::remove_reference_t< std::remove_const_t< PINCode > > |
Public Types inherited from Leosac::Tools::Visitor< WiegandCardPin > | |
using | VisitableT = std::remove_reference_t< std::remove_const_t< WiegandCardPin > > |
Public Types inherited from Leosac::Tools::Visitor<::Leosac::Cred::RFIDCard > | |
using | VisitableT = std::remove_reference_t< std::remove_const_t< ::Leosac::Cred::RFIDCard > > |
Public Types inherited from Leosac::Tools::Visitor<::Leosac::Cred::PinCode > | |
using | VisitableT = std::remove_reference_t< std::remove_const_t< ::Leosac::Cred::PinCode > > |
Public Types inherited from Leosac::Tools::Visitor<::Leosac::Cred::RFIDCardPin > | |
using | VisitableT = std::remove_reference_t< std::remove_const_t< ::Leosac::Cred::RFIDCardPin > > |
Use a file to map auth source (card, PIN, etc) to user.
Definition at line 47 of file FileAuthSourceMapper.hpp.
FileAuthSourceMapper::FileAuthSourceMapper | ( | const std::string & | auth_file | ) |
Definition at line 42 of file FileAuthSourceMapper.cpp.
|
private |
Store the credential to the id <-> credential map if the id is non-empty.
Definition at line 444 of file FileAuthSourceMapper.cpp.
|
private |
Definition at line 563 of file FileAuthSourceMapper.cpp.
|
private |
Definition at line 547 of file FileAuthSourceMapper.cpp.
|
private |
Build an access for a user.
This simply check for mapping which are linked directly to the given user.
Definition at line 532 of file FileAuthSourceMapper.cpp.
|
virtual |
Build an AccessProfile object given a Credential.
How the profile is built (ie, based only on user-id, based on auth source and user-id, group membership, etc) is implementation-defined.
The caller expect a valid profile object that will behave correctly or nullptr if no profile could be built.
Implements Leosac::Auth::IAuthSourceMapper.
Definition at line 460 of file FileAuthSourceMapper.cpp.
|
private |
Definition at line 423 of file FileAuthSourceMapper.cpp.
|
private |
Lookup a credentials by ID.
Definition at line 436 of file FileAuthSourceMapper.cpp.
|
private |
Naive method that bruteforce groups to try to find membership for an user.
u | a non-null pointer to user. |
Definition at line 195 of file FileAuthSourceMapper.cpp.
|
overridevirtual |
Return the groups this mapper is aware of.
Implements Leosac::Auth::IAuthSourceMapper.
Definition at line 183 of file FileAuthSourceMapper.cpp.
|
private |
Eager loading of credentials to avoid walking through the ptree whenever we have to grant/deny an access.
Definition at line 233 of file FileAuthSourceMapper.cpp.
|
private |
Extract group membership.
Definition at line 151 of file FileAuthSourceMapper.cpp.
|
private |
Load the schedules information from the config tree.
schedules | The <schedules> subtree. |
Definition at line 306 of file FileAuthSourceMapper.cpp.
|
private |
Load users from configuration tree, storing them in the users_
map.
Definition at line 384 of file FileAuthSourceMapper.cpp.
|
private |
Interpret the schedule mapping content of the config file.
This effectively build access profile for user.
Definition at line 313 of file FileAuthSourceMapper.cpp.
|
virtual |
Must map the ICredential data to a User.
This is done by calling the owner()
method on the auth source object. In case it fails, the field shall be set to nullptr
.
new
ed. Implements Leosac::Auth::IAuthSourceMapper.
Definition at line 137 of file FileAuthSourceMapper.cpp.
|
private |
Merge a bunch of profiles together and returns a new profile.
If the resulting profile contains the schedule, this method will return nullptr.
Definition at line 218 of file FileAuthSourceMapper.cpp.
|
overridevirtual |
Try to map a PIN code to a user.
Definition at line 107 of file FileAuthSourceMapper.cpp.
|
overridevirtual |
Try to map a wiegand card_id to a user.
Definition at line 93 of file FileAuthSourceMapper.cpp.
|
overridevirtual |
Try to map a card id + a PIN code to a user.
Definition at line 121 of file FileAuthSourceMapper.cpp.
|
private |
Store the name of the configuration file.
Definition at line 157 of file FileAuthSourceMapper.hpp.
|
private |
We store doors object, but really we only use the name property.
On door object is created for each mapping that specify a door.
Definition at line 204 of file FileAuthSourceMapper.hpp.
|
private |
Maps group name to object.
Definition at line 167 of file FileAuthSourceMapper.hpp.
|
private |
Maps credentials ID (from XML) to object.
If id is empty, the cred wont end up is this list.
Definition at line 190 of file FileAuthSourceMapper.hpp.
|
private |
List of mappings defined in the configuration file.
Definition at line 197 of file FileAuthSourceMapper.hpp.
|
private |
Maps PIN code to object.
Definition at line 178 of file FileAuthSourceMapper.hpp.
|
private |
Maps card_id to object.
Definition at line 172 of file FileAuthSourceMapper.hpp.
|
private |
Maps WiegandCard + PIN code to object.
Definition at line 184 of file FileAuthSourceMapper.hpp.
|
private |
Maps user id (or name) to object.
Definition at line 162 of file FileAuthSourceMapper.hpp.
|
private |
Definition at line 192 of file FileAuthSourceMapper.hpp.
|
private |
Definition at line 206 of file FileAuthSourceMapper.hpp.