From 61b982607ec7aad96d9753373c388e16d28f3979 Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Wed, 21 Mar 2018 15:03:50 +0100 Subject: [PATCH] Fixing filter generation when no filter file is present in the server --- creolefuncs/lemonldap.py | 32 ++++++++++++++------------------ tmpl/lmConf-1.js | 4 +--- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/creolefuncs/lemonldap.py b/creolefuncs/lemonldap.py index c68c218..b812c7d 100644 --- a/creolefuncs/lemonldap.py +++ b/creolefuncs/lemonldap.py @@ -32,35 +32,31 @@ def getSSOFilters(): """ import glob from ConfigParser import ConfigParser - import json try: - filters = {} + filters = { 'uid': "uid", "mail": "mail" } filterDirectory = "/usr/share/sso/app_filters/" filterExtention = ".ini" filterSection = "utilisateur" filterFiles = glob.glob("{0}/*{1}".format(filterDirectory, filterExtention)) - toClean = ["uid","mail","cn","__name__"] - for fi in filterFiles: - # Don't parse "applications.ini" - config = ConfigParser() - config.read(fi) - if filterSection in config._sections: - filters.update(config._sections[filterSection].items()) - - for key in toClean: - del(filters[key]) - + toClean = [ "__name__" ] + if len(filterFiles) != 0: + for fi in filterFiles: + # Don't parse "applications.ini" + config = ConfigParser() + config.read(fi) + if filterSection in config._sections: + filters.update(config._sections[filterSection].items()) + for key in toClean: + if key in filters.keys(): + del(filters[key]) res = "" index=0 size=len(filters) for k,v in filters.items(): - res += " \"{0}\": \"{1}\",".format(k,v) + res += " \"{0}\": \"{1}\"".format(k,v) index += 1 if index != size: - res += "\n" - + res += ",\n" return(res) - except: return "Error Generating Filters" - diff --git a/tmpl/lmConf-1.js b/tmpl/lmConf-1.js index 1411344..a4371bd 100644 --- a/tmpl/lmConf-1.js +++ b/tmpl/lmConf-1.js @@ -159,12 +159,10 @@ "ldapUsePasswordResetAttribute": 1, "ldapPpolicyControl": 0, "casAttributes": { - "uid":"uid", -%%getSSOFilters %for att in %%casAttribute "%%att": "%%att.casLDAPAttribute", %end for - "mail":"mail" +%%getSSOFilters }, "issuerDBSAMLPath": "^/saml/", "samlAttributeAuthorityDescriptorAttributeServiceSOAP": "urn:oasis:names:tc:SAML:2.0:bindings:SOAP;#PORTAL#/saml/AA/SOAP;",