diff --git a/.env.example b/.env.example new file mode 100644 index 0000000000000..d7ed972edc672 --- /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 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/.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..e9699e6947edb --- /dev/null +++ b/site/src/@types/vite-env.d.ts @@ -0,0 +1,13 @@ +/// + +interface ViteTypeOptions { + strictImportEnv: unknown +} + +interface ImportMetaEnv { + readonly VITE_DISABLE_EXTERNAL_LOGIN_PAGE: 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..3da1f6da67d03 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 disableExternalLoginPage = import.meta.env.VITE_DISABLE_EXTERNAL_LOGIN_PAGE === "true"; + + if (!isSignedIn && !disableExternalLoginPage) { 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,