Mercurial > hg > orthanc-authorization
changeset 163:4f5c7acb626f
more detailed error message
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 25 Apr 2024 15:30:24 +0200 |
parents | db1a5d1634e0 |
children | a1fbf3f982f8 99bdc05012c0 |
files | Plugin/Plugin.cpp |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugin/Plugin.cpp Thu Apr 25 15:26:35 2024 +0200 +++ b/Plugin/Plugin.cpp Thu Apr 25 15:30:24 2024 +0200 @@ -715,10 +715,14 @@ { // since this is a series/instance find, make sure the user has access to the parent study Json::Value studyOrthancIds; - if (!OrthancPlugins::RestApiPost(studyOrthancIds, "/tools/lookup", studyInstanceUID, false) || studyOrthancIds.size() != 1) + if (!OrthancPlugins::RestApiPost(studyOrthancIds, "/tools/lookup", studyInstanceUID, false)) { throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess, "Auth plugin: when using tools/find at Series or Instance level, unable to get the orthanc ID of StudyInstanceUID specified in the query."); } + else if (studyOrthancIds.size() != 1) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess, "Auth plugin: when using tools/find at Series or Instance level, unable to get the orthanc ID of StudyInstanceUID specified in the query. Found " + boost::lexical_cast<std::string>(studyOrthancIds.size()) + " orthanc studies with this StudyInstanceUID"); + } bool granted = false; OrthancPlugins::IAuthorizationParser::AccessedResources accessedResources; @@ -749,10 +753,14 @@ } Json::Value studyOrthancIds; - if (!OrthancPlugins::RestApiPost(studyOrthancIds, "/tools/lookup", studyInstanceUID, false) || studyOrthancIds.size() != 1) + if (!OrthancPlugins::RestApiPost(studyOrthancIds, "/tools/lookup", studyInstanceUID, false)) { throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess, "Auth plugin: when using tools/find with a resource token, unable to get the orthanc ID of StudyInstanceUID specified in the query."); } + else if (studyOrthancIds.size() != 1) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess, "Auth plugin: when using tools/find with a resource token, unable to get the orthanc ID of StudyInstanceUID specified in the query. Found " + boost::lexical_cast<std::string>(studyOrthancIds.size()) + " orthanc studies with this StudyInstanceUID"); + } std::vector<TokenAndValue> authTokens; // the tokens that are set in this request GetAuthTokens(authTokens, request->headersCount, request->headersKeys, request->headersValues, request->getCount, request->getKeys, request->getValues);