Using former eole-sso filters in LemonLDAP

Adding a creolefunc to convert eole-sso filter files into
lemonLDAP casAttrubites section, this way we can keep the
EOLE and Envole existing filters
This commit is contained in:
Philippe Caseiro 2018-03-21 12:17:20 +01:00
parent 8f33de7f55
commit 19fc15c324
2 changed files with 39 additions and 0 deletions

View File

@ -26,3 +26,41 @@ def readPass(encoder,reader):
except: except:
return "mot de passe inconnu" return "mot de passe inconnu"
def getSSOFilters():
""" Convert former eole-sso filters to LemonLDAP filters
"""
import glob
from ConfigParser import ConfigParser
import json
try:
filters = {}
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])
res = ""
index=0
size=len(filters)
for k,v in filters.items():
res += " \"{0}\": \"{1}\",".format(k,v)
index += 1
if index != size:
res += "\n"
return(res)
except:
return "Error Generating Filters"

View File

@ -160,6 +160,7 @@
"ldapPpolicyControl": 0, "ldapPpolicyControl": 0,
"casAttributes": { "casAttributes": {
"uid":"uid", "uid":"uid",
%%getSSOFilters
%for att in %%casAttribute %for att in %%casAttribute
"%%att": "%%att.casLDAPAttribute", "%%att": "%%att.casLDAPAttribute",
%end for %end for