Mercurial > hg > orthanc-authorization
comparison Plugin/Plugin.cpp @ 103:fcc4542a0c38
cleanup
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 20 Jun 2023 15:16:26 +0200 |
parents | 18d3f7bd18db |
children | 7381a7674b36 |
comparison
equal
deleted
inserted
replaced
102:18d3f7bd18db | 103:fcc4542a0c38 |
---|---|
145 std::string matchedPattern; | 145 std::string matchedPattern; |
146 if (permissionParser_->Parse(requiredPermissions, matchedPattern, method, uri)) | 146 if (permissionParser_->Parse(requiredPermissions, matchedPattern, method, uri)) |
147 { | 147 { |
148 if (authTokens.empty()) | 148 if (authTokens.empty()) |
149 { | 149 { |
150 LOG(INFO) << "Testing whether anonymous user has any of the required permissions '" << JoinStrings(requiredPermissions) << "'"; | 150 std::string msg = std::string("Testing whether anonymous user has any of the required permissions '") + JoinStrings(requiredPermissions) + "'"; |
151 LOG(INFO) << msg; | |
151 if (authorizationService_->HasAnonymousUserPermission(validity, requiredPermissions)) | 152 if (authorizationService_->HasAnonymousUserPermission(validity, requiredPermissions)) |
152 { | 153 { |
153 LOG(INFO) << "Testing whether anonymous user has any of the required permissions '" << JoinStrings(requiredPermissions) << "' -> granted"; | 154 LOG(INFO) << msg << " -> granted"; |
154 return 1; | 155 return 1; |
155 } | 156 } |
156 else | 157 else |
157 { | 158 { |
158 LOG(INFO) << "Testing whether anonymous user has any of the required permissions '" << JoinStrings(requiredPermissions) << "' -> not granted"; | 159 LOG(INFO) << msg << " -> not granted"; |
159 } | 160 } |
160 } | 161 } |
161 else | 162 else |
162 { | 163 { |
163 for (size_t i = 0; i < authTokens.size(); ++i) | 164 for (size_t i = 0; i < authTokens.size(); ++i) |
164 { | 165 { |
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 << "'"; | 166 std::string msg = std::string("Testing whether user has the required permissions '") + JoinStrings(requiredPermissions) + "' based on the HTTP header '" + authTokens[i].GetToken().GetKey() + "' required to match '" + matchedPattern + "'"; |
167 | |
168 LOG(INFO) << msg; | |
166 if (authorizationService_->HasUserPermission(validity, requiredPermissions, authTokens[i].GetToken(), authTokens[i].GetValue())) | 169 if (authorizationService_->HasUserPermission(validity, requiredPermissions, authTokens[i].GetToken(), authTokens[i].GetValue())) |
167 { | 170 { |
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"; | 171 LOG(INFO) << msg << " -> granted"; |
169 return 1; | 172 return 1; |
170 } | 173 } |
171 else | 174 else |
172 { | 175 { |
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"; | 176 LOG(INFO) << msg << " -> not granted"; |
174 } | 177 } |
175 } | 178 } |
176 } | 179 } |
177 } | 180 } |
178 } | 181 } |