# HG changeset patch # User Alain Mazy # Date 1664198439 -7200 # Node ID 317b31e99501af262a2c9a6d57d48d593827cce4 # Parent 01e0c35e004cdf799496f1c516f56c3e6c2de6de Added 3 new configurations: WebServiceUsername, WebServicePassword, WebServiceIdentifier. WebServiceIdentifier is now included in the payload as the 'identifier' field diff -r 01e0c35e004c -r 317b31e99501 NEWS --- a/NEWS Fri May 13 09:51:18 2022 +0200 +++ b/NEWS Mon Sep 26 15:20:39 2022 +0200 @@ -1,6 +1,13 @@ Pending changes in the mainline =============================== +2022-09-26 - v 0.3.0 +==================== + +* Added 3 new configurations: WebServiceUsername, WebServicePassword, WebServiceIdentifier. +* The WebServiceIdentifier is now included in the payload sent to the WebService as the + "identifier" field. + 2022-05-13 - v 0.2.5 ==================== diff -r 01e0c35e004c -r 317b31e99501 Plugin/AuthorizationWebService.cpp --- a/Plugin/AuthorizationWebService.cpp Fri May 13 09:51:18 2022 +0200 +++ b/Plugin/AuthorizationWebService.cpp Mon Sep 26 15:20:39 2022 +0200 @@ -72,6 +72,15 @@ body["token-value"] = tokenValue; } + if (!identifier_.empty()) + { + body["identifier"] = identifier_; + } + else + { + body["identifier"] = Json::nullValue; + } + MemoryBuffer answerBody; MemoryBuffer answerHeaders; uint16_t httpStatus = 0; @@ -148,4 +157,10 @@ username_ = username; password_ = password; } + + void AuthorizationWebService::SetIdentifier(const std::string& webServiceIdentifier) + { + identifier_ = webServiceIdentifier; + } + } diff -r 01e0c35e004c -r 317b31e99501 Plugin/AuthorizationWebService.h --- a/Plugin/AuthorizationWebService.h Fri May 13 09:51:18 2022 +0200 +++ b/Plugin/AuthorizationWebService.h Mon Sep 26 15:20:39 2022 +0200 @@ -28,6 +28,7 @@ std::string url_; std::string username_; std::string password_; + std::string identifier_; bool IsGrantedInternal(unsigned int& validity, OrthancPluginHttpMethod method, @@ -44,6 +45,8 @@ void SetCredentials(const std::string& username, const std::string& password); + void SetIdentifier(const std::string& webServiceIdentifier); + virtual bool IsGranted(unsigned int& validity, OrthancPluginHttpMethod method, const AccessedResource& access, diff -r 01e0c35e004c -r 317b31e99501 Plugin/Plugin.cpp --- a/Plugin/Plugin.cpp Fri May 13 09:51:18 2022 +0200 +++ b/Plugin/Plugin.cpp Mon Sep 26 15:20:39 2022 +0200 @@ -348,9 +348,24 @@ } } + std::unique_ptr webService(new OrthancPlugins::AuthorizationWebService(url)); + + std::string webServiceIdentifier; + if (configuration.LookupStringValue(webServiceIdentifier, "WebServiceIdentifier")) + { + webService->SetIdentifier(webServiceIdentifier); + } + + std::string webServiceUsername; + std::string webServicePassword; + if (configuration.LookupStringValue(webServiceUsername, "WebServiceUsername") && configuration.LookupStringValue(webServicePassword, "WebServicePassword")) + { + webService->SetCredentials(webServiceUsername, webServicePassword); + } + authorizationService_.reset (new OrthancPlugins::CachedAuthorizationService - (new OrthancPlugins::AuthorizationWebService(url), factory)); + (webService.release(), factory)); OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback);