changeset 128:0205e9efaca8

detect wildcards in query args like '/dicom-web/studies?PatientID=*' and consider these routes as system routes
author Alain Mazy <am@osimis.io>
date Mon, 13 Nov 2023 15:31:06 +0100
parents 8591a0c1fa2a
children 5a6ff0c93cf4 93008e52c86f
files Plugin/DefaultAuthorizationParser.cpp
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Plugin/DefaultAuthorizationParser.cpp	Mon Nov 13 12:59:10 2023 +0100
+++ b/Plugin/DefaultAuthorizationParser.cpp	Mon Nov 13 15:31:06 2023 +0100
@@ -20,6 +20,7 @@
 
 #include <OrthancException.h>
 #include <HttpServer/HttpToolbox.h>
+#include <Logging.h>
 
 namespace OrthancPlugins
 {
@@ -172,6 +173,30 @@
         patientId = Orthanc::HttpToolbox::GetArgument(getArguments, "PatientID", "");
       }
 
+      if (!sopInstanceUid.empty() && sopInstanceUid.find('*') != std::string::npos)
+      {
+        LOG(WARNING) << "Authorization plugin: unable to handle wildcards in SOPInstanceUID";
+        sopInstanceUid = "";  // remove the constrain, it will be considered as a 'system' access
+      }
+
+      if (!seriesInstanceUid.empty() && seriesInstanceUid.find('*') != std::string::npos)
+      {
+        LOG(WARNING) << "Authorization plugin: unable to handle wildcards in SeriesInstanceUID";
+        seriesInstanceUid = "";  // remove the constrain, it will be considered as a 'system' access
+      }
+
+      if (!studyInstanceUid.empty() && studyInstanceUid.find('*') != std::string::npos)
+      {
+        LOG(WARNING) << "Authorization plugin: unable to handle wildcards in StudyInstanceUID";
+        studyInstanceUid = "";  // remove the constrain, it will be considered as a 'system' access
+      }
+
+      if (!patientId.empty() && patientId.find('*') != std::string::npos)
+      {
+        LOG(WARNING) << "Authorization plugin: unable to handle wildcards in PatientID";
+        patientId = "";  // remove the constrain, it will be considered as a 'system' access
+      }
+
       if (!sopInstanceUid.empty() && !seriesInstanceUid.empty() && !studyInstanceUid.empty())
       {
         AddDicomInstance(target, studyInstanceUid, seriesInstanceUid, sopInstanceUid);