Fixing cookie settings for CSRF and auth token

This commit is contained in:
Wayne Witzel III 2017-07-25 10:11:11 -04:00
parent 0cf376ca6f
commit f6d59409de
2 changed files with 4 additions and 1 deletions

View File

@ -189,6 +189,9 @@ JOB_EVENT_MAX_QUEUE_SIZE = 10000
# Disallow sending session cookies over insecure connections
SESSION_COOKIE_SECURE = True
# Do not allow non-browser clients to read the CSRF cookie.
CSRF_COOKIE_HTTPONLY = True
# Disallow sending csrf cookies over insecure connections
CSRF_COOKIE_SECURE = True

View File

@ -60,7 +60,7 @@ class CompleteView(BaseRedirectView):
logger.info(smart_text(u"User {} logged in".format(self.request.user.username)))
request.session['auth_token_key'] = token.key
token_key = urllib.quote('"%s"' % token.key)
response.set_cookie('token', token_key)
response.set_cookie('token', value=token_key, httponly=True)
token_expires = token.expires.astimezone(utc).strftime('%Y-%m-%dT%H:%M:%S')
token_expires = '%s.%03dZ' % (token_expires, token.expires.microsecond / 1000)
token_expires = urllib.quote('"%s"' % token_expires)