Mercurial > hg > orthanc-authorization
changeset 275:4f693a12935e inbox
include the server-id field in all requests to the auth-service
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 12 Aug 2025 10:43:35 +0200 |
parents | 74c2ce776b81 |
children | a7dd71fa8516 |
files | NEWS Plugin/AuthorizationWebService.cpp Plugin/AuthorizationWebService.h |
diffstat | 3 files changed, 36 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Mon Aug 11 17:34:48 2025 +0200 +++ b/NEWS Tue Aug 12 10:43:35 2025 +0200 @@ -17,7 +17,8 @@ browsed through the route /auth/audit-logs. - New default permission "audit-logs" to grant access to the "/auth/audit-logs" route. - +* Fix: The "server-id" field is now included in all requests sent to the + auth-service. 2025-07-14 - v 0.9.4
--- a/Plugin/AuthorizationWebService.cpp Mon Aug 11 17:34:48 2025 +0200 +++ b/Plugin/AuthorizationWebService.cpp Tue Aug 12 10:43:35 2025 +0200 @@ -36,8 +36,23 @@ static const char* USER_NAME = "name"; static const char* GROUPS = "groups"; static const char* USER_ID = "user-id"; + static const char* TOKEN_KEY = "token-key"; + static const char* TOKEN_VALUE = "token-value"; + static const char* SERVER_ID = "server-id"; + - + void AddServerId(Json::Value& body, const std::string& serverId) + { + if (!serverId.empty()) + { + body[SERVER_ID] = serverId; + } + else + { + body[SERVER_ID] = Json::nullValue; + } + } + bool AuthorizationWebService::IsGrantedInternal(unsigned int& validity, OrthancPluginHttpMethod method, @@ -83,18 +98,11 @@ if (token != NULL) { - body["token-key"] = token->GetKey(); - body["token-value"] = tokenValue; + body[TOKEN_KEY] = token->GetKey(); + body[TOKEN_VALUE] = tokenValue; } - - if (!identifier_.empty()) - { - body["server-id"] = identifier_; - } - else - { - body["server-id"] = Json::nullValue; - } + + AddServerId(body, serverId_); if (access.GetLabels().size() > 0) { @@ -170,7 +178,7 @@ void AuthorizationWebService::SetIdentifier(const std::string& webServiceIdentifier) { - identifier_ = webServiceIdentifier; + serverId_ = webServiceIdentifier; } @@ -185,8 +193,8 @@ Json::Value body; - body["token-key"] = tokenKey; - body["token-value"] = tokenValue; + body[TOKEN_KEY] = tokenKey; + body[TOKEN_VALUE] = tokenValue; std::string bodyAsString; Orthanc::Toolbox::WriteFastJson(bodyAsString, body); @@ -271,6 +279,8 @@ body["id"] = id; } + AddServerId(body, serverId_); + body["resources"] = Json::arrayValue; for (size_t i = 0; i < resources.size(); ++i) { @@ -401,14 +411,7 @@ body["user-id"] = userId; - if (!identifier_.empty()) - { - body["identifier"] = identifier_; - } - else - { - body["identifier"] = Json::nullValue; - } + AddServerId(body, serverId_); std::string bodyAsString; Orthanc::Toolbox::WriteFastJson(bodyAsString, body); @@ -469,18 +472,11 @@ if (token != NULL) { - body["token-key"] = token->GetKey(); - body["token-value"] = tokenValue; + body[TOKEN_KEY] = token->GetKey(); + body[TOKEN_VALUE] = tokenValue; } - if (!identifier_.empty()) - { - body["identifier"] = identifier_; - } - else - { - body["identifier"] = Json::nullValue; - } + AddServerId(body, serverId_); std::string bodyAsString; Orthanc::Toolbox::WriteFastJson(bodyAsString, body); @@ -585,8 +581,11 @@ try { + Json::Value body = roles; + AddServerId(body, serverId_); + std::string bodyAsString; - Orthanc::Toolbox::WriteFastJson(bodyAsString, roles); + Orthanc::Toolbox::WriteFastJson(bodyAsString, body); HttpClient authClient; authClient.SetUrl(settingsRolesUrl_);
--- a/Plugin/AuthorizationWebService.h Mon Aug 11 17:34:48 2025 +0200 +++ b/Plugin/AuthorizationWebService.h Tue Aug 12 10:43:35 2025 +0200 @@ -30,7 +30,7 @@ private: std::string username_; std::string password_; - std::string identifier_; + std::string serverId_; std::string userProfileUrl_; std::string tokenValidationUrl_; std::string tokenDecoderUrl_;