comparison Plugin/PermissionParser.h @ 71:30fb3ce960d9

configurable user permissions
author Alain Mazy <am@osimis.io>
date Wed, 22 Feb 2023 13:13:38 +0100
parents
children 423531fb1200
comparison
equal deleted inserted replaced
70:786b202ef24e 71:30fb3ce960d9
1 /**
2 * Advanced authorization plugin for Orthanc
3 * Copyright (C) 2017-2023 Osimis S.A., Belgium
4 *
5 * This program is free software: you can redistribute it and/or
6 * modify it under the terms of the GNU Affero General Public License
7 * as published by the Free Software Foundation, either version 3 of
8 * the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 **/
18
19 #pragma once
20
21 #include "AuthorizationParserBase.h"
22
23 #include <boost/regex.hpp>
24 #include <boost/thread/mutex.hpp>
25
26 namespace OrthancPlugins
27 {
28 struct PermissionPattern
29 {
30 OrthancPluginHttpMethod method;
31 boost::regex pattern;
32 std::set<std::string> permissions;
33
34 PermissionPattern(const OrthancPluginHttpMethod& method, const std::string& patternRegex, const std::string& permissions);
35 };
36
37 class PermissionParser
38 {
39 private:
40 mutable boost::mutex mutex_;
41 std::list<PermissionPattern> permissionsPattern_;
42 std::string dicomWebRoot_;
43 std::string oe2Root_;
44
45 public:
46 PermissionParser(const std::string& dicomWebRoot,
47 const std::string& oe2Root);
48
49 void Add(const std::string& method,
50 const std::string& patternRegex,
51 const std::string& permission);
52
53 void Add(const Json::Value& configuration);
54
55 bool Parse(std::set<std::string>& permissions,
56 std::string& matchedPattern,
57 const OrthancPluginHttpMethod& method,
58 const std::string& uri) const;
59 };
60 }