Skip to content

Commit

Permalink
Setup env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Merlin Buczek committed Jun 8, 2019
1 parent 35b5140 commit 222859d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
`pip install -r requirements/production.txt`

## Set environmental variables
Alternatively, variables can be set in a `.env` file in `config/settings`.
For Django related variables see [Django's documentation](https://docs.djangoproject.com/en/dev/ref/settings/).
- `DJANGO_SECRET_KEY`
- `DATABASE_URL`
- `DJANGO_ALLOWED_HOSTS` (List)

### LDAP
See [django-auth-ldap docs](https://django-auth-ldap.readthedocs.io/en/latest/authentication.html#server-config).
- `LDAP_SERVER_URI`
- `LDAP_USER_DN`
- `LDAP_USER_PASSWORD`

## Run database migrations
- `python manage.py migrate --no-input`. See [Django docs](https://docs.djangoproject.com/en/2.2/ref/django-admin/#django-admin-migrate).
Expand Down
3 changes: 3 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

env = environ.Env()

# Read .env file
environ.Env.read_env()

# GENERAL
# ------------------------------------------------------------------------------
DEBUG = env.bool('DJANGO_DEBUG', False)
Expand Down
10 changes: 7 additions & 3 deletions config/settings/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@

AUTH_LDAP_SERVER_URI = env('LDAP_URI')

LDAP_USER_NAMES = env('LDAP_USER_NAMES', default="dc=user,dc=apps,dc=molgen,dc=mpg,dc=DE")

AUTH_LDAP_CONNECTION_OPTIONS = {
ldap.OPT_X_TLS_REQUIRE_CERT: ldap.OPT_X_TLS_NEVER
}

AUTH_LDAP_BIND_DN = env('LDAP_USER_DN')
AUTH_LDAP_BIND_DN = env('LDAP_USER_DN', default="cn=mpicms,dc=ldap,dc=apps,dc=molgen,dc=mpg,dc=DE")
AUTH_LDAP_BIND_PASSWORD = env('LDAP_USER_PASSWORD')
AUTH_LDAP_USER_SEARCH = LDAPSearch(
env('LDAP_USER_NAMES'), ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
LDAP_USER_NAMES,
ldap.SCOPE_SUBTREE,
"(uid=%(user)s)")


AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s," + env('LDAP_USER_NAMES')
AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s," + LDAP_USER_NAMES

AUTH_LDAP_FIND_GROUP_PERMS = False
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
Expand Down

0 comments on commit 222859d

Please sign in to comment.