Przeglądaj źródła

HPCC-17998 Ensure dali session tree for ESP using old env xml

We want to make sure that ESP is running in session management
even if old environment.xml is used. ESP should create the session
tree in dali for that situation.

Also should not setup dali session tree for an ESP binding if no
session authentication is required for that binding.

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 8 lat temu
rodzic
commit
3b494959f9

+ 5 - 2
esp/bindings/http/platform/httpbinding.cpp

@@ -280,10 +280,13 @@ EspHttpBinding::EspHttpBinding(IPropertyTree* tree, const char *bindname, const
     else
         domainName.set("default");
 
-    setSDSSession();
     readAuthDomainCfg(proc_cfg);
 
-    checkSessionTimeoutSeconds = proc_cfg->getPropInt("@checkSessionTimeoutSeconds", ESP_CHECK_SESSION_TIMEOUT);
+    if ((domainAuthType == AuthPerSessionOnly) || (domainAuthType == AuthTypeMixed))
+    {
+        setSDSSession();
+        checkSessionTimeoutSeconds = proc_cfg->getPropInt("@checkSessionTimeoutSeconds", ESP_CHECK_SESSION_TIMEOUT);
+    }
 }
 
 void EspHttpBinding::setSDSSession()

+ 9 - 3
esp/platform/espcfg.cpp

@@ -113,26 +113,32 @@ StringBuffer &CVSBuildToEspVersion(char const * tag, StringBuffer & out)
 
 void CEspConfig::ensureSDSSessionDomains()
 {
+    bool hasAuthDomainSettings = false;
+    bool hasSessionAuth = false;
     bool hasDefaultSessionDomain = false;
     Owned<IPropertyTree> proc_cfg = getProcessConfig(m_envpt, m_process.str());
     Owned<IPropertyTreeIterator> it = proc_cfg->getElements("AuthDomains/AuthDomain");
     ForEach(*it)
     {
+        hasAuthDomainSettings = true;
         IPropertyTree& authDomain = it->query();
         const char* authType = authDomain.queryProp("@authType");
         if (isEmptyString(authType) || (!strieq(authType, "AuthPerSessionOnly") && !strieq(authType, "AuthTypeMixed")))
             continue;
 
+        hasSessionAuth = true;
         const char* authDomainName = authDomain.queryProp("@name");
-        if (isEmptyString(authDomainName))
+        if (isEmptyString(authDomainName) || strieq(authDomainName, "default"))
         {
             if (hasDefaultSessionDomain)
                 throw MakeStringException(-1, ">1 AuthDomains are not named.");
 
             hasDefaultSessionDomain = true;
-            authDomainName = "default";
         }
-
+    }
+    //Ensure SDS Session tree if there is session auth or there is no AuthDomain setting (ex. old environment.xml)
+    if (hasSessionAuth || !hasAuthDomainSettings)
+    {
         Owned<IRemoteConnection> conn = querySDS().connect(PathSessionRoot, myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, SESSION_SDS_LOCK_TIMEOUT);
         if (!conn)
             throw MakeStringException(-1, "Failed to connect to %s.", PathSessionRoot);