comparison Plugin/Plugin.cpp @ 86:e2c3c497eb8d 0.5.0

fix LSB build
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 17 Mar 2023 18:52:45 +0100
parents 1c91a1cbbc35
children dff72e397f90
comparison
equal deleted inserted replaced
85:9db6b2ed930c 86:e2c3c497eb8d
47 std::set<std::string> copy = values; // TODO: remove after upgrading to OrthancFramework 1.11.3+ 47 std::set<std::string> copy = values; // TODO: remove after upgrading to OrthancFramework 1.11.3+
48 Orthanc::Toolbox::JoinStrings(out, copy, "|"); 48 Orthanc::Toolbox::JoinStrings(out, copy, "|");
49 return out; 49 return out;
50 } 50 }
51 51
52 struct TokenAndValue 52 class TokenAndValue
53 { 53 {
54 const OrthancPlugins::Token& token; 54 private:
55 std::string value; 55 OrthancPlugins::Token token_;
56 56 std::string value_;
57
58 public:
57 TokenAndValue(const OrthancPlugins::Token& token, const std::string& value) : 59 TokenAndValue(const OrthancPlugins::Token& token, const std::string& value) :
58 token(token), 60 token_(token),
59 value(value) 61 value_(value)
60 { 62 {
63 }
64
65 const OrthancPlugins::Token& GetToken() const
66 {
67 return token_;
68 }
69
70 const std::string& GetValue() const
71 {
72 return value_;
61 } 73 }
62 }; 74 };
63 75
64 76
65 static int32_t FilterHttpRequests(OrthancPluginHttpMethod method, 77 static int32_t FilterHttpRequests(OrthancPluginHttpMethod method,
148 } 160 }
149 else 161 else
150 { 162 {
151 for (size_t i = 0; i < authTokens.size(); ++i) 163 for (size_t i = 0; i < authTokens.size(); ++i)
152 { 164 {
153 LOG(INFO) << "Testing whether user has the required permission '" << JoinStrings(requiredPermissions) << "' based on the '" << authTokens[i].token.GetKey() << "' HTTP header required to match '" << matchedPattern << "'"; 165 LOG(INFO) << "Testing whether user has the required permission '" << JoinStrings(requiredPermissions) << "' based on the '" << authTokens[i].GetToken().GetKey() << "' HTTP header required to match '" << matchedPattern << "'";
154 if (authorizationService_->HasUserPermission(validity, requiredPermissions, authTokens[i].token, authTokens[i].value)) 166 if (authorizationService_->HasUserPermission(validity, requiredPermissions, authTokens[i].GetToken(), authTokens[i].GetValue()))
155 { 167 {
156 LOG(INFO) << "Testing whether user has the required permission '" << JoinStrings(requiredPermissions) << "' based on the '" << authTokens[i].token.GetKey() << "' HTTP header required to match '" << matchedPattern << "' -> granted"; 168 LOG(INFO) << "Testing whether user has the required permission '" << JoinStrings(requiredPermissions) << "' based on the '" << authTokens[i].GetToken().GetKey() << "' HTTP header required to match '" << matchedPattern << "' -> granted";
157 return 1; 169 return 1;
158 } 170 }
159 else 171 else
160 { 172 {
161 LOG(INFO) << "Testing whether user has the required permission '" << JoinStrings(requiredPermissions) << "' based on the '" << authTokens[i].token.GetKey() << "' HTTP header required to match '" << matchedPattern << "' -> not granted"; 173 LOG(INFO) << "Testing whether user has the required permission '" << JoinStrings(requiredPermissions) << "' based on the '" << authTokens[i].GetToken().GetKey() << "' HTTP header required to match '" << matchedPattern << "' -> not granted";
162 } 174 }
163 } 175 }
164 } 176 }
165 } 177 }
166 } 178 }
196 else 208 else
197 { 209 {
198 // Loop over all the authorization tokens in the request until finding one that is granted 210 // Loop over all the authorization tokens in the request until finding one that is granted
199 for (size_t i = 0; i < authTokens.size(); ++i) 211 for (size_t i = 0; i < authTokens.size(); ++i)
200 { 212 {
201 if (authorizationService_->IsGranted(validity, method, *access, authTokens[i].token, authTokens[i].value)) 213 if (authorizationService_->IsGranted(validity, method, *access, authTokens[i].GetToken(), authTokens[i].GetValue()))
202 { 214 {
203 granted = true; 215 granted = true;
204 break; 216 break;
205 } 217 }
206 } 218 }