Mercurial > hg > orthanc-authorization
comparison Plugin/BaseAuthorizationService.h @ 113:43154740ea2e
wip: checking labels
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 05 Sep 2023 12:48:20 +0200 |
parents | 7381a7674b36 |
children | 9be1ee2b8fe1 |
comparison
equal
deleted
inserted
replaced
112:572955904411 | 113:43154740ea2e |
---|---|
40 const Token* token, | 40 const Token* token, |
41 const std::string& tokenValue) = 0; | 41 const std::string& tokenValue) = 0; |
42 | 42 |
43 virtual bool HasUserPermissionInternal(unsigned int& validity, | 43 virtual bool HasUserPermissionInternal(unsigned int& validity, |
44 const std::string& permission, | 44 const std::string& permission, |
45 const Token* token, | 45 const UserProfile& profile) = 0; |
46 const std::string& tokenValue) = 0; | |
47 | 46 |
48 public: | 47 public: |
49 virtual ~BaseAuthorizationService() | 48 virtual ~BaseAuthorizationService() |
50 { | 49 { |
51 } | 50 } |
80 return GetUserProfileInternal(validity, profile, NULL, ""); | 79 return GetUserProfileInternal(validity, profile, NULL, ""); |
81 } | 80 } |
82 | 81 |
83 virtual bool HasUserPermission(unsigned int& validity /* out */, | 82 virtual bool HasUserPermission(unsigned int& validity /* out */, |
84 const std::set<std::string>& anyOfPermissions, | 83 const std::set<std::string>& anyOfPermissions, |
85 const Token& token, | 84 const UserProfile& profile) |
86 const std::string& tokenValue) | |
87 { | 85 { |
88 if (anyOfPermissions.size() == 0) | 86 if (anyOfPermissions.size() == 0) |
89 { | 87 { |
90 return true; | 88 return true; |
91 } | 89 } |
92 | 90 |
93 for (std::set<std::string>::const_iterator it = anyOfPermissions.begin(); it != anyOfPermissions.end(); ++it) | 91 for (std::set<std::string>::const_iterator it = anyOfPermissions.begin(); it != anyOfPermissions.end(); ++it) |
94 { | 92 { |
95 if (HasUserPermissionInternal(validity, *it, &token, tokenValue)) | 93 if (HasUserPermissionInternal(validity, *it, profile)) |
96 { | 94 { |
97 return true; | 95 return true; |
98 } | 96 } |
99 } | 97 } |
100 return false; | 98 return false; |
106 if (anyOfPermissions.size() == 0) | 104 if (anyOfPermissions.size() == 0) |
107 { | 105 { |
108 return true; | 106 return true; |
109 } | 107 } |
110 | 108 |
109 UserProfile anonymousUserProfile; | |
110 anonymousUserProfile.tokenType = TokenType_None; | |
111 | |
111 for (std::set<std::string>::const_iterator it = anyOfPermissions.begin(); it != anyOfPermissions.end(); ++it) | 112 for (std::set<std::string>::const_iterator it = anyOfPermissions.begin(); it != anyOfPermissions.end(); ++it) |
112 { | 113 { |
113 if (HasUserPermissionInternal(validity, *it, NULL, "")) | 114 if (HasUserPermissionInternal(validity, *it, anonymousUserProfile)) |
114 { | 115 { |
115 return true; | 116 return true; |
116 } | 117 } |
117 } | 118 } |
118 return false; | 119 return false; |