secret-squirrel/settings.py

176 строки
5.0 KiB
Python

# -*- coding: utf-8 -*-
# Django settings for the secret_squirrel project.
import os
import logging
# Make filepaths relative to settings.
ROOT = os.path.dirname(os.path.abspath(__file__))
path = lambda *a: os.path.join(ROOT, *a)
ROOT_PACKAGE = os.path.basename(ROOT)
DEBUG = True
TEMPLATE_DEBUG = DEBUG
LOG_LEVEL = logging.DEBUG
SYSLOG_TAG = "http_app_sso"
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'squirrel',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
'OPTIONS': {'init_command': 'SET storage_engine=InnoDB'},
'TEST_CHARSET': 'utf8',
'TEST_COLLATION': 'utf8_general_ci',
}
}
DATABASE_ROUTERS = ('multidb.MasterSlaveRouter',)
# Put the aliases for your slave databases in this list
SLAVE_DATABASES = []
# Cache Settings
#CACHE_BACKEND = 'caching.backends.memcached://localhost:11211'
#CACHE_PREFIX = 'sumo:'
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Los_Angeles'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = path('media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/admin-media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'bi)(czxyf#e68_bg4lvx!7o*v&ggnz*@()w$z-0injzc#0&)l_'
# Templates
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.media',
'django.core.context_processors.request',
'django.core.context_processors.csrf',
'sso.context_processors.now',
)
TEMPLATE_DIRS = (
path('templates'),
)
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
def JINJA_CONFIG():
import jinja2
# TODO replace 'jinja2.ext.i18n' with 'tower.template.i18n' when we're
# actually doing L10n.
config = {'extensions': ['jinja2.ext.i18n', 'jinja2.ext.loopcontrols',
'jinja2.ext.with_'],
'finalize': lambda x: x if x is not None else ''}
return config
MIDDLEWARE_CLASSES = (
'commonware.middleware.SetRemoteAddrFromForwardedFor', # First, so all others see the right IP
'sso.middleware.HttpOnlyMiddleware', # needs to be before AuthMiddleware
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'paranoidsessions.ParanoidSessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'commonware.middleware.FrameOptionsHeader',
)
ROOT_URLCONF = '%s.urls' % ROOT_PACKAGE
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'cas_provider',
'sso',
'users',
)
AUTHENTICATION_BACKENDS = ('users.auth.Sha256Backend',)
AUTH_PROFILE_MODULE = 'users.UserProfile'
# Tests
TEST_RUNNER = 'test_utils.runner.RadicalTestSuiteRunner'
# Security settings
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
# Default to 1 week expiration
SESSION_COOKIE_AGE = 7 * 24 * 60 * 60
SESSION_COOKIE_SECURE = True
# Cookie names that should NOT have the HttpOnly flag set.
JAVASCRIPT_READABLE_COOKIES = ()
# CAS Service ticket expiration, in seconds, 0 means no expiration.
SERVICE_TICKET_TIMEOUT = 30
# django-paranoid-sessions settings
PSESSION_CHECK_HEADERS = ('REMOTE_ADDR',) # Check remote IP address
PSESSION_NONCE_TIMEOUT = None # No nonce cookies for now
# Emails
DEFAULT_FROM_EMAIL = 'nobody@mozilla.org'
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# Auth
LOGIN_URL = '/users/login/'
LOGOUT_URL = '/users/logout/'
LOGIN_REDIRECT_URL = '/'
ACCOUNT_ACTIVATION_DAYS = 7