-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New toolbar cookie + Secure session/csrf cookies #1387
Conversation
- make other cookies secure
Tests are failing, setting to WIP/draft |
This is waiting behind a new |
Small change from the text above. Instead of the This might cause trouble for people upgrading who have some special configs... and this new variable should be well documented. Some issue still with cypress tests...? |
This might be outside the scope for this PR, but after giving it a though, I'd actually nuke This setting makes sense only for users who direct both their HTTP and HTTPS traffic directly to their app. How many people do that? What's the risk here vs benefit of an easier setup with fewer compilcated env variables? |
The big one is Heroku, where if you don't set it you allow both http and https access. |
Regarding heroku... oh well. I think then it could make sense to eventually flip the SSL redirect toggle, so it must be explicitly enabled. There are bigger fish to fry now. |
Changes
This PR does two things.
First,
The django documentation says the following:
This PR does that. These settings now default to
True
and revert toFalse
if running under DEBUG/TEST or if the env varDISABLE_SECURE_COOKIES
is set.This PR will be breaking if you're running posthog under regular HTTP in production (no nginx ssl proxy, no nothing). Then you need to set the
DISABLE_SECURE_COOKIES
flag.This should be documented if the PR is merged.
Second,
This PR sets a new cross-domain cookie,
phtoolbar
, which is available to the/decide
endpoint. It uses it to determine that the user is logged in and returnstrue
for isAuthenticated... causing the toolbar to appear and ask for authorization.This is a lot safer than setting the session cookie to be cross domain, as in case there's an error with this cookie (strong security in the browser, etc), nothing bad will happen. You'll just need to click "Launch Toolbar" manually.
Caveats: I'm not sure if I should add tests for this. Probably, if so, it's a WIP. I just ran out of time now.
Checklist