2
2
from __future__ import unicode_literals
3
3
import os
4
4
from .settings_base import *
5
+ from .django_ldap_extension import *
5
6
6
7
DEBUG = TEMPLATE_DEBUG = False
7
8
@@ -43,9 +44,9 @@ EMAIL_HOST = '{{ domain }}'
43
44
EMAIL_HOST_USER = '{{ app }}@{{ domain }}'
44
45
EMAIL_HOST_PASSWORD = '{{ mail_pwd }}'
45
46
46
- # Tous acces
47
+ # LDAP authentication and group management
47
48
import ldap
48
- from django_auth_ldap.config import LDAPSearch, MemberDNGroupType
49
+ from django_auth_ldap.config import LDAPSearch, LDAPSearchUnion, MemberDNGroupType, LDAPGroupType
49
50
AUTHENTICATION_BACKENDS = (
50
51
'django_auth_ldap.backend.LDAPBackend',
51
52
'django.contrib.auth.backends.ModelBackend',
@@ -63,13 +64,20 @@ AUTH_LDAP_USER_FLAGS_BY_GROUP = {
63
64
"is_staff": "cn={{ app }}.staff,ou=permission,dc=yunohost,dc=org",
64
65
"is_superuser": "cn={{ app }}.superadmin,ou=permission,dc=yunohost,dc=org"
65
66
}
66
- AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=permission,dc=yunohost,dc=org", ldap.SCOPE_SUBTREE)
67
- AUTH_LDAP_GROUP_TYPE = MemberDNGroupType("inheritPermission", "permissionYnh")
67
+ AUTH_LDAP_GROUP_SEARCH = LDAPSearchUnion(
68
+ LDAPSearch("ou=permission,dc=yunohost,dc=org", ldap.SCOPE_SUBTREE, filterstr=u'(cn=coin.*)'),
69
+ LDAPSearch("ou=groups,dc=yunohost,dc=org", ldap.SCOPE_SUBTREE)
70
+ )
71
+ AUTH_LDAP_GROUP_TYPE = MemberDNGroupTypeUnion(
72
+ MemberDNGroupType("inheritPermission"), # permissionYnh
73
+ MemberDNGroupType("member")) # groupOfNamesYnh
68
74
AUTH_LDAP_ALWAYS_UPDATE_USER = True
69
75
AUTH_LDAP_AUTHORIZE_ALL_USERS = False
70
76
AUTH_LDAP_FIND_GROUP_PERMS = True
71
77
AUTH_LDAP_CACHE_GROUPS = True
72
78
AUTH_LDAP_GROUP_CACHE_TIMEOUT = 1000
79
+ # Link Yunohost group with django permission group
80
+ AUTH_LDAP_MIRROR_GROUPS_EXCEPT = ("{{ app }}.main", "{{ app }}.staff", "{{ app }}.superadmin")
73
81
# import logging
74
82
# logger = logging.getLogger('django_auth_ldap')
75
83
# logger.addHandler(logging.StreamHandler())
0 commit comments