Leosac  0.7.0
OpenSourceAccessControl
DoormanInstance.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "core/auth/Auth.hpp"
23 #include "core/auth/AuthFwd.hpp"
24 #include <map>
25 #include <zmqpp/zmqpp.hpp>
26 
27 namespace Leosac
28 {
29 namespace Module
30 {
31 namespace Doorman
32 {
33 class DoormanModule;
40 {
44  std::string target_;
45 
50 
55  std::vector<std::string> cmd_;
56 };
57 
64 {
65  public:
75  DoormanInstance(DoormanModule &module, zmqpp::context &ctx,
76  const std::string &name,
77  const std::vector<std::string> &auth_contexts,
78  const std::vector<DoormanAction> &actions);
79 
80  DoormanInstance(const DoormanInstance &) = delete;
81 
82  DoormanInstance &operator=(const DoormanInstance &) = delete;
83 
84  zmqpp::socket &bus_sub();
85 
89  void handle_bus_msg();
90 
91  private:
100  bool ignore_action(const DoormanAction &action, Auth::AccessStatus status) const;
101 
102  Auth::AuthTargetPtr find_target(const std::string &name) const;
103 
105 
112  void command_send_recv(const std::string &target_name, zmqpp::message msg);
113 
114  std::string name_;
115 
116  std::vector<DoormanAction> actions_;
117 
118  zmqpp::socket bus_sub_;
119 
123  std::map<std::string, zmqpp::socket> targets_;
124 };
125 }
126 }
127 }
std::shared_ptr< AuthTarget > AuthTargetPtr
Definition: AuthFwd.hpp:93
This is the header file for a generated source file, GitSHA1.cpp.
std::map< std::string, zmqpp::socket > targets_
Socket (REP) connected to each target this doorman may have.
Helper struct to wrap an "action".
std::vector< DoormanAction > actions_
Implements a Doorman, that is, a component that will listen to authentication event and react accordi...
Leosac::Auth::AccessStatus on_
When should this action be done? on GRANTED or DENIED ?
std::vector< std::string > cmd_
The command to be send.
std::string target_
Target component.
Main class for the module, it create handlers and run them to, well, handle events and send command...