Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing unicode parameters to LDAP library #168

Open
stephane-martin opened this issue Aug 8, 2016 · 8 comments
Open

Passing unicode parameters to LDAP library #168

stephane-martin opened this issue Aug 8, 2016 · 8 comments

Comments

@stephane-martin
Copy link
Contributor

Hello,

the LDAP parameters come from a JSON file, so in python 2 they are parsed as "unicode" strings. The LDAP library that realms use for LDAP auth does not accept unicode for parameter names :(

Please see: ContinuumIO/flask-ldap-login#26

@theodotos
Copy link

Hi, same here.

I applied the patch suggested above. Now I get "Invalid LDAP Credentials" and "Form Invalid":

screenshot from 2016-09-21 08-14-15

@stephane-martin
Copy link
Contributor Author

Probably means that your LDAP configuration is not working.

Which version of realms-wiki are you using?
Can you post your realms-wiki config file ? (masking passwords of course)

@theodotos
Copy link

theodotos commented Sep 21, 2016

I have verified my LDAP setup using ldapsearch:

ldapsearch -ZZ -x -D cn=realms,ou=dsa,dc=example,dc=com -W -b "ou=people,dc=example,dc=com" -H ldap://ldap.example.com

It works and returns all the objects in "ou=people,dc=example,dc=com"

Using the same credential in realms-wiki.json:

root@wiki-test:~# cat /etc/realms-wiki/realms-wiki.json 
{
    "ALLOW_ANON": false,
    "BASE_URL": "http://wiki-test.example.com
    "DB_URI": "sqlite:////var/lib/realms/db/wiki.db",
    "PORT": 5000,
    "REGISTRATION_ENABLED": true,
    "SEARCH_TYPE": "simple",
    "SECRET_KEY": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "SITE_TITLE": "Example Wiki",
    "WIKI_PATH": "/var/lib/realms/data",

    "LDAP": {
        "URI": "ldap://ldap.example.com:389",
        "BIND_DN": "cn=realms,ou=dsa,dc=example,dc=com",
        "BIND_AUTH": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "START_TLS": true,
        "KEY_MAP": {
            "username": "uid",
            "email": "mail"},
        "OPTIONS": {
            "OPT_PROTOCOL_VERSION": 3}
    }
}

I have verified my credentials on other ldap services and they are correct. I have tried both the username and the complete email address as the login but no luck.

@stephane-martin
Copy link
Contributor Author

  • it looks like you're trying to do "bind search" method

see https://github.com/ContinuumIO/flask-ldap-login/blob/master/examples/bind_search.py

but there is no 'USER_SEARCH' option to tell the ldap client where to find the users.

maybe 'USER_SEARCH': {'base': 'ou=people,dc=example,dc=com', 'filter': 'uid=%(username)s'}

  • START_TLS is always tricky, as different python versions have different behaviour for the certificate validation.

@theodotos
Copy link

A million thanks @stephane-martin! LDAP is working fine now. STARTTLS too.

But now the editor broke :(

I will use the relevant issue (#169) for that.

@stephane-martin
Copy link
Contributor Author

yes it's better to expose realms at the root of the domain, some things break when you try to install in /somesubdir

@stephane-martin
Copy link
Contributor Author

by the way i have a current pull request to get rid of flask-ldap-login, so that LDAP authentication becomes python3 compatible. expect LDAP configuration to change a bit in future versions.

@theodotos
Copy link

That would be great! I spent endless hours trying to figure out what's going on and this will ease the pain in future deployments :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants