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
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__"]
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"

View File

@ -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;",