# HG changeset patch # User Alain Mazy # Date 1599655619 -7200 # Node ID 1c9c2c41c0151bb44b45689aa593e56501877f44 # Parent 3576616904d3945b253780da2ce5c4a89974167f When checking DICOM allowed methods, if there are multiple modalities with the same AET, differentiate them from the calling IP diff -r 3576616904d3 -r 1c9c2c41c015 NEWS --- a/NEWS Mon Sep 07 15:08:52 2020 +0200 +++ b/NEWS Wed Sep 09 14:46:59 2020 +0200 @@ -7,7 +7,8 @@ * Underscores are now allowed in peers/modalities symbolic names * Fix compatibility with C-MOVE SCU requests issued by Ambra * Fix transcoding in C-MOVE SCP, in the case where "SynchronousCMove" is "true" - +* When checking DICOM allowed methods, if there are multiple modalities with the same AET, + differentiate them from the calling IP Version 1.7.3 (2020-08-24) ========================== diff -r 3576616904d3 -r 1c9c2c41c015 OrthancServer/Sources/OrthancConfiguration.cpp --- a/OrthancServer/Sources/OrthancConfiguration.cpp Mon Sep 07 15:08:52 2020 +0200 +++ b/OrthancServer/Sources/OrthancConfiguration.cpp Wed Sep 09 14:46:59 2020 +0200 @@ -746,6 +746,23 @@ return false; } + bool OrthancConfiguration::LookupDicomModalitiesUsingAETitle(std::list& modalities, + const std::string& aet) const + { + modalities.clear(); + + for (Modalities::const_iterator it = modalities_.begin(); it != modalities_.end(); ++it) + { + if (IsSameAETitle(aet, it->second.GetApplicationEntityTitle())) + { + modalities.push_back(it->second); + } + } + + return modalities.size() > 0; + } + + bool OrthancConfiguration::IsKnownAETitle(const std::string& aet, const std::string& ip) const diff -r 3576616904d3 -r 1c9c2c41c015 OrthancServer/Sources/OrthancConfiguration.h --- a/OrthancServer/Sources/OrthancConfiguration.h Mon Sep 07 15:08:52 2020 +0200 +++ b/OrthancServer/Sources/OrthancConfiguration.h Wed Sep 09 14:46:59 2020 +0200 @@ -202,6 +202,9 @@ bool IsSameAETitle(const std::string& aet1, const std::string& aet2) const; + bool LookupDicomModalitiesUsingAETitle(std::list& modalities, + const std::string& aet) const; + bool LookupDicomModalityUsingAETitle(RemoteModalityParameters& modality, const std::string& aet) const; diff -r 3576616904d3 -r 1c9c2c41c015 OrthancServer/Sources/main.cpp --- a/OrthancServer/Sources/main.cpp Mon Sep 07 15:08:52 2020 +0200 +++ b/OrthancServer/Sources/main.cpp Wed Sep 09 14:46:59 2020 +0200 @@ -323,10 +323,28 @@ { OrthancConfiguration::ReaderLock lock; - RemoteModalityParameters modality; - if (lock.GetConfiguration().LookupDicomModalityUsingAETitle(modality, remoteAet)) + std::list modalities; + if (lock.GetConfiguration().LookupDicomModalitiesUsingAETitle(modalities, remoteAet)) { - return modality.IsRequestAllowed(type); + if (modalities.size() == 1) // don't check the IP if there's only one modality with this AET + { + return modalities.front().IsRequestAllowed(type); + } + else // if there are multiple modalities with the same AET, check the one matching this IP + { + for (std::list::const_iterator it = modalities.begin(); it != modalities.end(); ++it) + { + if (it->GetHost() == remoteIp) + { + return it->IsRequestAllowed(type); + } + } + + LOG(WARNING) << "Unable to check DICOM authorization for AET " << remoteAet + << " on IP " << remoteIp << ", " << modalities.size() + << " modalites found with this AET but none of them matching the IP"; + } + return false; } else {