Fixing filter generation when no filter file is present in the server

This commit is contained in:
Philippe Caseiro 2018-03-21 15:03:50 +01:00
parent a91abb36f3
commit 61b982607e
2 changed files with 15 additions and 21 deletions

View File

@ -32,35 +32,31 @@ def getSSOFilters():
""" """
import glob import glob
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
import json
try: try:
filters = {} filters = { 'uid': "uid", "mail": "mail" }
filterDirectory = "/usr/share/sso/app_filters/" filterDirectory = "/usr/share/sso/app_filters/"
filterExtention = ".ini" filterExtention = ".ini"
filterSection = "utilisateur" filterSection = "utilisateur"
filterFiles = glob.glob("{0}/*{1}".format(filterDirectory, filterExtention)) filterFiles = glob.glob("{0}/*{1}".format(filterDirectory, filterExtention))
toClean = ["uid","mail","cn","__name__"] toClean = [ "__name__" ]
if len(filterFiles) != 0:
for fi in filterFiles: for fi in filterFiles:
# Don't parse "applications.ini" # Don't parse "applications.ini"
config = ConfigParser() config = ConfigParser()
config.read(fi) config.read(fi)
if filterSection in config._sections: if filterSection in config._sections:
filters.update(config._sections[filterSection].items()) filters.update(config._sections[filterSection].items())
for key in toClean: for key in toClean:
if key in filters.keys():
del(filters[key]) del(filters[key])
res = "" res = ""
index=0 index=0
size=len(filters) size=len(filters)
for k,v in filters.items(): for k,v in filters.items():
res += " \"{0}\": \"{1}\",".format(k,v) res += " \"{0}\": \"{1}\"".format(k,v)
index += 1 index += 1
if index != size: if index != size:
res += "\n" res += ",\n"
return(res) return(res)
except: except:
return "Error Generating Filters" return "Error Generating Filters"

View File

@ -159,12 +159,10 @@
"ldapUsePasswordResetAttribute": 1, "ldapUsePasswordResetAttribute": 1,
"ldapPpolicyControl": 0, "ldapPpolicyControl": 0,
"casAttributes": { "casAttributes": {
"uid":"uid",
%%getSSOFilters
%for att in %%casAttribute %for att in %%casAttribute
"%%att": "%%att.casLDAPAttribute", "%%att": "%%att.casLDAPAttribute",
%end for %end for
"mail":"mail" %%getSSOFilters
}, },
"issuerDBSAMLPath": "^/saml/", "issuerDBSAMLPath": "^/saml/",
"samlAttributeAuthorityDescriptorAttributeServiceSOAP": "urn:oasis:names:tc:SAML:2.0:bindings:SOAP;#PORTAL#/saml/AA/SOAP;", "samlAttributeAuthorityDescriptorAttributeServiceSOAP": "urn:oasis:names:tc:SAML:2.0:bindings:SOAP;#PORTAL#/saml/AA/SOAP;",