# HG changeset patch # User Sebastien Jodogne # Date 1679075581 -3600 # Node ID 65950b86437bfdf6f3e2d29694e019265991c627 # Parent 9194a65254d4b74c697ac7e80525ccb9d53df0cc# Parent e2c3c497eb8dfe63d5c3d66b3c3f16ddc8091dbb integration 0.5.0->mainline diff -r 9194a65254d4 -r 65950b86437b CMakeLists.txt --- a/CMakeLists.txt Fri Mar 17 17:01:43 2023 +0100 +++ b/CMakeLists.txt Fri Mar 17 18:53:01 2023 +0100 @@ -19,13 +19,13 @@ project(OrthancAuthorization) -set(ORTHANC_PLUGIN_VERSION "mainline") +set(ORTHANC_PLUGIN_VERSION "0.5.0") if (ORTHANC_PLUGIN_VERSION STREQUAL "mainline") set(ORTHANC_FRAMEWORK_VERSION "mainline") set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") else() - set(ORTHANC_FRAMEWORK_VERSION "1.9.3") + set(ORTHANC_FRAMEWORK_VERSION "1.11.3") set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web") endif() @@ -204,4 +204,4 @@ target_link_libraries(UnitTests ${GOOGLE_TEST_LIBRARIES} # ${AUTOGENERATED_SOURCES} - ) \ No newline at end of file + ) diff -r 9194a65254d4 -r 65950b86437b Plugin/AuthorizationWebService.cpp --- a/Plugin/AuthorizationWebService.cpp Fri Mar 17 17:01:43 2023 +0100 +++ b/Plugin/AuthorizationWebService.cpp Fri Mar 17 18:53:01 2023 +0100 @@ -282,7 +282,7 @@ } if (validityDuration > 0) { - body["validity-duration"] = validityDuration; + body["validity-duration"] = Json::UInt64(validityDuration); } std::string bodyAsString; diff -r 9194a65254d4 -r 65950b86437b Plugin/Plugin.cpp --- a/Plugin/Plugin.cpp Fri Mar 17 17:01:43 2023 +0100 +++ b/Plugin/Plugin.cpp Fri Mar 17 18:53:01 2023 +0100 @@ -49,15 +49,27 @@ return out; } -struct TokenAndValue +class TokenAndValue { - const OrthancPlugins::Token& token; - std::string value; +private: + OrthancPlugins::Token token_; + std::string value_; +public: TokenAndValue(const OrthancPlugins::Token& token, const std::string& value) : - token(token), - value(value) + token_(token), + value_(value) + { + } + + const OrthancPlugins::Token& GetToken() const { + return token_; + } + + const std::string& GetValue() const + { + return value_; } }; @@ -150,15 +162,15 @@ { for (size_t i = 0; i < authTokens.size(); ++i) { - LOG(INFO) << "Testing whether user has the required permission '" << JoinStrings(requiredPermissions) << "' based on the '" << authTokens[i].token.GetKey() << "' HTTP header required to match '" << matchedPattern << "'"; - if (authorizationService_->HasUserPermission(validity, requiredPermissions, authTokens[i].token, authTokens[i].value)) + LOG(INFO) << "Testing whether user has the required permission '" << JoinStrings(requiredPermissions) << "' based on the '" << authTokens[i].GetToken().GetKey() << "' HTTP header required to match '" << matchedPattern << "'"; + if (authorizationService_->HasUserPermission(validity, requiredPermissions, authTokens[i].GetToken(), authTokens[i].GetValue())) { - LOG(INFO) << "Testing whether user has the required permission '" << JoinStrings(requiredPermissions) << "' based on the '" << authTokens[i].token.GetKey() << "' HTTP header required to match '" << matchedPattern << "' -> granted"; + LOG(INFO) << "Testing whether user has the required permission '" << JoinStrings(requiredPermissions) << "' based on the '" << authTokens[i].GetToken().GetKey() << "' HTTP header required to match '" << matchedPattern << "' -> granted"; return 1; } else { - LOG(INFO) << "Testing whether user has the required permission '" << JoinStrings(requiredPermissions) << "' based on the '" << authTokens[i].token.GetKey() << "' HTTP header required to match '" << matchedPattern << "' -> not granted"; + LOG(INFO) << "Testing whether user has the required permission '" << JoinStrings(requiredPermissions) << "' based on the '" << authTokens[i].GetToken().GetKey() << "' HTTP header required to match '" << matchedPattern << "' -> not granted"; } } } @@ -198,7 +210,7 @@ // Loop over all the authorization tokens in the request until finding one that is granted for (size_t i = 0; i < authTokens.size(); ++i) { - if (authorizationService_->IsGranted(validity, method, *access, authTokens[i].token, authTokens[i].value)) + if (authorizationService_->IsGranted(validity, method, *access, authTokens[i].GetToken(), authTokens[i].GetValue())) { granted = true; break;