Make cookie domain configurable via zulip.conf

Adapted from a cherry-pick picked of Zev's
fda2d99d9e9a07951d11fcd9fc61cf229988f471.

(imported from commit 4701511d94f9ae34523202ca395e72ceb7a1adfb)
This commit is contained in:
Luke Faraone
2014-01-16 16:03:48 -05:00
parent ce50478a1e
commit c3eac38fa4

View File

@@ -137,6 +137,15 @@ if DEPLOYED:
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
try:
# For get_updates hostname sharding
domain = config_file.get('django', 'cookie_domain')
SESSION_COOKIE_DOMAIN = '.' + domain
CSRF_COOKIE_DOMAIN = '.' + domain
except ConfigParser.Error:
# Failing here is OK
pass
# Prevent Javascript from reading the CSRF token from cookies. Our code gets
# the token from the DOM, which means malicious code could too. But hiding the
# cookie will slow down some attackers.