Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in / Register
Toggle navigation
Keel - LDH Middleware
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liberty
host
Keel - LDH Middleware
Commits
44336009
Commit
44336009
authored
Jun 09, 2017
by
David Seaward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switch from settings.py to ini-file in /etc/opt/
parent
efd97ba3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
204 additions
and
200 deletions
+204
-200
README.md
README.md
+12
-8
settings.py
purist_account/settings.py
+62
-105
settings_local.txt
purist_account/settings_local.txt
+0
-87
settings_original.py
purist_account/settings_original.py
+130
-0
No files found.
README.md
View file @
44336009
...
...
@@ -33,13 +33,16 @@ Setup
*
Activate virtualenv (
`/opt/purist_account/bin/activate.py`
)
*
Install Python packages (
`pip install -r requirements.txt`
)
*
Complete Django settings
*
Copy
`purist_account/settings_local.txt`
as
`settings_local.py`
*
Create
`/etc/opt/purist_account/config.ini`
and
`/etc/opt/purist_account/secret.ini`
*
Fill in settings values
*
Run
`./manage.py migrate --settings=purist_account.settings_local`
*
Run
`./manage.py createsuperuser --settings=purist_account.settings_local`
*
When prompted, enter the credentials of your LDAP superuser / account manager
*
Run
`./manage.py migrate`
*
Run
`./manage.py createsuperuser`
*
When prompted, enter the credentials of your LDAP superuser /
account manager
*
Hook up Django site to webserver (i.e. Apache HTTPD, Nginx...)
*
Hook up system service (i.e. systemd, supervisord...) to runserver directive (
`manage.py runserver --settings=purist_account.settings_local`
)
*
Hook up system service (i.e. systemd, supervisord...) to runserver
directive (
`manage.py runserver`
)
For more options and details see
<https://docs.djangoproject.com/en/1.11/#the-development-process>
...
...
@@ -54,11 +57,12 @@ If you need to make a new migration:
*
Switch
`LdapGroup.cn`
and
`LdapPerson.uid`
from non-primary to primary
*
Run
`makemigrations`
*
Switch
`LdapGroup.cn`
and
`LdapPerson.uid`
back to non-primary
*
If you have just added a new LDAP table, switch
`NewTable.key`
to non-primary too
*
If you have just added a new LDAP table, switch
`NewTable.key`
to
non-primary too
*
Run
`migrate`
You only need to do this when creating new migrations (
`makemigrations`
)
not when running
existing migrations (
`migrate`
).
You only need to do this when creating new migrations (
`makemigrations`
)
not when running
existing migrations (
`migrate`
).
Usage
-----
...
...
purist_account/settings.py
View file @
44336009
"""
Django settings for purist_account project.
Generated by 'django-admin startproject' using Django 1.11.2.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
Copy this file as settings_local.py
Update with environment settings
Start the site with `python manage.py --settings=settings_local runserver`
FIXME: switch to storing strict yaml in /etc/
"""
import
os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
from
.settings
import
*
# from registration_defaults.settings import *
import
ldap
from
django_auth_ldap.config
import
LDAPSearch
#
Quick-start development settings - unsuitable for production
#
See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
#
#
SECURITY
#
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY
=
'secret'
SECRET_KEY
=
'
local_
secret'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
True
ALLOWED_HOSTS
=
[]
# Application definition
INSTALLED_APPS
=
[
'django.contrib.admin'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
]
MIDDLEWARE
=
[
'django.middleware.security.SecurityMiddleware'
,
'django.contrib.sessions.middleware.SessionMiddleware'
,
'django.middleware.common.CommonMiddleware'
,
'django.middleware.csrf.CsrfViewMiddleware'
,
'django.contrib.auth.middleware.AuthenticationMiddleware'
,
'django.contrib.messages.middleware.MessageMiddleware'
,
'django.middleware.clickjacking.XFrameOptionsMiddleware'
,
]
ROOT_URLCONF
=
'purist_account.urls'
TEMPLATES
=
[
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[],
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
'django.template.context_processors.debug'
,
'django.template.context_processors.request'
,
'django.contrib.auth.context_processors.auth'
,
'django.contrib.messages.context_processors.messages'
,
],
},
},
{
'BACKEND'
:
'django.template.backends.jinja2.Jinja2'
,
'DIRS'
:
[],
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'extensions'
:
[
'jdj_tags.extensions.DjangoCompat'
,
],
},
},
]
DEBUG
=
False
WSGI_APPLICATION
=
'purist_account.wsgi.application'
# Required if DEBUG is False
ALLOWED_HOSTS
=
[
'example.com'
]
#
# REGISTRATION APPLICATION
#
#
Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
#
INSTALLED_APPS = ["registration_defaults", ] + INSTALLED_APPS + ["ldapregister", ]
INSTALLED_APPS
+=
[
"ldapregister"
,
]
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
os
.
path
.
join
(
BASE_DIR
,
'db.sqlite3'
),
}
}
REGISTRATION_OPEN
=
True
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
REG_PERSON_BASE_DN
=
"ou=people,dc=example,dc=com"
REG_PERSON_OBJECT_CLASSES
=
[
'inetOrgPerson'
,
'organizationalPerson'
,
'person'
,
]
AUTH_PASSWORD_VALIDATORS
=
[
{
'NAME'
:
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.MinimumLengthValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.CommonPasswordValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.NumericPasswordValidator'
,
},
]
REG_GROUP_BASE_DN
=
"dc=example,dc=com"
REG_GROUP_OBJECT_CLASSES
=
[
'groupOfNames'
,
]
#
# AUTHENTICATION
#
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
# AUTH_PASSWORD_VALIDATORS = [] # override
LANGUAGE_CODE
=
'en-us'
AUTHENTICATION_BACKENDS
=
(
'django_auth_ldap.backend.LDAPBackend'
,
# 'django.contrib.auth.backends.ModelBackend',
)
TIME_ZONE
=
'UTC'
AUTH_LDAP_SERVER_URI
=
"ldap://ldap.example.com"
AUTH_LDAP_START_TLS
=
True
USE_I18N
=
True
AUTH_LDAP_BIND_DN
=
"cn=application,dc=example,dc=com"
AUTH_LDAP_BIND_PASSWORD
=
"password"
AUTH_LDAP_USER_SEARCH
=
LDAPSearch
(
"dc=example,dc=com"
,
ldap
.
SCOPE_SUBTREE
,
"(uid=
%(user)
s)"
)
# must match `base_dn` and primary key in `ldapregister.models.LdapPerson`
USE_L10N
=
True
AUTH_USER_MODEL
=
'ldapregister.User'
USE_TZ
=
True
#
# DATABASE
#
# See also:
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
# and https://pypi.python.org/pypi/django-ldapdb/
# (re-uses LDAP connection details from authentication settings, you can change this)
DATABASES
=
{
'ldap'
:
{
'ENGINE'
:
'ldapdb.backends.ldap'
,
'NAME'
:
AUTH_LDAP_SERVER_URI
,
'USER'
:
AUTH_LDAP_BIND_DN
,
'PASSWORD'
:
AUTH_LDAP_BIND_PASSWORD
,
'TLS'
:
AUTH_LDAP_START_TLS
,
},
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
os
.
path
.
join
(
BASE_DIR
,
'db.sqlite3'
),
},
}
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
DATABASE_ROUTERS
=
[
'ldapdb.router.Router'
]
STATIC_URL
=
'/static/'
purist_account/settings_local.txt
deleted
100755 → 0
View file @
efd97ba3
"""
Copy this file as settings_local.py
Update with environment settings
Start the site with `python manage.py --settings=settings_local runserver`
FIXME: switch to storing strict yaml in /etc/
"""
from .settings import *
# from registration_defaults.settings import *
import ldap
from django_auth_ldap.config import LDAPSearch
#
# SECURITY
#
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'local_secret'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
# Required if DEBUG is False
ALLOWED_HOSTS = ['example.com']
#
# REGISTRATION APPLICATION
#
# INSTALLED_APPS = ["registration_defaults", ] + INSTALLED_APPS + ["ldapregister", ]
INSTALLED_APPS += ["ldapregister", ]
REGISTRATION_OPEN = True
REG_PERSON_BASE_DN = "ou=people,dc=example,dc=com"
REG_PERSON_OBJECT_CLASSES = ['inetOrgPerson', 'organizationalPerson', 'person', ]
REG_GROUP_BASE_DN = "dc=example,dc=com"
REG_GROUP_OBJECT_CLASSES = ['groupOfNames', ]
#
# AUTHENTICATION
#
# AUTH_PASSWORD_VALIDATORS = [] # override
AUTHENTICATION_BACKENDS = (
'django_auth_ldap.backend.LDAPBackend',
# 'django.contrib.auth.backends.ModelBackend',
)
AUTH_LDAP_SERVER_URI = "ldap://ldap.example.com"
AUTH_LDAP_START_TLS = True
AUTH_LDAP_BIND_DN = "cn=application,dc=example,dc=com"
AUTH_LDAP_BIND_PASSWORD = "password"
AUTH_LDAP_USER_SEARCH = LDAPSearch("dc=example,dc=com", ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
# must match `base_dn` and primary key in `ldapregister.models.LdapPerson`
AUTH_USER_MODEL = 'ldapregister.User'
#
# DATABASE
#
# See also:
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
# and https://pypi.python.org/pypi/django-ldapdb/
# (re-uses LDAP connection details from authentication settings, you can change this)
DATABASES = {
'ldap': {
'ENGINE': 'ldapdb.backends.ldap',
'NAME': AUTH_LDAP_SERVER_URI,
'USER': AUTH_LDAP_BIND_DN,
'PASSWORD': AUTH_LDAP_BIND_PASSWORD,
'TLS': AUTH_LDAP_START_TLS,
},
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
},
}
DATABASE_ROUTERS = ['ldapdb.router.Router']
purist_account/settings_original.py
0 → 100755
View file @
44336009
"""
Django settings for purist_account project.
Generated by 'django-admin startproject' using Django 1.11.2.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import
os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY
=
'secret'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
True
ALLOWED_HOSTS
=
[]
# Application definition
INSTALLED_APPS
=
[
'django.contrib.admin'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
]
MIDDLEWARE
=
[
'django.middleware.security.SecurityMiddleware'
,
'django.contrib.sessions.middleware.SessionMiddleware'
,
'django.middleware.common.CommonMiddleware'
,
'django.middleware.csrf.CsrfViewMiddleware'
,
'django.contrib.auth.middleware.AuthenticationMiddleware'
,
'django.contrib.messages.middleware.MessageMiddleware'
,
'django.middleware.clickjacking.XFrameOptionsMiddleware'
,
]
ROOT_URLCONF
=
'purist_account.urls'
TEMPLATES
=
[
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[],
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
'django.template.context_processors.debug'
,
'django.template.context_processors.request'
,
'django.contrib.auth.context_processors.auth'
,
'django.contrib.messages.context_processors.messages'
,
],
},
},
{
'BACKEND'
:
'django.template.backends.jinja2.Jinja2'
,
'DIRS'
:
[],
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'extensions'
:
[
'jdj_tags.extensions.DjangoCompat'
,
],
},
},
]
WSGI_APPLICATION
=
'purist_account.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
os
.
path
.
join
(
BASE_DIR
,
'db.sqlite3'
),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS
=
[
{
'NAME'
:
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.MinimumLengthValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.CommonPasswordValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.NumericPasswordValidator'
,
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE
=
'en-us'
TIME_ZONE
=
'UTC'
USE_I18N
=
True
USE_L10N
=
True
USE_TZ
=
True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL
=
'/static/'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment