aws.py 3.28 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
from .common import *
12
from logsettings import get_logger_config
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
# Enable Berkeley forums
23 24
MITX_FEATURES['ENABLE_DISCUSSION_SERVICE'] = True

25
# IMPORTANT: With this enabled, the server must always be behind a proxy that
26 27 28 29 30
# 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')
31

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

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

38
SITE_NAME = ENV_TOKENS['SITE_NAME']
39
SESSION_COOKIE_DOMAIN = ENV_TOKENS.get('SESSION_COOKIE_DOMAIN')
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
VIRTUAL_UNIVERSITIES = ENV_TOKENS.get('VIRTUAL_UNIVERSITIES', [])
62 63
COMMENTS_SERVICE_URL = ENV_TOKENS.get("COMMENTS_SERVICE_URL",'')
COMMENTS_SERVICE_KEY = ENV_TOKENS.get("COMMENTS_SERVICE_KEY",'')
64
CERT_QUEUE = ENV_TOKENS.get("CERT_QUEUE", 'test-pull')
65

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

71 72
SECRET_KEY = AUTH_TOKENS['SECRET_KEY']

73 74
AWS_ACCESS_KEY_ID = AUTH_TOKENS["AWS_ACCESS_KEY_ID"]
AWS_SECRET_ACCESS_KEY = AUTH_TOKENS["AWS_SECRET_ACCESS_KEY"]
75
AWS_STORAGE_BUCKET_NAME = 'edxuploads'
76

77
DATABASES = AUTH_TOKENS['DATABASES']
78 79

XQUEUE_INTERFACE = AUTH_TOKENS['XQUEUE_INTERFACE']
80

81 82 83
# Get the MODULESTORE from auth.json, but if it doesn't exist,
# use the one from common.py
MODULESTORE = AUTH_TOKENS.get('MODULESTORE', MODULESTORE)
84
CONTENTSTORE = AUTH_TOKENS.get('CONTENTSTORE', CONTENTSTORE)
85

86
STAFF_GRADING_INTERFACE = AUTH_TOKENS.get('STAFF_GRADING_INTERFACE', STAFF_GRADING_INTERFACE)
Vik Paruchuri committed
87
PEER_GRADING_INTERFACE = AUTH_TOKENS.get('PEER_GRADING_INTERFACE', PEER_GRADING_INTERFACE)
88

89
PEARSON_TEST_USER = "pearsontest"
90
PEARSON_TEST_PASSWORD = AUTH_TOKENS.get("PEARSON_TEST_PASSWORD")