aws.py 2.78 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
"""
This is the default template for our main set of AWS servers. This does NOT
cover the content machines, which use content.py

Common traits:
* Use memcached, and cache-backed sessions
* Use a MySQL 5.1 database
"""
import json

11 12
from .logsettings import get_logger_config
from .common import *
13

14 15 16 17
############################### ALWAYS THE SAME ################################
DEBUG = False
TEMPLATE_DEBUG = False

18 19 20 21
EMAIL_BACKEND = 'django_ses.SESBackend'
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

22 23 24 25
# Disable askbot, enable Berkeley forums
MITX_FEATURES['ENABLE_DISCUSSION'] = False
MITX_FEATURES['ENABLE_DISCUSSION_SERVICE'] = True

26 27 28 29 30 31
# IMPORTANT: With this enabled, the server must always be behind a proxy that 
# strips the header HTTP_X_FORWARDED_PROTO from client requests. Otherwise,
# a user can fool our server into thinking it was an https connection.
# See https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
# for other warnings.
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
32

33 34
########################### NON-SECURE ENV CONFIG ##############################
# Things like server locations, ports, etc.
35

36
with open(ENV_ROOT / "env.json") as env_file:
37 38
    ENV_TOKENS = json.load(env_file)

39
SITE_NAME = ENV_TOKENS['SITE_NAME']
40

41 42 43
BOOK_URL = ENV_TOKENS['BOOK_URL']
MEDIA_URL = ENV_TOKENS['MEDIA_URL']
LOG_DIR = ENV_TOKENS['LOG_DIR']
44

45
CACHES = ENV_TOKENS['CACHES']
46

47
for feature, value in ENV_TOKENS.get('MITX_FEATURES', {}).items():
48 49
    MITX_FEATURES[feature] = value

50
WIKI_ENABLED = ENV_TOKENS.get('WIKI_ENABLED', WIKI_ENABLED)
51
local_loglevel = ENV_TOKENS.get('LOCAL_LOGLEVEL', 'INFO')
52

53
LOGGING = get_logger_config(LOG_DIR,
54 55
                            logging_env=ENV_TOKENS['LOGGING_ENV'],
                            syslog_addr=(ENV_TOKENS['SYSLOG_SERVER'], 514),
56
                            local_loglevel=local_loglevel,
57
                            debug=False)
58

59 60
COURSE_LISTINGS = ENV_TOKENS.get('COURSE_LISTINGS', {})
SUBDOMAIN_BRANDING = ENV_TOKENS.get('SUBDOMAIN_BRANDING', {})
61 62
COMMENTS_SERVICE_URL = ENV_TOKENS.get("COMMENTS_SERVICE_URL",'')
COMMENTS_SERVICE_KEY = ENV_TOKENS.get("COMMENTS_SERVICE_KEY",'')
63

64 65
############################## SECURE AUTH ITEMS ###############################
# Secret things: passwords, access keys, etc.
66
with open(ENV_ROOT / "auth.json") as auth_file:
67 68
    AUTH_TOKENS = json.load(auth_file)

69 70
SECRET_KEY = AUTH_TOKENS['SECRET_KEY']

71 72
AWS_ACCESS_KEY_ID = AUTH_TOKENS["AWS_ACCESS_KEY_ID"]
AWS_SECRET_ACCESS_KEY = AUTH_TOKENS["AWS_SECRET_ACCESS_KEY"]
73
AWS_STORAGE_BUCKET_NAME = 'edxuploads'
74

75
DATABASES = AUTH_TOKENS['DATABASES']
76 77

XQUEUE_INTERFACE = AUTH_TOKENS['XQUEUE_INTERFACE']
78 79 80 81

if 'COURSE_ID' in ENV_TOKENS:
    ASKBOT_URL = "courses/{0}/discussions/".format(ENV_TOKENS['COURSE_ID'])