Configuration

This section describes any settings which are specific to lookupproxy

Specifying the database

The default settings.py file contains a facility to configure the database by means of environment variables. A variable with a name of the form DJANGO_DB_<key> will be used to set the DATABASES['default'][<key>] setting. So, for example, one could set the location of the sqlite database by setting the DJANGO_DB_NAME environment variable or one could change the backend by setting DJANGO_DB_BACKEND.

Default settings

The default settings are given in the lookupproxy.settings.base module:

lookupproxy.settings.base.BASE_DIR = '/home/travis/build/uisautomation/lookupproxy'

Base directory containing the project. Build paths inside the project via os.path.join(BASE_DIR, ...).

lookupproxy.settings.base.SECRET_KEY = 'ex561uglj%!8oh*umt3-@2-4yj*&dc8cznob*vmb0!9bryoc-$'

The Django secret key is by default set from the environment. If omitted, a system check will complain.

lookupproxy.settings.base.DEBUG = True

SECURITY WARNING: don’t run with debug turned on in production!

lookupproxy.settings.base.ALLOWED_HOSTS = []

By default, no hosts are allowed.

lookupproxy.settings.base.INSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'corsheaders', 'ucamwebauth', 'automationcommon', 'automationlookup', 'rest_framework', 'drf_yasg', 'lookupapi']

Installed applications

lookupproxy.settings.base.MIDDLEWARE = ['corsheaders.middleware.CorsMiddleware', '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']

Installed middleware

lookupproxy.settings.base.ROOT_URLCONF = 'lookupproxy.urls'

Root URL patterns

lookupproxy.settings.base.TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['/home/travis/build/uisautomation/lookupproxy/templates'], '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']}}]

Template loading

lookupproxy.settings.base.WSGI_APPLICATION = 'lookupproxy.wsgi.application'

WSGI

lookupproxy.settings.base.DATABASES = {'default': {'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_MAX_AGE': 0, 'ENGINE': 'django.db.backends.postgresql', 'HOST': 'localhost', 'NAME': 'postgres', 'OPTIONS': {}, 'PASSWORD': 'mysecret', 'PORT': '', 'TEST': {'CHARSET': None, 'COLLATION': None, 'MIRROR': None, 'NAME': None}, 'TIME_ZONE': None, 'USER': 'postgres'}}

Database configuration. The default settings allow configuration of the database from environment variables. An environment variable named DJANGO_DB_<key> will override the DATABASES['default'][<key>] setting.

lookupproxy.settings.base.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'}]

Password validation

lookupproxy.settings.base.LANGUAGE_CODE = 'en-gb'

Internationalization

lookupproxy.settings.base.TIME_ZONE = 'UTC'

Internationalization

lookupproxy.settings.base.USE_I18N = True

Internationalization

lookupproxy.settings.base.USE_L10N = True

Internationalization

lookupproxy.settings.base.USE_TZ = True

Internationalization

lookupproxy.settings.base.STATIC_URL = '/static/'

Static files (CSS, JavaScript, Images)

lookupproxy.settings.base.AUTHENTICATION_BACKENDS = ['ucamwebauth.backends.RavenAuthBackend', 'django.contrib.auth.backends.ModelBackend']

Authentication backends

lookupproxy.settings.base.CORS_ORIGIN_ALLOW_ALL = True

By default, whitelist all origins for CORS

lookupproxy.settings.base.UCAMWEBAUTH_CREATE_USER = True

Allow the autocreation of users who have been successfully authenticated by Raven but do not exist in the local database.

lookupproxy.settings.base.UCAMWEBAUTH_LOGOUT_REDIRECT = 'https://raven.cam.ac.uk/auth/logout.html'

Redirect to this URL on log out

lookupproxy.settings.base.UCAMWEBAUTH_NOT_CURRENT = False

Allow members who are not current members to log in?

lookupproxy.settings.base.SWAGGER_SETTINGS = {'DEFAULT_AUTO_SCHEMA_CLASS': 'lookupapi.inspectors.SwaggerAutoSchema', 'SECURITY_DEFINITIONS': {'oauth2': {'authorizationUrl': 'http://oauth2.example.com/oauth2/auth', 'description': 'OAuth2 Bearer Token', 'flow': 'implicit', 'scopes': {'lookup:anonymous': 'Anonymous Lookup Access'}, 'type': 'oauth2'}}, 'USE_SESSION_AUTH': False}

Swagger UI settings