Mercurial > hg > orthanc-dicomweb
changeset 792:d93f5841c7ca default tip
fix Host configuration that was ignored
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Tue, 01 Dec 2026 16:23:11 +0100 |
| parents | 9c31fd31c12a |
| children | |
| files | Plugin/Configuration.cpp |
| diffstat | 1 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugin/Configuration.cpp Tue Sep 22 11:02:34 2026 +0200 +++ b/Plugin/Configuration.cpp Tue Dec 01 16:23:11 2026 +0100 @@ -564,12 +564,13 @@ { assert(dicomWebConfiguration_.get() != NULL); std::string host = dicomWebConfiguration_->GetStringValue("Host", ""); + bool hostIsForcedInConfig = ! host.empty(); std::set<std::string> allowedHosts; dicomWebConfiguration_->LookupSetOfStrings(allowedHosts, "AllowedHosts", ""); bool https = dicomWebConfiguration_->GetBooleanValue("Ssl", false); std::string forwardedHost, forwardedProto; - if (host.empty() && + if (!hostIsForcedInConfig && LookupHttpHeader2(forwardedHost, headers, "x-forwarded-host") && LookupHttpHeader2(forwardedProto, headers, "x-forwarded-proto")) { @@ -581,7 +582,7 @@ } std::string forwarded; - if (host.empty() && + if (!hostIsForcedInConfig && host.empty() && LookupHttpHeader2(forwarded, headers, "forwarded")) { // There is a "Forwarded" HTTP header in the query @@ -620,7 +621,7 @@ } } - if (host.empty() && + if (!hostIsForcedInConfig && host.empty() && !LookupHttpHeader2(host, headers, "host")) { // Should never happen: The "host" header should always be present @@ -628,7 +629,12 @@ host = "localhost:8042"; } - if (!IsLocalhost(host)) + if (host.empty()) + { + ORTHANC_PLUGINS_THROW_WITH_FILE_AND_LINE_INFO(Orthanc::ErrorCode_InternalError); + } + + if (!IsLocalhost(host) && !hostIsForcedInConfig) // localhost is always trusted as well as any value that is forced in the "Host" configuration { if (allowedHosts.size() == 0) {
