:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(csp): let the admin OAuth redirect through form-action (#101296)
Tom Piccirelloa418b7f30b8c
diff --git a/posthog/middleware.py b/posthog/middleware.pyindex 0a465dace051..ae9b6e906930 100644--- a/posthog/middleware.py+++ b/posthog/middleware.py@@ -1386,8 +1386,13 @@ class CSPMiddleware:"manifest-src 'self'","base-uri 'self'",# form-action has no default-src fallback, so leaving it unset lets an injected- # form post anywhere. Every form we serve targets a same-origin path.- "form-action 'self'",+ # form post anywhere. Every form we serve targets a same-origin path, but Chromium+ # judges each hop of the redirect chain too, and reports the original action rather+ # than the hop that failed. Exiting impersonation posts to /logout, which redirects+ # into /admin/, and AdminOAuth2Middleware sends that on to Google because+ # restore_original_login() flushes the session holding the admin verification. So+ # without this origin a staff logout is cancelled with nothing shown to the user.+ "form-action 'self' https://accounts.google.com",]report_uri = csp_report_endpoint(sample_rate="0.1")