Mercurial > hg > orthanc-authorization
changeset 56:c02f0646297d
added support for /dicom-web/studies?0020000D=1.2.3&...
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 08 Nov 2022 16:10:22 +0100 |
parents | 317b31e99501 |
children | 55539d564f4f |
files | NEWS Plugin/DefaultAuthorizationParser.cpp Plugin/DefaultAuthorizationParser.h Plugin/IAuthorizationParser.h Plugin/Plugin.cpp |
diffstat | 5 files changed, 33 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Mon Sep 26 15:20:39 2022 +0200 +++ b/NEWS Tue Nov 08 16:10:22 2022 +0100 @@ -1,6 +1,8 @@ Pending changes in the mainline =============================== +* added support for QIDO-RS query arguments (e.g: /dicom-web/studies?0020000D=1.2.3&...) + 2022-09-26 - v 0.3.0 ====================
--- a/Plugin/DefaultAuthorizationParser.cpp Mon Sep 26 15:20:39 2022 +0200 +++ b/Plugin/DefaultAuthorizationParser.cpp Tue Nov 08 16:10:22 2022 +0100 @@ -19,6 +19,7 @@ #include "DefaultAuthorizationParser.h" #include <OrthancException.h> +#include <HttpServer/HttpToolbox.h> namespace OrthancPlugins { @@ -47,11 +48,15 @@ dicomWebInstances_ = boost::regex( "^" + tmp + "/studies/([.0-9]+)/series/([.0-9]+)/instances/([.0-9]+)(|/|/frames/.*)$"); + + dicomWebQidoRsFindStudies_ = boost::regex( + "^" + tmp + "/studies\?(.*)$"); } bool DefaultAuthorizationParser::Parse(AccessedResources& target, - const std::string& uri) + const std::string& uri, + const std::map<std::string, std::string>& getArguments) { // The mutex below should not be necessary, but we prefer to // ensure thread safety in boost::regex @@ -127,6 +132,18 @@ AddOrthancInstance(target, what[2]); return true; } + else if (boost::regex_match(uri, what, dicomWebQidoRsFindStudies_)) + { + std::string studyInstanceUid; + + studyInstanceUid = Orthanc::HttpToolbox::GetArgument(getArguments, "0020000D", ""); + + if (!studyInstanceUid.empty()) + { + AddDicomStudy(target, studyInstanceUid); + } + return true; + } else { // Unknown type of resource: Consider it as a system access
--- a/Plugin/DefaultAuthorizationParser.h Mon Sep 26 15:20:39 2022 +0200 +++ b/Plugin/DefaultAuthorizationParser.h Tue Nov 08 16:10:22 2022 +0100 @@ -35,6 +35,7 @@ boost::regex dicomWebStudies_; boost::regex dicomWebSeries_; boost::regex dicomWebInstances_; + boost::regex dicomWebQidoRsFindStudies_; boost::regex osimisViewerSeries_; boost::regex osimisViewerImages_; @@ -45,6 +46,7 @@ const std::string& dicomWebRoot); virtual bool Parse(AccessedResources& target, - const std::string& uri); + const std::string& uri, + const std::map<std::string, std::string>& getArguments); }; }
--- a/Plugin/IAuthorizationParser.h Mon Sep 26 15:20:39 2022 +0200 +++ b/Plugin/IAuthorizationParser.h Tue Nov 08 16:10:22 2022 +0100 @@ -22,6 +22,7 @@ #include <boost/noncopyable.hpp> #include <list> +#include <map> namespace OrthancPlugins { @@ -39,6 +40,7 @@ const std::string& id) = 0; virtual bool Parse(AccessedResources& target, - const std::string& uri) = 0; + const std::string& uri, + const std::map<std::string, std::string>& getArguments) = 0; }; }
--- a/Plugin/Plugin.cpp Mon Sep 26 15:20:39 2022 +0200 +++ b/Plugin/Plugin.cpp Tue Nov 08 16:10:22 2022 +0100 @@ -73,7 +73,13 @@ { // Parse the resources that are accessed through this URI OrthancPlugins::IAuthorizationParser::AccessedResources accesses; - if (!authorizationParser_->Parse(accesses, uri)) // TODO: include getArguments (e.g. for StoneViewer call http://localhost:8044/dicom-web/studies?0020000D=1.2.276.0.7230010.3.1.2.2831156000.1.1499097860.742568&includefield=00081030) + std::map<std::string, std::string> getArguments; + for (uint32_t i = 0; i < getArgumentsCount; i++) + { + getArguments[getArgumentsKeys[i]] = getArgumentsValues[i]; + } + + if (!authorizationParser_->Parse(accesses, uri, getArguments)) { return 0; // Unable to parse this URI }