From 1a1460cff9d9e2f268b7d5c0c7a132efaae0bb17 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 23 Apr 2025 05:12:42 +0000 Subject: [PATCH 1/3] feat: disabled redirect by env Co-authored-by: hyohyeok1 --- .env.example | 20 ++++++++++++++++++++ .gitignore | 1 + site/src/@types/vite-env.d.ts | 16 ++++++++++++++++ site/src/pages/LoginPage/LoginPage.tsx | 6 +++++- site/vite.config.mts | 1 + 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .env.example create mode 100644 site/src/@types/vite-env.d.ts diff --git a/.env.example b/.env.example new file mode 100644 index 0000000000000..be97ef96dca71 --- /dev/null +++ b/.env.example @@ -0,0 +1,20 @@ +export CODER_ACCESS_URL="https://coder.access.url" +export CODER_HTTP_ADDRESS="0.0.0.0:3000" #If using nginx -> 127.0.0.1:3000 +export CODER_PROVISIONER_DAEMONS=5 +export CODER_TLS_ENABLE=false + +export CODER_REDIRECT_TO_ACCESS_URL=false +export CODER_TELEMETRY_ENABLE=false +export CODER_OIDC_ENABLED=true +export CODER_OIDC_ISSUER_URL="https://oidc.issuer.url" +export CODER_OIDC_CLIENT_ID="your-oidc-client-id" +export CODER_OIDC_CLIENT_SECRET="your-oidc-client-secret" +export CODER_OIDC_SCOPES="openid email" +export CODER_OIDC_IGNORE_EMAIL_VERIFIED=true +export CODER_OIDC_REDIRECT_URI="$BASE_URL/api/v2/users/oidc/callback" +export CODER_OIDC_LOGOUT_URI="https://oidc.logout.url" +export CODER_OIDC_TOKEN_PATH="/home/ubuntu/.coder/tokens" + +# if IS_CI_BUILD variable is true, CODER_DISABLE_PASSWORD_AUTH variable must be false +export VITE_IS_CI_BUILD=true +export CODER_DISABLE_PASSWORD_AUTH=false \ No newline at end of file diff --git a/.gitignore b/.gitignore index f98101cd7f920..e1d757a99c4c3 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ gotests.json node_modules/ vendor/ yarn-error.log +.env # VSCode settings. **/.vscode/* diff --git a/site/src/@types/vite-env.d.ts b/site/src/@types/vite-env.d.ts new file mode 100644 index 0000000000000..b867ffd74c489 --- /dev/null +++ b/site/src/@types/vite-env.d.ts @@ -0,0 +1,16 @@ +/// + +interface ViteTypeOptions { + // 아래 라인을 추가하면, ImportMetaEnv 타입을 엄격하게 설정해 + // 알 수 없는 키를 허용하지 않게 할 수 있습니다. + strictImportEnv: unknown +} + +interface ImportMetaEnv { + readonly VITE_IS_CI_BUILD: string + // 다른 환경 변수들에 대한 타입 정의... +} + +interface ImportMeta { + readonly env: ImportMetaEnv +} \ No newline at end of file diff --git a/site/src/pages/LoginPage/LoginPage.tsx b/site/src/pages/LoginPage/LoginPage.tsx index f490086ee9bde..e86304596c1e9 100644 --- a/site/src/pages/LoginPage/LoginPage.tsx +++ b/site/src/pages/LoginPage/LoginPage.tsx @@ -69,7 +69,11 @@ export const LoginPage: FC = () => { /> ); } - } else { + } + + const isCI = import.meta.env.VITE_IS_CI_BUILD === "true" + + if (!isSignedIn && !isCI) { window.location.replace(`https://heaan.io`); return null; } diff --git a/site/vite.config.mts b/site/vite.config.mts index 9da0221016cb1..5523edd0cd60c 100644 --- a/site/vite.config.mts +++ b/site/vite.config.mts @@ -29,6 +29,7 @@ export default defineConfig({ // 'hidden' works like true except that the corresponding sourcemap comments in the bundled files are suppressed sourcemap: "hidden", }, + envDir: "../", define: { "process.env": { NODE_ENV: process.env.NODE_ENV, From d4201c110e289e36b67706feea1d1c778cfac8ee Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 23 Apr 2025 05:17:04 +0000 Subject: [PATCH 2/3] fix: fixed typo Co-authored-by: hyohyeok1 --- .env.example | 2 +- site/src/@types/vite-env.d.ts | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.env.example b/.env.example index be97ef96dca71..0ecd16656b899 100644 --- a/.env.example +++ b/.env.example @@ -15,6 +15,6 @@ export CODER_OIDC_REDIRECT_URI="$BASE_URL/api/v2/users/oidc/callback" export CODER_OIDC_LOGOUT_URI="https://oidc.logout.url" export CODER_OIDC_TOKEN_PATH="/home/ubuntu/.coder/tokens" -# if IS_CI_BUILD variable is true, CODER_DISABLE_PASSWORD_AUTH variable must be false +# if VITE_IS_CI_BUILD variable is true, CODER_DISABLE_PASSWORD_AUTH variable must be false export VITE_IS_CI_BUILD=true export CODER_DISABLE_PASSWORD_AUTH=false \ No newline at end of file diff --git a/site/src/@types/vite-env.d.ts b/site/src/@types/vite-env.d.ts index b867ffd74c489..597b1ba3e5f67 100644 --- a/site/src/@types/vite-env.d.ts +++ b/site/src/@types/vite-env.d.ts @@ -1,14 +1,11 @@ /// interface ViteTypeOptions { - // 아래 라인을 추가하면, ImportMetaEnv 타입을 엄격하게 설정해 - // 알 수 없는 키를 허용하지 않게 할 수 있습니다. strictImportEnv: unknown } interface ImportMetaEnv { readonly VITE_IS_CI_BUILD: string - // 다른 환경 변수들에 대한 타입 정의... } interface ImportMeta { From c1fc86c5d7e20d433d975eb14fbf6a701fe2e7bf Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 23 Apr 2025 06:14:23 +0000 Subject: [PATCH 3/3] refactor: Changed variable names Co-authored-by: hyohyeok1 --- .env.example | 4 ++-- site/src/@types/vite-env.d.ts | 2 +- site/src/pages/LoginPage/LoginPage.tsx | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 0ecd16656b899..d7ed972edc672 100644 --- a/.env.example +++ b/.env.example @@ -15,6 +15,6 @@ export CODER_OIDC_REDIRECT_URI="$BASE_URL/api/v2/users/oidc/callback" export CODER_OIDC_LOGOUT_URI="https://oidc.logout.url" export CODER_OIDC_TOKEN_PATH="/home/ubuntu/.coder/tokens" -# if VITE_IS_CI_BUILD variable is true, CODER_DISABLE_PASSWORD_AUTH variable must be false -export VITE_IS_CI_BUILD=true +# if VITE_DISABLE_EXTERNAL_LOGIN_PAGE variable is true, CODER_DISABLE_PASSWORD_AUTH variable must be false +export VITE_DISABLE_EXTERNAL_LOGIN_PAGE=true export CODER_DISABLE_PASSWORD_AUTH=false \ No newline at end of file diff --git a/site/src/@types/vite-env.d.ts b/site/src/@types/vite-env.d.ts index 597b1ba3e5f67..e9699e6947edb 100644 --- a/site/src/@types/vite-env.d.ts +++ b/site/src/@types/vite-env.d.ts @@ -5,7 +5,7 @@ interface ViteTypeOptions { } interface ImportMetaEnv { - readonly VITE_IS_CI_BUILD: string + readonly VITE_DISABLE_EXTERNAL_LOGIN_PAGE: string } interface ImportMeta { diff --git a/site/src/pages/LoginPage/LoginPage.tsx b/site/src/pages/LoginPage/LoginPage.tsx index e86304596c1e9..3da1f6da67d03 100644 --- a/site/src/pages/LoginPage/LoginPage.tsx +++ b/site/src/pages/LoginPage/LoginPage.tsx @@ -71,9 +71,9 @@ export const LoginPage: FC = () => { } } - const isCI = import.meta.env.VITE_IS_CI_BUILD === "true" + const disableExternalLoginPage = import.meta.env.VITE_DISABLE_EXTERNAL_LOGIN_PAGE === "true"; - if (!isSignedIn && !isCI) { + if (!isSignedIn && !disableExternalLoginPage) { window.location.replace(`https://heaan.io`); return null; }