-
Notifications
You must be signed in to change notification settings - Fork 23
/
settings.py
224 lines (191 loc) · 6.5 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
import os
import imp
# from S3 import CallingFormat
# from boto.s3.connection import OrdinaryCallingFormat
BASE = os.path.abspath(os.path.dirname(__file__))
DEBUG = True
ADMINS = ()
# SERVER_EMAIL = "[email protected]"
MANAGERS = ADMINS
TIME_ZONE = 'UTC'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
WSGI_APPLICATION = "wsgi.application"
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATICFILES_DIRS = (os.path.join(BASE, "in_app_purchase_receipt_verifier", "static"),)
STATIC_ROOT = os.path.join(BASE, "collected")
SECRET_KEY = os.environ.get("SECRET_KEY")
ALLOWED_HOSTS = [
"localhost",
".herokuapp.com",
]
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'urls'
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)
PASSWORD_HASHERS = [
'django.contrib.auth.hashers.Argon2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
'django.contrib.auth.hashers.BCryptPasswordHasher',
]
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.staticfiles',
'app',
'raven.contrib.django.raven_compat',
)
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'root': {
'level': 'INFO',
'handlers': ['syslog', 'papertrail', 'sentry', 'console'],
},
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse',
}
},
'formatters': {
'condensed': {
'format': '[%(levelname)s] %(name)s#%(lineno)d: %(message)s',
'datefmt': '%Y-%m-%d %H:%M:%S'
},
'papertrail': {
'format': ':[%(levelname)s] %(name)s#%(lineno)d: %(message)s',
'datefmt': '%Y-%m-%d %H:%M:%S'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'condensed'
},
'syslog': {
'level': 'INFO',
'address': '/dev/log',
'class': 'logging.handlers.SysLogHandler',
'formatter': 'condensed',
'filters': ['require_debug_false'],
},
'papertrail': {
'level': 'INFO',
'class': 'logging.handlers.SysLogHandler',
'address': ('logs.papertrailapp.com', 22222),
'filters': ['require_debug_false'],
'formatter': 'papertrail',
},
'sentry': {
'level': 'ERROR',
'class': 'raven.contrib.django.handlers.SentryHandler',
'filters': ['require_debug_false'],
},
},
'loggers': {
'sorl': {
'handlers': ['syslog', 'console'],
'propagate': False,
},
'raven': {
'handlers': ['sentry'],
'propagate': False
},
# 'django.db.backends': {
# 'level': 'INFO',
# 'propagate': False,
# 'handlers': ['syslog', 'console', 'sentry'],
# },
# 'django.request': {
# 'level': 'INFO',
# 'propagate': False,
# 'handlers': ['syslog', 'console', 'sentry'],
# },
},
}
if not os.path.exists('/dev/log'):
del LOGGING['handlers']['syslog']['address']
LOGGING['handlers']['syslog']['class'] = 'logging.StreamHandler'
LOGIN_REDIRECT_URL = '/'
LOGIN_URL = '/account/login'
LOGOUT_URL = '/account/logout'
INTERNAL_IPS = ['127.0.0.1', '0.0.0.0']
SESSION_SAVE_EVERY_REQUEST = True
# Uncomment imports at top to enable S3 integration
#
# AWS_CALLING_FORMAT = CallingFormat.PATH
# AWS_GZIP = True
from boto.s3.connection import OrdinaryCallingFormat
AWS_S3_CALLING_FORMAT = OrdinaryCallingFormat()
AWS_S3_SECURE_URLS = True
AWS_QUERYSTRING_AUTH = False
AWS_STORAGE_BUCKET_NAME = os.environ.get("AWS_STORAGE_BUCKET_NAME")
if AWS_STORAGE_BUCKET_NAME:
# Optionally change to full CDN url
STATIC_URL = "https://s3.amazonaws.com/{}/".format(AWS_STORAGE_BUCKET_NAME)
else:
STATIC_URL = "/static/"
AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID")
AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_SECRET_ACCESS_KEY")
AWS_STATIC_STORAGE_BUCKET_NAME = os.environ.get("AWS_STATIC_STORAGE_BUCKET_NAME")
AWS_HEADERS = {
'Cache-Control': "max-age:86400, public"
}
# EMAIL_BACKEND = "django_ses.SESBackend"
# AWS_SES_ACCESS_KEY_ID = ''
# AWS_SES_SECRET_ACCESS_KEY = ''
# SESSION_REDIS_PREFIX = "session"
# SESSION_ENGINE = 'redis_sessions.session'
# SENTRY_PUBLIC_KEY = ""
# SENTRY_SECRET_KEY = ""
# RAVEN_CONFIG = {
# 'dsn': "https://{}:{}@app.getsentry.com/4195".format(SENTRY_PUBLIC_KEY, SENTRY_SECRET_KEY)
# }
# django-statictastic querystring support
COMMIT_SHA = ""
APP_SPECIFIC_SHARED_SECRET = os.environ.get("APP_SPECIFIC_SHARED_SECRET")
RECEIPT_VERIFICATION_ENVIRONMENT = os.environ.get("RECEIPT_VERIFICATION_ENVIRONMENT")
BASE64_ENCODED_SIGNING_KEY = os.environ.get("BASE64_ENCODED_SIGNING_KEY")
if RECEIPT_VERIFICATION_ENVIRONMENT == "production":
RECEIPT_VERIFICATION_URL = "https://buy.itunes.apple.com/verifyReceipt"
else:
RECEIPT_VERIFICATION_URL = "https://sandbox.itunes.apple.com/verifyReceipt"
settings_path = lambda env: os.path.join(BASE, 'conf', 'settings', '{}.py'.format(env))
try:
from local_settings import *
except ImportError:
environment = os.environ.get('APP_ENVIRONMENT', 'production')
config = imp.load_source('local_settings', settings_path(environment))
from local_settings import *
# Uncomment if using django-celery
# try:
# import djcelery
# djcelery.setup_loader()
# import celeryconfig
# except ImportError:
# raise ImportError("""Please link the appropriate settings file from conf/settings/celery to `celeryconfig.py` in the project root. E.g.
#
# (in_app_purchase_receipt_verifier)$ ln -s conf/settings/celery/local.py celeryconfig.py""")