Mercurial > hg > orthanc-authorization
annotate Plugin/IAuthorizationService.h @ 87:65950b86437b
integration 0.5.0->mainline
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 17 Mar 2023 18:53:01 +0100 |
parents | aa73b10c2db9 |
children | 7381a7674b36 |
rev | line source |
---|---|
1 | 1 /** |
2 * Advanced authorization plugin for Orthanc | |
68 | 3 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
1 | 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 "AccessedResource.h" | |
22 #include "Token.h" | |
23 | |
24 #include <orthanc/OrthancCPlugin.h> | |
25 #include <boost/noncopyable.hpp> | |
69
af44dce56328
new 'auth/user-profile' Rest API route
Alain Mazy <am@osimis.io>
parents:
68
diff
changeset
|
26 #include <json/json.h> |
1 | 27 |
28 namespace OrthancPlugins | |
29 { | |
30 // NOTE: This interface must be thread-safe | |
31 class IAuthorizationService : public boost::noncopyable | |
32 { | |
33 public: | |
72
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
34 struct OrthancResource |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
35 { |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
36 std::string dicomUid; |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
37 std::string orthancId; |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
38 std::string url; |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
39 std::string level; |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
40 }; |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
41 |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
42 struct CreatedToken |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
43 { |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
44 std::string url; |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
45 std::string token; |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
46 }; |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
47 |
74 | 48 struct DecodedToken |
49 { | |
50 std::string redirectUrl; | |
51 std::string errorCode; | |
52 std::string tokenType; | |
53 }; | |
54 | |
1 | 55 virtual ~IAuthorizationService() |
56 { | |
57 } | |
58 | |
59 virtual bool IsGranted(unsigned int& validity /* out */, | |
60 OrthancPluginHttpMethod method, | |
61 const AccessedResource& access, | |
62 const Token& token, | |
63 const std::string& tokenValue) = 0; | |
64 | |
71 | 65 virtual bool IsGrantedToAnonymousUser(unsigned int& validity /* out */, |
66 OrthancPluginHttpMethod method, | |
67 const AccessedResource& access) = 0; | |
69
af44dce56328
new 'auth/user-profile' Rest API route
Alain Mazy <am@osimis.io>
parents:
68
diff
changeset
|
68 |
71 | 69 virtual bool GetUserProfile(unsigned int& validity /* out */, |
70 Json::Value& profile /* out */, | |
69
af44dce56328
new 'auth/user-profile' Rest API route
Alain Mazy <am@osimis.io>
parents:
68
diff
changeset
|
71 const Token& token, |
af44dce56328
new 'auth/user-profile' Rest API route
Alain Mazy <am@osimis.io>
parents:
68
diff
changeset
|
72 const std::string& tokenValue) = 0; |
71 | 73 |
74 virtual bool GetAnonymousUserProfile(unsigned int& validity /* out */, | |
75 Json::Value& profile /* out */) = 0; | |
76 | |
77 virtual bool HasUserPermission(unsigned int& validity /* out */, | |
78 const std::set<std::string>& anyOfPermissions, | |
79 const Token& token, | |
80 const std::string& tokenValue) = 0; | |
81 | |
82 virtual bool HasAnonymousUserPermission(unsigned int& validity /* out */, | |
83 const std::set<std::string>& anyOfPermissions) = 0; | |
72
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
84 |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
85 virtual bool CreateToken(CreatedToken& response, |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
86 const std::string& tokenType, |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
87 const std::string& id, |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
88 const std::vector<OrthancResource>& resources, |
73
512247750f0a
new ValidityDuration arg in create token API
Alain Mazy <am@osimis.io>
parents:
72
diff
changeset
|
89 const std::string& expirationDateString, |
512247750f0a
new ValidityDuration arg in create token API
Alain Mazy <am@osimis.io>
parents:
72
diff
changeset
|
90 const uint64_t& validityDuration) = 0; |
72
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
91 |
74 | 92 virtual bool DecodeToken(DecodedToken& response, |
93 const std::string& tokenKey, | |
94 const std::string& tokenValue) = 0; | |
95 | |
72
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
96 virtual bool HasUserProfile() const = 0; |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
97 virtual bool HasCreateToken() const = 0; |
e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
Alain Mazy <am@osimis.io>
parents:
71
diff
changeset
|
98 virtual bool HasTokenValidation() const = 0; |
1 | 99 }; |
100 } |