cmsmanage/member_paperwork/settings/prod_base.py

42 lines
1.0 KiB
Python
Raw Normal View History

2021-03-24 14:33:07 -04:00
import ldap
from django_auth_ldap.config import LDAPSearch, PosixGroupType, LDAPGroupQuery
from .base import *
DEBUG = False
# LDAP Authentication
# https://django-auth-ldap.readthedocs.io/en/latest/
# "AUTH_LDAP_SERVER_URI", "AUTH_LDAP_BIND_DN", and "AUTH_LDAP_BIND_PASSWORD" set in prod.py
AUTHENTICATION_BACKENDS = [
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
]
AUTH_LDAP_USER_SEARCH = LDAPSearch(
'cn=users,dc=sawtooth,dc=claremontmakerspace,dc=org',
ldap.SCOPE_SUBTREE,
'(uid=%(user)s)',
)
AUTH_LDAP_USER_ATTR_MAP = {
'first_name': 'givenName',
'last_name': 'sn',
'email': 'mail',
}
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
"is_staff": LDAPGroupQuery(
"cn=MW_CMS Staff,cn=groups,dc=sawtooth,dc=claremontmakerspace,dc=org"),
}
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
'cn=groups,dc=sawtooth,dc=claremontmakerspace,dc=org',
ldap.SCOPE_SUBTREE,
'(objectClass=posixGroup)',
)
AUTH_LDAP_GROUP_TYPE = PosixGroupType()
AUTH_LDAP_MIRROR_GROUPS = True