Mercurial > hg > orthanc-authorization
changeset 87:65950b86437b
integration 0.5.0->mainline
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 17 Mar 2023 18:53:01 +0100 |
parents | 9194a65254d4 (current diff) e2c3c497eb8d (diff) |
children | 0048bde2b916 |
files | |
diffstat | 3 files changed, 26 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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 + )
--- 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;
--- 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;