changeset 2790:c7313e1f7644

MongooseServer::SetRealm()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 26 Jul 2018 20:43:03 +0200
parents 2a4ac74da1ed
children d015fa861e3c
files Core/HttpServer/MongooseServer.cpp Core/HttpServer/MongooseServer.h
diffstat 2 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Core/HttpServer/MongooseServer.cpp	Thu Jul 26 14:02:20 2018 +0200
+++ b/Core/HttpServer/MongooseServer.cpp	Thu Jul 26 20:43:03 2018 +0200
@@ -611,7 +611,7 @@
     if (!server.IsRemoteAccessAllowed() &&
         !localhost)
     {
-      output.SendUnauthorized(ORTHANC_REALM);
+      output.SendUnauthorized(server.GetRealm());
       return;
     }
 
@@ -655,7 +655,7 @@
     if (server.IsAuthenticationEnabled() && 
         !IsAccessGranted(server, headers))
     {
-      output.SendUnauthorized(ORTHANC_REALM);
+      output.SendUnauthorized(server.GetRealm());
       return;
     }
 
@@ -682,7 +682,7 @@
       if (!filter->IsAllowed(method, request->uri, remoteIp,
                              username.c_str(), headers, argumentsGET))
       {
-        //output.SendUnauthorized(ORTHANC_REALM);
+        //output.SendUnauthorized(server.GetRealm());
         output.SendStatus(HttpStatus_403_Forbidden);
         return;
       }
@@ -917,6 +917,7 @@
     keepAlive_ = false;
     httpCompression_ = true;
     exceptionFormatter_ = NULL;
+    realm_ = ORTHANC_REALM;
 
 #if ORTHANC_ENABLE_SSL == 1
     // Check for the Heartbleed exploit
--- a/Core/HttpServer/MongooseServer.h	Thu Jul 26 14:02:20 2018 +0200
+++ b/Core/HttpServer/MongooseServer.h	Thu Jul 26 20:43:03 2018 +0200
@@ -96,6 +96,7 @@
     bool keepAlive_;
     bool httpCompression_;
     IHttpExceptionFormatter* exceptionFormatter_;
+    std::string realm_;
   
     bool IsRunning() const;
 
@@ -188,5 +189,15 @@
     {
       return exceptionFormatter_;
     }
+
+    const std::string& GetRealm() const
+    {
+      return realm_;
+    }
+
+    void SetRealm(const std::string& realm)
+    {
+      realm_ = realm;
+    }
   };
 }