ContinuumIO / flask-ldap-login

Flask ldap integration
BSD 2-Clause "Simplified" License
105 stars 35 forks source link

unicode/str #26

Open stephane-martin opened 8 years ago

stephane-martin commented 8 years ago

hello,

in method connect():

for opt, value in self.config.get('OPTIONS', {}).items():
    if isinstance(opt, str):
        opt = getattr(ldap, opt)
    try:
        if isinstance(value, str):
            value = getattr(ldap, value)
    except AttributeError:
        pass

in python2, the checks vs 'str' are not very robust. the caller could pass a unicode string like u"OPT_PROTOCOL_VERSION". In current code this would trigger an uncaught exception (because python-ldap only accepts integers)

(I faced this issue with a wiki - realms on github. Pretty hard to trace back to LDAP as of course the only symptom was a 500 HTTP error. In the realms wiki the parameters come from a JSON file, that's of course parsed to unicode)