Преглед изворни кода

Merge pull request #10621 from RussWhitehead/htFeature

HPCC-18688 HTPasswd security manager feature support incomplete

Reviewed-By: Kevin Wang <kevin.wang@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman пре 7 година
родитељ
комит
206d979239

+ 1 - 0
esp/bindings/http/platform/httpbinding.cpp

@@ -199,6 +199,7 @@ EspHttpBinding::EspHttpBinding(IPropertyTree* tree, const char *bindname, const
                     //This is a Pluggable Security Manager
                     m_secmgr.setown(SecLoader::loadPluggableSecManager(bindname, bnd_cfg, secMgrCfg));
                     m_authmap.setown(m_secmgr->createAuthMap(authcfg));
+                    m_feature_authmap.setown(m_secmgr->createFeatureMap(authcfg));
                 }
                 else
                 {

+ 36 - 0
system/security/plugins/htpasswdSecurity/htpasswdSecurity.cpp

@@ -112,6 +112,42 @@ public:
 		return authmap;
 	}
 
+    IAuthMap * createFeatureMap(IPropertyTree * authconfig)
+    {
+        CAuthMap* feature_authmap = new CAuthMap(this);
+
+        Owned<IPropertyTreeIterator> feature_iter;
+        feature_iter.setown(authconfig->getElements(".//Feature"));
+        ForEach(*feature_iter)
+        {
+            IPropertyTree *feature = NULL;
+            feature = &feature_iter->query();
+            if (feature)
+            {
+                StringBuffer pathstr, rstr, required, description;
+                feature->getProp("@path", pathstr);
+                feature->getProp("@resource", rstr);
+                feature->getProp("@required", required);
+                feature->getProp("@description", description);
+                ISecResourceList* rlist = feature_authmap->queryResourceList(pathstr.str());
+                if(rlist == NULL)
+                {
+                    rlist = createResourceList(pathstr.str());
+                    feature_authmap->add(pathstr.str(), rlist);
+                }
+                if (!rstr.isEmpty())
+                {
+                    ISecResource* rs = rlist->addResource(rstr.str());
+                    SecAccessFlags requiredaccess = str2perm(required.str());
+                    rs->setRequiredAccessFlags(requiredaccess);
+                    rs->setDescription(description.str());
+                    rs->setAccessFlags(SecAccess_Full);//grant full access to authenticated users
+                }
+            }
+        }
+
+        return feature_authmap;
+    }
 protected:
 
     //ISecManager