Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Disable CORS on /login/oauth/authorize (#6657)
Artur Patace05236bdf1f
diff --git a/lib/plausible_web/endpoint.ex b/lib/plausible_web/endpoint.exindex 0fce02defe..a63319e902 100644--- a/lib/plausible_web/endpoint.ex+++ b/lib/plausible_web/endpoint.ex@@ -2,6 +2,7 @@ defmodule PlausibleWeb.Endpoint douse Plausibleuse Sentry.PlugCaptureuse Phoenix.Endpoint, otp_app: :plausible+ use PlausibleWeb.VerifiedRouteson_ce doplug :maybe_handle_acme_challenge@@ -85,7 +86,7 @@ defmodule PlausibleWeb.Endpoint doplug(:runtime_session)- plug(CORSPlug)+ plug(:cors)plug(PlausibleWeb.Router)def secure_cookie?, do: config!(:secure_cookie)@@ -94,6 +95,17 @@ defmodule PlausibleWeb.Endpoint doconfig!(:websocket_url)end+ @cors_opts CORSPlug.init([])++ # CORS must not be supported at the [authorization endpoint](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1#name-authorization-endpoint)+ def cors(conn, _opts) do+ if conn.request_path == ~p"/login/oauth/authorize" do+ conn+ else+ CORSPlug.call(conn, @cors_opts)+ end+ end+def runtime_session(conn, _opts) doPlug.run(conn, [{Plug.Session, runtime_session_opts()}])end