diff --git a/assets/js/dashboard/extra/COPYING.txt b/assets/js/dashboard/extra/COPYING.txt new file mode 100644 index 000000000..3a9651ee0 --- /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 3b29d71b9..b771a9e22 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 000000000..3a9651ee0 --- /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 000000000..e62bfaa48 --- /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 439888bea..941649cec 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 2665f3bef..4ac2d23b5 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""" - - diff --git a/lib/plausible_web/templates/layout/base_error.html.heex b/lib/plausible_web/templates/layout/base_error.html.heex new file mode 100644 index 000000000..bf3e20d93 --- /dev/null +++ b/lib/plausible_web/templates/layout/base_error.html.heex @@ -0,0 +1,40 @@ + + + + + + + + Plausible · Web analytics + + + +
+ + <%= img_tag( + PlausibleWeb.Router.Helpers.static_path( + @conn, + logo_path("logo_dark.svg") + ), + class: "w-44 hidden dark:inline", + alt: "Plausible logo", + loading: "lazy" + ) %> + <%= img_tag( + PlausibleWeb.Router.Helpers.static_path( + @conn, + logo_path("logo_light.svg") + ), + class: "w-44 inline dark:hidden", + alt: "Plausible logo", + loading: "lazy" + ) %> + +
+ + <%= @inner_content %> + + + + diff --git a/lib/plausible_web/templates/layout/focus.html.heex b/lib/plausible_web/templates/layout/focus.html.heex index 16f90460a..560ad17f5 100644 --- a/lib/plausible_web/templates/layout/focus.html.heex +++ b/lib/plausible_web/templates/layout/focus.html.heex @@ -13,30 +13,31 @@ <% end %> - + <%= assigns[:title] || "Plausible · Web analytics" %> <%= render("_tracking.html", assigns) %> -
+ diff --git a/lib/plausible_web/views/layout_view.ex b/lib/plausible_web/views/layout_view.ex index f12204417..7a531a951 100644 --- a/lib/plausible_web/views/layout_view.ex +++ b/lib/plausible_web/views/layout_view.ex @@ -40,6 +40,14 @@ defmodule PlausibleWeb.LayoutView do end end + def logo_path(filename) do + if full_build?() do + Path.join("/images/ee/", filename) + else + Path.join("/images/ce/", filename) + end + end + def settings_tabs(conn) do [ [key: "General", value: "general", icon: :rocket_launch], diff --git a/mix.exs b/mix.exs index 8bd488ca7..4b253148c 100644 --- a/mix.exs +++ b/mix.exs @@ -158,7 +158,7 @@ defmodule Plausible.MixProject do defp docs do [ main: "readme", - logo: "priv/static/images/icon/plausible_favicon.png", + logo: "priv/static/images/ee/favicon-32x32.png", extras: Path.wildcard("guides/**/*.md") ++ [ diff --git a/priv/static/images/ce/apple-touch-icon.png b/priv/static/images/ce/apple-touch-icon.png new file mode 100644 index 000000000..a6c9af6ed Binary files /dev/null and b/priv/static/images/ce/apple-touch-icon.png differ diff --git a/priv/static/images/ce/favicon-16x16.png b/priv/static/images/ce/favicon-16x16.png new file mode 100644 index 000000000..985206612 Binary files /dev/null and b/priv/static/images/ce/favicon-16x16.png differ diff --git a/priv/static/images/ce/favicon-32x32.png b/priv/static/images/ce/favicon-32x32.png new file mode 100644 index 000000000..2a3b0dff8 Binary files /dev/null and b/priv/static/images/ce/favicon-32x32.png differ diff --git a/priv/static/images/ce/favicon.ico b/priv/static/images/ce/favicon.ico new file mode 100644 index 000000000..25510630f Binary files /dev/null and b/priv/static/images/ce/favicon.ico differ diff --git a/priv/static/images/ce/logo_dark.svg b/priv/static/images/ce/logo_dark.svg new file mode 100644 index 000000000..a5e0dfb88 --- /dev/null +++ b/priv/static/images/ce/logo_dark.svg @@ -0,0 +1 @@ + diff --git a/priv/static/images/ce/logo_light.svg b/priv/static/images/ce/logo_light.svg new file mode 100644 index 000000000..afa776d0a --- /dev/null +++ b/priv/static/images/ce/logo_light.svg @@ -0,0 +1 @@ + diff --git a/priv/static/images/ee/apple-touch-icon.png b/priv/static/images/ee/apple-touch-icon.png new file mode 100644 index 000000000..00f995336 Binary files /dev/null and b/priv/static/images/ee/apple-touch-icon.png differ diff --git a/priv/static/images/ee/favicon-16x16.png b/priv/static/images/ee/favicon-16x16.png new file mode 100644 index 000000000..5998d7b4c Binary files /dev/null and b/priv/static/images/ee/favicon-16x16.png differ diff --git a/priv/static/images/ee/favicon-32x32.png b/priv/static/images/ee/favicon-32x32.png new file mode 100644 index 000000000..74af7adbd Binary files /dev/null and b/priv/static/images/ee/favicon-32x32.png differ diff --git a/priv/static/images/ee/favicon.ico b/priv/static/images/ee/favicon.ico new file mode 100644 index 000000000..fd4db40ee Binary files /dev/null and b/priv/static/images/ee/favicon.ico differ diff --git a/priv/static/images/ee/logo_dark.svg b/priv/static/images/ee/logo_dark.svg new file mode 100644 index 000000000..9c18a7ee0 --- /dev/null +++ b/priv/static/images/ee/logo_dark.svg @@ -0,0 +1 @@ + diff --git a/priv/static/images/ee/logo_light.svg b/priv/static/images/ee/logo_light.svg new file mode 100644 index 000000000..0effe278f --- /dev/null +++ b/priv/static/images/ee/logo_light.svg @@ -0,0 +1 @@ + diff --git a/priv/static/images/icon/apple-touch-icon.png b/priv/static/images/icon/apple-touch-icon.png deleted file mode 100644 index 747c7ca2e..000000000 Binary files a/priv/static/images/icon/apple-touch-icon.png and /dev/null differ diff --git a/priv/static/images/icon/plausible_favicon.png b/priv/static/images/icon/plausible_favicon.png deleted file mode 100644 index 6e9ba0861..000000000 Binary files a/priv/static/images/icon/plausible_favicon.png and /dev/null differ diff --git a/priv/static/images/icon/plausible_logo.png b/priv/static/images/icon/plausible_logo.png deleted file mode 100644 index e7d76ad88..000000000 Binary files a/priv/static/images/icon/plausible_logo.png and /dev/null differ diff --git a/priv/static/images/icon/plausible_logo_100px.png b/priv/static/images/icon/plausible_logo_100px.png deleted file mode 100644 index 6310b1006..000000000 Binary files a/priv/static/images/icon/plausible_logo_100px.png and /dev/null differ diff --git a/priv/static/images/icon/plausible_logo_100px_dark.png b/priv/static/images/icon/plausible_logo_100px_dark.png deleted file mode 100644 index 148b43164..000000000 Binary files a/priv/static/images/icon/plausible_logo_100px_dark.png and /dev/null differ diff --git a/priv/static/images/icon/plausible_logo_300px.png b/priv/static/images/icon/plausible_logo_300px.png deleted file mode 100644 index b8f54e4c4..000000000 Binary files a/priv/static/images/icon/plausible_logo_300px.png and /dev/null differ diff --git a/priv/static/images/icon/plausible_logo_300px_dark.png b/priv/static/images/icon/plausible_logo_300px_dark.png deleted file mode 100644 index 0baea1e7f..000000000 Binary files a/priv/static/images/icon/plausible_logo_300px_dark.png and /dev/null differ diff --git a/priv/static/images/icon/plausible_logo_dark.png b/priv/static/images/icon/plausible_logo_dark.png deleted file mode 100644 index f386bdfc5..000000000 Binary files a/priv/static/images/icon/plausible_logo_dark.png and /dev/null differ diff --git a/priv/static/images/icon/plausible_logo_sm.png b/priv/static/images/icon/plausible_logo_sm.png deleted file mode 100644 index 89c7558e8..000000000 Binary files a/priv/static/images/icon/plausible_logo_sm.png and /dev/null differ