π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
ποΈ Merge branch 'master' of github.com:lissy93/dashy into migration/vue3-upgrade
Alicia Sykes8bf2f8e02dbd
diff --cc .envindex a16ca244,87202c32..43ee620b--- a/.env+++ b/.env@@@ -27,31 -27,33 +27,33 @@@# The path to the user data directory# USER_DATA_DIR=user-data- # Enable HTTP basic auth to protect your *.yml config files+ # Enable HTTP auth on all server-side endpoints, using the users defined in conf.yml+ # This is the recommended approach when using Dashy's built-in auth (via appConfig.auth.users)# ENABLE_HTTP_AUTH=true- # Enable basic HTTP auth to protect your *.yml config files- # BASIC_AUTH_USERNAME- # BASIC_AUTH_PASSWORD+ # Alternatively, protect server-side endpoints with a single static username/password+ # BASIC_AUTH_USERNAME=+ # BASIC_AUTH_PASSWORD=- # If you'd like frontend to automatically authenticate when basic auth enabled, set credentials here too- # VITE_APP_BASIC_AUTH_USERNAME- # VITE_APP_BASIC_AUTH_PASSWORD+ # If using BASIC_AUTH above, set these to the same values to skip the browser auth prompt+ # Requires a rebuild to take effect - only use on trusted networks-# VUE_APP_BASIC_AUTH_USERNAME=-# VUE_APP_BASIC_AUTH_PASSWORD=++# VITE_APP_BASIC_AUTH_USERNAME=++# VITE_APP_BASIC_AUTH_PASSWORD=# Override where the path to the configuration file is, can be a remote URL-# VUE_APP_CONFIG_PATH=/conf.yml+# VITE_APP_CONFIG_PATH=/conf.yml# Usually the same as BASE_URL, but accessible in frontend-# VUE_APP_DOMAIN=https://dashy.to+# VITE_APP_DOMAIN=https://dashy.to# Override the page title for the frontend app-# VUE_APP_TITLE=''+# VITE_APP_TITLE=''# Set the default view to load on startup (can be `minimal`, `workspace` or `home`)-# VUE_APP_STARTING_VIEW=home+# VITE_APP_STARTING_VIEW=home# Set the Vue app routing mode (can be 'hash', 'history' or 'abstract')-# VUE_APP_ROUTING_MODE=history+# VITE_APP_ROUTING_MODE=history# Should enable SRI for build script and link resources# INTEGRITY=truediff --cc Dockerfileindex 5b344603,30e41314..9aa6e557--- a/Dockerfile+++ b/Dockerfile@@@ -1,4 -1,4 +1,4 @@@- FROM node:20-alpine AS BUILD_IMAGE-FROM node:18.19.1-alpine AS build++FROM node:20-alpine AS build# Set the platform to build image forARG TARGETPLATFORMdiff --cc docs/authentication.mdindex 620e33cc,b2bce798..fe3ed1de--- a/docs/authentication.md+++ b/docs/authentication.md@@@ -152,9 -170,24 +170,24 @@@ The built-in login page prevents casua## HTTP Auth- If you'd like to protect all your config files from direct access, you can set the `BASIC_AUTH_USERNAME` and `BASIC_AUTH_PASSWORD` environmental variables. You'll then be prompted to enter these credentials when visiting Dashy.+ If you'd like to protect server-side endpoints with HTTP Basic Auth, there are two approaches. They protect the same endpoints but use different credential sources, so pick one - don't combine them.++ ### Using config-file users (recommended)++ This is the approach described in [Adding HTTP Auth to Configuration](#adding-http-auth-to-configuration) above. Set `ENABLE_HTTP_AUTH=true` and it uses the same `appConfig.auth.users` from your `conf.yml`. The frontend handles authentication automatically using the session token from the login page, so no extra setup is needed.++ This is the recommended approach because it keeps credentials in one place and works together with the client-side login page. But the drawback is that your credentials will be stored in your config file.++ ### Using static credentials- Then, if you'd like your frontend to automatically log you in, without prompting you for credentials (insecure, so only use on a trusted environment), then also specify `VITE_APP_BASIC_AUTH_USERNAME` and `VITE_APP_BASIC_AUTH_PASSWORD`. This is useful for when you're hosting Dashy on a private server, and just want to use auth for user management and to prevent direct access to your config files, while still allowing the frontend to access them. Note that a rebuild is required for these changes to take effect.+ If you don't have users in your `conf.yml` (e.g. you handle user management externally, or just want a single shared password for server-side access), you can set the `BASIC_AUTH_USERNAME` and `BASIC_AUTH_PASSWORD` environmental variables instead.++ With this approach, there is no Dashy login page. When the browser first requests the config file, the server responds with a `401` and the browser shows its native HTTP auth prompt. Once the user enters the correct credentials, the browser caches them for the session and all subsequent requests work.+-To skip the browser prompt and have the frontend authenticate automatically, also set `VUE_APP_BASIC_AUTH_USERNAME` and `VUE_APP_BASIC_AUTH_PASSWORD` to the same values. These are baked in at build time, so a rebuild is required, and you should only do this on a trusted network.++To skip the browser prompt and have the frontend authenticate automatically, also set `VITE_APP_BASIC_AUTH_USERNAME` and `VITE_APP_BASIC_AUTH_PASSWORD` to the same values. These are baked in at build time, so a rebuild is required, and you should only do this on a trusted network.++ > [!WARNING]+ > Do not combine `BASIC_AUTH_USERNAME`/`BASIC_AUTH_PASSWORD` with conf.yml users. If both are present, the server will log a warning at startup. With `ENABLE_HTTP_AUTH` set, config-file users take priority and the static credentials are ignored. Without it, the static credentials protect the server but the Dashy login page will use conf.yml credentials, and the frontend will send the wrong credentials to server endpoints. Pick one approach or the other.**[β¬οΈ Back to Top](#authentication)**diff --cc package.jsonindex eb88b76c,62aab0b8..5aadac18--- a/package.json+++ b/package.json@@@ -58,13 -71,17 +58,14 @@@"happy-dom": "^20.8.9","npm-run-all": "^4.1.5","sass": "^1.77.0",- "sass-loader": "^12.0.0",+ "supertest": "^7.2.2",- "typescript": "^5.4.4",- "vite-plugin-vue2": "^2.0.3",- "vitest": "^1.6.0",- "vue-cli-plugin-yaml": "^1.0.2",- "vue-svg-loader": "^0.16.0",- "vue-template-compiler": "^2.7.0"+ "vite": "^6.2.0",+ "vite-plugin-pwa": "^1.0.0",+ "vite-svg-loader": "^5.1.0",+ "vitest": "^4.0.18"},"engines": {- "node": ">=16.0.0 <21.6.2"+ "node": ">=18.0.0"},"eslintConfig": {"root": true,diff --cc src/components/LinkItems/StatusIndicator.vueindex 1beb60aa,d8f38f67..19663fba--- a/src/components/LinkItems/StatusIndicator.vue+++ b/src/components/LinkItems/StatusIndicator.vue@@@ -2,10 -2,10 +2,10 @@@<div class="indicator"v-tooltip="{content: statusText || otherStatusText,- classes: ['status-tooltip', `tip-${color()}`],+ popperClass: ['status-tooltip', `tip-${color()}`],delay: { show: 0, hide: 150 }}">- <div :class="`dot dot-${color()}`">+ <div :class="['dot', `dot-${color()}`, { 'a11y-mode': a11yMode }]"><span><span></span></span></div></div>diff --cc src/components/Settings/AuthButtons.vueindex 93dddf05,03b2daaf..0a349fe8--- a/src/components/Settings/AuthButtons.vue+++ b/src/components/Settings/AuthButtons.vue@@@ -79,10 -79,18 +79,18 @@@ export default}, 500);},goToLogin() {- router.push({ path: '/login' });+ if (isOidcEnabled()) {+ const oidc = getOidcAuth();+ oidc.userManager.signinRedirect();+ } else if (isKeycloakEnabled()) {+ const keycloak = getKeycloakAuth();+ keycloak.keycloakClient.login(keycloak.loginOptions);+ } else {+ router.push({ path: '/login' });+ }},tooltip(content) {- return { content, trigger: 'hover focus', delay: 250 };+ return { content };},makeUserGreeting() {if (this.userType === userStateEnum.loggedIndiff --cc src/utils/Auth.jsindex d8d051a2,981e3965..46c436e4--- a/src/utils/Auth.js+++ b/src/utils/Auth.js@@@ -74,16 -73,13 +74,13 @@@ export const makeBasicAuthHeaders = ()const token = getCookieToken();const bearerAuth = (token && token.length > 5) ? `Bearer ${token}` : null;- const username = process.env.VUE_APP_BASIC_AUTH_USERNAME+ const username = import.meta.env.VITE_APP_BASIC_AUTH_USERNAME|| localStorage[localStorageKeys.USERNAME]|| 'user';- const password = process.env.VUE_APP_BASIC_AUTH_PASSWORD || bearerAuth;+ const password = import.meta.env.VITE_APP_BASIC_AUTH_PASSWORD || bearerAuth;const basicAuth = `Basic ${btoa(`${username}:${password}`)}`;- const headers = password- ? { headers: { Authorization: basicAuth, 'WWW-Authenticate': 'true' } }- : {};- return headers;+ return password ? { headers: { Authorization: basicAuth } } : {};};/**@@@ -147,13 -140,13 +141,14 @@@ export const checkCredentials = (usernausers.forEach((user) => {if (user.user.toLowerCase() === username.toLowerCase()) { // User foundif (user.password) {- if (!user.password.startsWith('VUE_APP_')) {- ErrorHandler('Invalid password format. Please use VUE_APP_ prefix');+ const credEnvKey = user.password.replace(/^VUE_APP_/, 'VITE_APP_');+ if (!user.password.startsWith('VUE_APP_') && !user.password.startsWith('VITE_APP_')) {+ ErrorHandler('Invalid password format. Please use VITE_APP_ prefix');response = { correct: false, msg: messages.incorrectPassword };- } else if (!process.env[user.password]) {- ErrorHandler(`Missing environmental variable for ${user.password}`);+ } else if (!import.meta.env[credEnvKey]) {+ ErrorHandler(`Missing environmental variable for ${credEnvKey}`);+ response = { correct: false, msg: messages.incorrectPassword };- } else if (process.env[user.password] === pass) {+ } else if (import.meta.env[credEnvKey] === pass) {response = { correct: true, msg: messages.successMsg };} else {response = { correct: false, msg: messages.incorrectPassword };