changeset 6221:67dbb5004469

clarifying forbidden vs. unauthorized in class HttpServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 07 Jul 2025 16:49:22 +0200
parents 49991d8aef82
children da6430b05c8d 1c03790d9ff6
files OrthancFramework/Sources/HttpServer/HttpServer.cpp OrthancFramework/Sources/HttpServer/HttpServer.h
diffstat 2 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/HttpServer/HttpServer.cpp	Mon Jul 07 16:37:32 2025 +0200
+++ b/OrthancFramework/Sources/HttpServer/HttpServer.cpp	Mon Jul 07 16:49:22 2025 +0200
@@ -621,7 +621,7 @@
   
   enum AccessMode
   {
-    AccessMode_Forbidden,
+    AccessMode_NotAuthenticated,
     AccessMode_AuthorizationToken,
     AccessMode_RegisteredUser
   };
@@ -657,7 +657,7 @@
       }
     }
 
-    return AccessMode_Forbidden;
+    return AccessMode_NotAuthenticated;
   }
 
 
@@ -1241,9 +1241,9 @@
 
     // Authenticate this connection
     if (server.IsAuthenticationEnabled() &&
-        accessMode == AccessMode_Forbidden)
+        accessMode == AccessMode_NotAuthenticated)
     {
-      if (server.IsRedirectForbiddenToRoot() &&
+      if (server.IsRedirectNotAuthenticatedToRoot() &&
           uri.size() > 0)
       {
         // This is new in Orthanc 1.12.9
@@ -1326,7 +1326,7 @@
       // filter. In the case of an authorization bearer token, grant
       // full access to the API.
 
-      assert(accessMode == AccessMode_Forbidden ||  // Could be the case if "!server.IsAuthenticationEnabled()"
+      assert(accessMode == AccessMode_NotAuthenticated ||  // Could be the case if "!server.IsAuthenticationEnabled()"
              accessMode == AccessMode_RegisteredUser);
       
       IIncomingHttpRequestFilter *filter = server.GetIncomingHttpRequestFilter();
@@ -1628,7 +1628,7 @@
     threadsCount_(50),  // Default value in mongoose/civetweb
     tcpNoDelay_(true),
     requestTimeout_(30),  // Default value in mongoose/civetweb (30 seconds)
-    redirectForbiddenToRoot_(false)
+    redirectNotAuthenticatedToRoot_(false)
   {
 #if ORTHANC_ENABLE_MONGOOSE == 1
     CLOG(INFO, HTTP) << "This Orthanc server uses Mongoose as its embedded HTTP server";
@@ -2233,15 +2233,15 @@
 #endif
 
 
-  bool HttpServer::IsRedirectForbiddenToRoot() const
+  bool HttpServer::IsRedirectNotAuthenticatedToRoot() const
   {
-    return redirectForbiddenToRoot_;
+    return redirectNotAuthenticatedToRoot_;
   }
 
 
-  void HttpServer::SetRedirectForbiddenToRoot(bool redirect)
+  void HttpServer::SetRedirectNotAuthenticatedToRoot(bool redirect)
   {
     Stop();
-    redirectForbiddenToRoot_ = redirect;
+    redirectNotAuthenticatedToRoot_ = redirect;
   }
 }
--- a/OrthancFramework/Sources/HttpServer/HttpServer.h	Mon Jul 07 16:37:32 2025 +0200
+++ b/OrthancFramework/Sources/HttpServer/HttpServer.h	Mon Jul 07 16:49:22 2025 +0200
@@ -114,7 +114,7 @@
     unsigned int threadsCount_;
     bool tcpNoDelay_;
     unsigned int requestTimeout_;  // In seconds
-    bool redirectForbiddenToRoot_;  // New in Orthanc 1.12.9
+    bool redirectNotAuthenticatedToRoot_;  // New in Orthanc 1.12.9
 
 #if ORTHANC_ENABLE_PUGIXML == 1
     WebDavBuckets webDavBuckets_;
@@ -228,8 +228,8 @@
                                   const std::string& body,
                                   const std::string& boundary);
 
-    bool IsRedirectForbiddenToRoot() const;
+    bool IsRedirectNotAuthenticatedToRoot() const;
 
-    void SetRedirectForbiddenToRoot(bool redirect);
+    void SetRedirectNotAuthenticatedToRoot(bool redirect);
   };
 }