comparison Plugin/DefaultAuthorizationParser.cpp @ 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 89eddd4b2f6a
children f448e8626f1a
comparison
equal deleted inserted replaced
127:8591a0c1fa2a 128:0205e9efaca8
18 18
19 #include "DefaultAuthorizationParser.h" 19 #include "DefaultAuthorizationParser.h"
20 20
21 #include <OrthancException.h> 21 #include <OrthancException.h>
22 #include <HttpServer/HttpToolbox.h> 22 #include <HttpServer/HttpToolbox.h>
23 #include <Logging.h>
23 24
24 namespace OrthancPlugins 25 namespace OrthancPlugins
25 { 26 {
26 DefaultAuthorizationParser::DefaultAuthorizationParser(ICacheFactory& factory, 27 DefaultAuthorizationParser::DefaultAuthorizationParser(ICacheFactory& factory,
27 const std::string& dicomWebRoot) : 28 const std::string& dicomWebRoot) :
170 if (patientId.empty()) 171 if (patientId.empty())
171 { 172 {
172 patientId = Orthanc::HttpToolbox::GetArgument(getArguments, "PatientID", ""); 173 patientId = Orthanc::HttpToolbox::GetArgument(getArguments, "PatientID", "");
173 } 174 }
174 175
176 if (!sopInstanceUid.empty() && sopInstanceUid.find('*') != std::string::npos)
177 {
178 LOG(WARNING) << "Authorization plugin: unable to handle wildcards in SOPInstanceUID";
179 sopInstanceUid = ""; // remove the constrain, it will be considered as a 'system' access
180 }
181
182 if (!seriesInstanceUid.empty() && seriesInstanceUid.find('*') != std::string::npos)
183 {
184 LOG(WARNING) << "Authorization plugin: unable to handle wildcards in SeriesInstanceUID";
185 seriesInstanceUid = ""; // remove the constrain, it will be considered as a 'system' access
186 }
187
188 if (!studyInstanceUid.empty() && studyInstanceUid.find('*') != std::string::npos)
189 {
190 LOG(WARNING) << "Authorization plugin: unable to handle wildcards in StudyInstanceUID";
191 studyInstanceUid = ""; // remove the constrain, it will be considered as a 'system' access
192 }
193
194 if (!patientId.empty() && patientId.find('*') != std::string::npos)
195 {
196 LOG(WARNING) << "Authorization plugin: unable to handle wildcards in PatientID";
197 patientId = ""; // remove the constrain, it will be considered as a 'system' access
198 }
199
175 if (!sopInstanceUid.empty() && !seriesInstanceUid.empty() && !studyInstanceUid.empty()) 200 if (!sopInstanceUid.empty() && !seriesInstanceUid.empty() && !studyInstanceUid.empty())
176 { 201 {
177 AddDicomInstance(target, studyInstanceUid, seriesInstanceUid, sopInstanceUid); 202 AddDicomInstance(target, studyInstanceUid, seriesInstanceUid, sopInstanceUid);
178 return true; 203 return true;
179 } 204 }