PhoenixKit 2.18.0: Website access, a password gate and site closing in one page
PhoenixKit 2.18.0 adds Website access, one settings page for every way of controlling who sees a Phoenix site: a password gate, a redirect to production, a visitor notice, closing the site, hiding it from search engines and a list of allowed addresses.
One page for who sees the site
The page is at /admin/settings/website-access. Each feature is switched on and off on its own. Presets set several at once: Maintenance, Under construction, Development site and Live, which turns everything off. An environment panel shows how the app runs, its environment, host and site URL, and suggests a preset when the site looks like a development site; it never turns anything on by itself. While a feature is on, a badge in the admin header shows it and links to its settings.
Password gate
The Password gate puts a blank page with one password field in front of the whole site, at /access under the PhoenixKit prefix, before anyone sees anything, including your own login page. Changing the password asks everyone for it again. Every try is listed under Tries at the door, with a verdict and, by default, what was typed, so a bot can be told from a client mistyping; Keep what was typed narrows or turns that off. Lock out after (wrong tries) sets an optional lockout per address. Logged-in users pass without the password is on by default. You can also Make an access link to share: it unlocks only when the visitor presses the button on the page, so a link preview cannot use it up.
Redirect, notice and closing the site
- Redirect to production sends visitors asking for a public page to the same path and query on the Production URL. Logged-in users and admin pages are never redirected. Who is redirected is Everyone or Search-engine crawlers only.
- Visitor notice shows a bar along the bottom of every page, with an icon, a text and an optional link. Admins see it too.
- Site closed replaces the separate Maintenance Mode settings. Everyone except admins and owners sees a closed page with a heading and a message, by hand or in a scheduled window with a start and an end time, and a countdown when there is an end time. The Maintenance Mode card on the Modules page is gone.
- Hide from search engines is the same switch as on the Crawlers page, and now also sends an
X-Robots-Tagheader. - Allowed addresses, one per line, pass the gate and the redirect without a password.
Other fixes
After a restart, settings stored encrypted, such as OAuth secrets or storage keys, could read as empty until they were saved again, because the cache could warm up before the key was available. They are no longer cached as empty.
Upgrading
Run mix phoenix_kit.update to apply migration V187, which adds the table of password gate tries. The website access checks run in the PhoenixKit plug your browser pipeline already uses, so the router needs no change. Maintenance settings now live under Website access, as Site closed; the old /admin/settings/maintenance page is removed.
Full release notes: PhoenixKit 2.18.0
2.18.0 · 7 September 2026
Added
-
Website access — one settings page (
/admin/settings/website-access) for every way of controlling who sees the site, with independently switchable features and presets (Maintenance, Under construction, Development site, Live) that bundle them:- Password gate — a blank page with one field at
<prefix>/access, before anyone sees anything. Unlock is a session epoch (rotated on password change, switch-on, or “ask everyone again”), never password-derived. Every try is recorded with a verdict (correct, case, close, unrelated, empty, locked, link) and, by default, what was typed — narrowable to near-misses or nothing. Optional per-address lockout under a per-address advisory lock. An access link unlocks only on the button’s POST, never on the link’s own GET, so a preview fetcher can’t burn it. Logged-in users pass by default. - Redirect to production — public GET/HEAD to the same path and query on the production URL, never for logged-in users, the kit’s own pages, or back to this host; everyone or crawlers only.
- Visitor notice — an escaped bar injected after
<body>on HTML 200s (byte-safe), editable live from the settings page. - Site closed — maintenance is now part of core: heading, message, a
from/until window, a status line, a preview, and a visitor 503 page that counts
down to the end.
PhoenixKit.Modules.Maintenancekeeps its name and API. - Hide from search engines — the crawlers noindex switch, plus
X-Robots-Tagon every response in the chain. - Allowed addresses — pass the gate and the redirect; editing the list relocks already-open sessions.
- Environment panel — release/mix,
MIX_ENV, host, site URL — suggests a preset, never switches anything on. Header badges (lock, wrench, arrow) show while a feature is on and link to its settings.
PhoenixKitWeb.Plugs.WebsiteAccessruns the chain in the host’s browser pipeline: allowed-address bookkeeping → notice/robots → redirect → gate → maintenance. Everyon_mounthook inUsers.Authchecks the gate first. New migration V187 addsphoenix_kit_access_attempts. Core’s<.checkbox>gainedvariant="toggle";Routes.prefix_base/0was added for root-mounted kits. - Password gate — a blank page with one field at
Fixed
- The settings cache warmer could run before the host’s endpoint was up. Under
the legacy encryption tier the endpoint’s
secret_key_baseis the key, so a restricted value failed to decrypt at boot and the failure was cached asniluntil that key’s next write — any host reading an OAuth secret or AWS key throughget_setting_cached/2right after a restart hit this. The warm map now leaves an undecryptable key out instead of cachingnilfor it, and a cache miss caused by a decrypt failure is answerednilwithout being cached. - A password-gate redirect-target test asserted a maintenance schedule starting
exactly 60 seconds in the past, which sits on the validator’s own tolerance
boundary and failed deterministically once clock drift pushed it a hair past
-60. - The gate’s
?to=redirect-target check reimplemented local-path validation with its own regex instead ofRoutes.local_path?/1; it now calls the shared guard, with the gate’s own rules layered on top.
PhoenixKit 2.18.0. Install or update: {:phoenix_kit, "~> 2.18"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.