Leosac  0.8.0
Open Source Access Control
RemoteControlSecurity.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 <boost/property_tree/ptree.hpp>
23 #include <unordered_map>
24 #include <vector>
25 
26 namespace Leosac
27 {
28 
29 class Kernel;
30 
49 {
50  public:
54  RemoteControlSecurity(const boost::property_tree::ptree &cfg);
55 
56  bool allow_request(const std::string &user_pubkey, const std::string &req);
57 
61  using KeyCommandsMap = std::unordered_map<std::string, std::vector<std::string>>;
62 
63  private:
64  void process_config();
65 
69  void process_security_entry(const boost::property_tree::ptree &);
70 
71  boost::property_tree::ptree cfg_;
72 
73  std::unordered_map<std::string, bool> default_permissions_;
75 
80 };
81 }
Leosac::RemoteControlSecurity::RemoteControlSecurity
RemoteControlSecurity(const boost::property_tree::ptree &cfg)
The config tree is the same tree that the RemoteControl object has.
Definition: RemoteControlSecurity.cpp:26
Leosac::RemoteControlSecurity::allow_request
bool allow_request(const std::string &user_pubkey, const std::string &req)
Definition: RemoteControlSecurity.cpp:49
Leosac::RemoteControlSecurity
Provide some kind of security framework to the Remote Control service.
Definition: RemoteControlSecurity.hpp:48
Leosac::RemoteControlSecurity::permissions_
KeyCommandsMap permissions_
Definition: RemoteControlSecurity.hpp:74
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::RemoteControlSecurity::process_security_entry
void process_security_entry(const boost::property_tree::ptree &)
Process one <map> entry.
Definition: RemoteControlSecurity.cpp:71
Leosac::RemoteControlSecurity::unrestricted_
bool unrestricted_
If everyone has access to everything.
Definition: RemoteControlSecurity.hpp:79
Leosac::RemoteControlSecurity::process_config
void process_config()
Definition: RemoteControlSecurity.cpp:33
Leosac::RemoteControlSecurity::KeyCommandsMap
std::unordered_map< std::string, std::vector< std::string > > KeyCommandsMap
Map user public key to a set of command.
Definition: RemoteControlSecurity.hpp:61
Leosac::RemoteControlSecurity::cfg_
boost::property_tree::ptree cfg_
Definition: RemoteControlSecurity.hpp:71
Leosac::RemoteControlSecurity::default_permissions_
std::unordered_map< std::string, bool > default_permissions_
Definition: RemoteControlSecurity.hpp:73