diff --git a/assets/js/dashboard/extra/COPYING.txt b/assets/js/dashboard/extra/COPYING.txt
new file mode 100644
index 000000000000..3a9651ee046c
--- /dev/null
+++ b/assets/js/dashboard/extra/COPYING.txt
@@ -0,0 +1,5 @@
+Plausible copyright notice
+
+This software is Copyright 2024 Plausible Insights OÜ
+
+This repository is provided for informational purposes only, and no rights to use, distribute or otherwise exploit this software are granted to you. Our other repositories include software that is offered under the Affero GPL, but this repository is not. If you wish to discuss a license, or our hosted service that uses the software, please contact us at hello@plausible.io
diff --git a/config/runtime.exs b/config/runtime.exs
index 3b29d71b9a1d..b771a9e223c2 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -291,13 +291,16 @@ secure_cookie =
|> get_var_from_path_or_env("SECURE_COOKIE", if(is_selfhost, do: "false", else: "true"))
|> String.to_existing_atom()
+license_key = get_var_from_path_or_env(config_dir, "LICENSE_KEY", "")
+
config :plausible,
environment: env,
mailer_email: mailer_email,
super_admin_user_ids: super_admin_user_ids,
is_selfhost: is_selfhost,
custom_script_name: custom_script_name,
- log_failed_login_attempts: log_failed_login_attempts
+ log_failed_login_attempts: log_failed_login_attempts,
+ license_key: license_key
config :plausible, :selfhost,
enable_email_verification: enable_email_verification,
diff --git a/extra/COPYING.txt b/extra/COPYING.txt
new file mode 100644
index 000000000000..3a9651ee046c
--- /dev/null
+++ b/extra/COPYING.txt
@@ -0,0 +1,5 @@
+Plausible copyright notice
+
+This software is Copyright 2024 Plausible Insights OÜ
+
+This repository is provided for informational purposes only, and no rights to use, distribute or otherwise exploit this software are granted to you. Our other repositories include software that is offered under the Affero GPL, but this repository is not. If you wish to discuss a license, or our hosted service that uses the software, please contact us at hello@plausible.io
diff --git a/extra/lib/license.ex b/extra/lib/license.ex
new file mode 100644
index 000000000000..e62bfaa48ea8
--- /dev/null
+++ b/extra/lib/license.ex
@@ -0,0 +1,42 @@
+defmodule Plausible.License do
+ @moduledoc """
+ This module ensures that you cannot run Plausible Analytics Enterprise Edition without a valid license key.
+ The software contained within the ee/ and assets/js/dashboard/ee directories are Copyright © Plausible Insights OÜ.
+ We have made this code available solely for informational and transparency purposes. No rights are granted to use,
+ distribute, or exploit this software in any form.
+
+ Any attempt to disable or modify the behavior of this module will be considered a violation of copyright.
+ If you wish to use the Plausible Analytics Enterprise Edition for your own requirements, please contact us
+ at hello@plausible.io to discuss obtaining a license.
+ """
+
+ require Logger
+
+ if Mix.env() == :prod do
+ def ensure_valid_license do
+ if has_valid_license?() do
+ :ok
+ else
+ Logger.error(
+ "Invalid or no license key provided for Plausible Enterprise Edition. Please contact hello@plausible.io to acquire a license."
+ )
+
+ Logger.error("Shutting down")
+ System.stop()
+ end
+ end
+
+ @license_hash "4qidue2klxynf4vrprlxuouwjos7dnyn4nsquamkrfhtn3ts6ova===="
+ defp has_valid_license?() do
+ hash =
+ :crypto.hash(:sha256, Application.fetch_env!(:plausible, :license_key))
+ |> Base.encode32(case: :lower)
+
+ hash == @license_hash
+ end
+ else
+ def ensure_valid_license do
+ :ok
+ end
+ end
+end
diff --git a/lib/plausible/application.ex b/lib/plausible/application.ex
index 439888beaf4d..941649cec835 100644
--- a/lib/plausible/application.ex
+++ b/lib/plausible/application.ex
@@ -2,10 +2,13 @@ defmodule Plausible.Application do
@moduledoc false
use Application
+ use Plausible
require Logger
def start(_type, _args) do
+ on_full_build(do: Plausible.License.ensure_valid_license())
+
children = [
Plausible.Repo,
Plausible.ClickhouseRepo,
diff --git a/lib/plausible_web/components/layout.ex b/lib/plausible_web/components/layout.ex
index 2665f3bef37b..4ac2d23b5bc9 100644
--- a/lib/plausible_web/components/layout.ex
+++ b/lib/plausible_web/components/layout.ex
@@ -3,6 +3,28 @@ defmodule PlausibleWeb.Components.Layout do
use Phoenix.Component
+ def favicon(assigns) do
+ ~H"""
+
+
+
+ """
+ end
+
def theme_script(assigns) do
~H"""
-