From 9c97fb359daf14df7704f3b15cb889877a8d382c Mon Sep 17 00:00:00 2001 From: Alexander Piskun <13381981+bigcat88@users.noreply.github.com> Date: Thu, 2 Oct 2025 09:09:11 +0300 Subject: [PATCH] feat(auth): Allow SSO login only for whitelisted addresses (localhost) (#5815) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Hide Google/GitHub SSO login options when the UI is accessed from **non‑local** addresses. This PR also adds a **static whitelist** (editable in code) so we can allow additional hosts if needed. Default whitelisted addresses: 1. `localhost` and any subdomain: `*.localhost` 2. IPv4 loopback `127.0.0.0/8` (e.g., `127.x.y.z`) 4. IPv6 loopback `::1` (including equivalent textual forms such as `::0001`) ## Changes - **What**: * Add `src/utils/hostWhitelist.ts` with `normalizeHost` and `isHostWhitelisted` helpers. * Update `SignInContent.vue` to **hide** SSO options when `isHostWhitelisted(normalizeHost(window.location.hostname))` returns `false`. - **Breaking**: * Users accessing from Runpod or other previously allowed **non‑local** hosts will **lose** SSO login options. If we need to keep SSO there, we should add those hosts to the whitelist in `hostWhitelist.ts`. ## Review Focus 1. Verify that logging in from local addresses (`localhost`, `*.localhost`, `127.0.0.1`, `::1`) **does not change** the current behavior: SSO is visible. 2. Verify that from a **non‑local** address, SSO options are **not** displayed. ## Screenshots (if applicable) UI opened from `192.168.2.109` address: Screenshot From 2025-09-27 13-22-15 UI opened from default `127.0.0.1` address(nothing changed): Screenshot From 2025-09-27 13-35-27 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5815-feat-auth-Allow-SSO-login-only-for-whitelisted-addresses-localhost-27b6d73d365081ccbe84c034cf8e416d) by [Unito](https://www.unito.io) --- .../dialog/content/SignInContent.vue | 62 ++++----- src/utils/hostWhitelist.ts | 91 +++++++++++++ tests-ui/tests/utils/hostWhitelist.test.ts | 123 ++++++++++++++++++ 3 files changed, 247 insertions(+), 29 deletions(-) create mode 100644 src/utils/hostWhitelist.ts create mode 100644 tests-ui/tests/utils/hostWhitelist.test.ts diff --git a/src/components/dialog/content/SignInContent.vue b/src/components/dialog/content/SignInContent.vue index 3f3a47b7b..29f441a28 100644 --- a/src/components/dialog/content/SignInContent.vue +++ b/src/components/dialog/content/SignInContent.vue @@ -45,37 +45,39 @@ {{ t('auth.login.orContinueWith') }} - +
- +