Commit d8abbb85 authored by Joachim Kołodziejski's avatar Joachim Kołodziejski
Browse files

Document options in sample.env, add LDAP_TIMEOUT to connection too

parent fcf63541
Loading
Loading
Loading
Loading
+56 −13
Changes for sample.env: 56 added lines, 13 removed lines.
Original line number Diff line number Diff line
EMAIL_URL="smtp+tls://wybory:changeme@smtp.example.com:587"
# EMAIL_TIMEOUT="20"
# WARNING: non-commented options are required, change them.

# SMTP server URL (see django-environ environ.Env.email_url())
EMAIL_URL="smtp+tls://wybory:password@smtp.example.com:587"

# Email From header (see Django settings DEFAULT_FROM_EMAIL)
DEFAULT_FROM_EMAIL="Wybory <wybory@example.com>"

# SMTP blocking operations timeout (see Django settings EMAIL_TIMEOUT)
#EMAIL_TIMEOUT="20"

# Number of emails to send in one batch (connection)
#EMAIL_BATCH_SIZE="20"
SITE_URL="http://localhost:8000"
# SECRET_KEY="changeme"

# Public (user-facing) site URL
SITE_URL="https://wybory.example.com"

# Django secret key (see Django settings SECRET_KEY)
SECRET_KEY=

# Set to false in production (see Django settings DEBUG)
#DEBUG="false"
# ALLOWED_HOSTS="localhost"
# RQ_URL="redis://localhost:6379/0"

# Comma-separated allowed hosts list (see Django settings ALLOWED_KEYS)
ALLOWED_HOSTS="localhost,wybory.example.com"

# Redis instance URL (see django-rq RQ_QUEUES)
RQ_URL="redis://localhost:6379/0"

# Timezone in IANA notation (see Django settings TIME_ZONE)
#TIME_ZONE="Etc/UTC"
# DATABASE_URL="sqlite:///db.sqlite3"
# SCHOOL_YEAR_MONTH=9
# SCHOOL_YEAR_DAY=1

# Database URL (see dj-database-url)
DATABASE_URL="postgres://wybory:password@localhost:5432/wybory"

# First day of the school year
#SCHOOL_YEAR_MONTH="9"
#SCHOOL_YEAR_DAY="1"

# LDAP server
LDAP_HOST="ldap.example.com"
# LDAP_PORT=389

# LDAP port
#LDAP_PORT="389"

# Use TLS for LDAP
#LDAP_TLS=false

# CA certificate file to trust when using LDAP over TLS, by default the system cert store is used
#LDAP_CA_CERTS_FILE=
LDAP_BIND_DN="cn=myuser,ou=mygroup,ou=users,dc=ldap,dc=example,dc=com"
LDAP_BIND_PASSWORD="myuserpassword"

# LDAP bind DN
LDAP_BIND_DN="cn=wybory,ou=users,dc=ldap,dc=example,dc=com"

# LDAP bind password
LDAP_BIND_PASSWORD="password"

# LDAP connection and search timeout
#LDAP_TIMEOUT="30"
LDAP_GROUP_SEARCH_BASE_TEMPLATE="ou=%(group)s,ou=users,dc=ad,dc=staszic,dc=waw,dc=pl"

# LDAP search base and filter templates when searching for voters, use %(group)s as the voter group placeholder
LDAP_GROUP_SEARCH_BASE_TEMPLATE="ou=%(group)s,ou=users,dc=ldap,dc=example,dc=com"
LDAP_GROUP_FILTER_TEMPLATE="(&(objectClass=posixAccount)(memberOf=cn=%(group)s,ou=users,dc=ldap,dc=example,dc=com))"

# LDAP field names for voter name and email
LDAP_NAME_FIELD="displayName"
LDAP_EMAIL_FIELD="mail"
+1 −0
Changes for voters/ldap.py: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ def query(groups: list[str]) -> dict[str, list[dict[str, str]] | None]:
        else ldap3.AUTO_BIND_NO_TLS,
        client_strategy=ldap3.SAFE_SYNC,
        raise_exceptions=True,
        receive_timeout=settings.LDAP_TIMEOUT,
    ) as conn:
        for group in set(groups):
            try: