remove hard dependency on python-ldap

This commit is contained in:
Benjamin Dauvergne 2013-08-15 14:57:28 +02:00
parent 380072acc8
commit c41d5ab558
2 changed files with 21 additions and 18 deletions

View File

@ -47,7 +47,6 @@ __ENVIRONMENT_DEFAULTS = dict(
LOGIN_REDIRECT_URL='/inbox',
MESSAGE_STORAGE='django.contrib.messages.storage.fallback.FallbackStorage',
AUTHENTICATION_BACKENDS=(
'django_auth_ldap.backend.LDAPBackend',
'docbow_project.docbow.auth_backend.DelegationAuthBackend',
'django.contrib.auth.backends.ModelBackend' ),
AUTH_LDAP_SERVER_URI='ldaps://ldap.libre-entreprise.org:636',
@ -222,23 +221,28 @@ if DEBUG:
logger['handlers'].append('console')
# LDAP backend configuration
import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfUniqueNamesType
try:
import ldap
except ImportError:
pass
else:
from django_auth_ldap.config import LDAPSearch, GroupOfUniqueNamesType
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=people,o=entrouvert,ou=companies,o=libre-entreprise",
ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
AUTH_LDAP_GROUP_TYPE = GroupOfUniqueNamesType()
AUTH_LDAP_GROUP_SEARCH = LDAPSearch("o=libre-entreprise",
ldap.SCOPE_SUBTREE, "(objectClass=legroup)")
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
"is_staff": "cn=ldapadmins,ou=groups,o=entrouvert,ou=companies,o=libre-entreprise",
"is_superuser": "cn=ldapadmins,ou=groups,o=entrouvert,ou=companies,o=libre-entreprise",
}
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail"
}
AUTHENTICATION_BACKENDS = ('django_auth_ldap.backend.LDAPBackend',) + AUTHENTICATION_BACKENDS
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=people,o=entrouvert,ou=companies,o=libre-entreprise",
ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
AUTH_LDAP_GROUP_TYPE = GroupOfUniqueNamesType()
AUTH_LDAP_GROUP_SEARCH = LDAPSearch("o=libre-entreprise",
ldap.SCOPE_SUBTREE, "(objectClass=legroup)")
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
"is_staff": "cn=ldapadmins,ou=groups,o=entrouvert,ou=companies,o=libre-entreprise",
"is_superuser": "cn=ldapadmins,ou=groups,o=entrouvert,ou=companies,o=libre-entreprise",
}
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail"
}
try:
from local_settings import *

View File

@ -5,7 +5,6 @@ django-grappelli<2.5.0
django-tinymce<1.6.0
django-crispy-forms>=1.3,<1.4
django-auth-ldap<1.1
python-ldap<3.0.0
BeautifulSoup<3.3.0
M2Crypto<1.0.0
pyasn1<1.0.0