Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ›‚ Adds auth.logoutRedirectUrl config option (#2233)

Alicia Sykes7bfb7692395c
diff --git a/docs/authentication/header-auth.md b/docs/authentication/header-auth.md
index 2e3b560a..4962ec09 100644
--- a/docs/authentication/header-auth.md
+++ b/docs/authentication/header-auth.md
@@ -8,6 +8,7 @@ Use this when you already run something like [Authelia](https://www.authelia.com
- [Configure Dashy](#configure-dashy)
- [Configure your proxy](#configure-your-proxy)
+- [Logging out](#logging-out)
- [Troubleshooting](#troubleshooting)
- [Security notes](#security-notes)
- [How it works](#how-it-works)
@@ -49,6 +50,20 @@ Two things the proxy has to do:
The whitelist is the security boundary, so Dashy must only be reachable through the proxy. If someone can hit Dashy directly and their IP happens to be whitelisted, they can forge the header. See [Security notes](#security-notes).
+## Logging out
+
+Dashy's logout button only clears Dashy's own session. Your session at the proxy stays alive, so the next page load signs you straight back in. To end both, point `logoutRedirectUrl` at your proxy's sign-out endpoint:
+
+```yaml
+appConfig:
+ auth:
+ logoutRedirectUrl: https://dashy.example.com/oauth2/sign_out
+```
+
+Logging out then sends the browser to that URL, where the proxy can destroy its session.
+
+The specific endpoint depends on your proxy, but for oauth2-proxy it's usually `/oauth2/sign_out` with an `rd` query param to chain your identity provider's logout, e.g. `/oauth2/sign_out?rd=https://sso.example.com/logout` (the `rd` domain must be in oauth2-proxy's `whitelist_domains`).
+
## Troubleshooting
#### 401 "Unauthorized - not from trusted proxy"
@@ -64,7 +79,7 @@ The proxy sent a username with no matching entry in `auth.users`. Add a user who
That user's `type` isn't `admin`. Saving is admin-only, so set `type: admin` on their entry.
#### Logging out just logs me back in
-Expected. Logout clears Dashy's cookie, but you're still signed in at the proxy, so the next page load re-authenticates from the header. To fully sign out, log out at the proxy.
+Expected with the default config. Logout clears Dashy's cookie, but you're still signed in at the proxy, so the next page load re-authenticates from the header. Set `logoutRedirectUrl` to your proxy's sign-out endpoint to end both sessions β€” see [Logging out](#logging-out).
## Security notes
diff --git a/docs/configuring.md b/docs/configuring.md
index 6845bdb7..526b1825 100644
--- a/docs/configuring.md
+++ b/docs/configuring.md
@@ -156,14 +156,6 @@ For more info, see the[Multi-Page docs](/docs/pages-and-sections.md#multi-page-s
## `appConfig.auth` _(optional)_
-> [!NOTE]
-> Since the auth is initiated in the main app entry point (for security), a rebuild is required to apply changes to the auth configuration.
-> Run `yarn build` in the root directory, then restart the server.
-
-> [!WARNING]
-> Built-in auth should **not be used** for security-critical applications, or if your Dashy instance is publicly accessible.
-> For these, it is recommended to use an [alternate authentication method](/docs/authentication.md#alternative-authentication-methods).
-
**Field** | **Type** | **Required**| **Description**
--- | --- | --- | ---
**`users`** | `array` | _Optional_ | An array of objects containing usernames and hashed passwords. If this is not provided, then authentication will be off by default, and you will not need any credentials to access the app. See [`appConfig.auth.users`](#appconfigauthusers-optional). <br>**Note** this method of authentication is handled on the client side, so for security critical situations, it is recommended to use an [alternate authentication method](/docs/authentication.md#alternative-authentication-methods).
@@ -174,6 +166,7 @@ For more info, see the[Multi-Page docs](/docs/pages-and-sections.md#multi-page-s
**`enableOidc`** | `boolean` | _Optional_ | If set to `true`, then authentication using OIDC will be enabled. Note that you need to have a configured OIDC server and configure it with `auth.oidc`. Defaults to `false`
**`oidc`** | `object` | _Optional_ | Config options to point Dash to your OIDC configuration. Request `enableOidc: true`. See [`auth.oidc`](#appconfigauthoidc-optional) for more info
**`enableGuestAccess`** | `boolean` | _Optional_ | When set to `true`, an unauthenticated user will be able to access the dashboard, with read-only access, without having to login. Requires `auth.users` to be configured. Defaults to `false`.
+**`logoutRedirectUrl`** | `string` | _Optional_ | URL to redirect the user to after logging out (useful with [header auth](/docs/authentication/header-auth.md#logging-out), where you also need to end the session on your auth proxy)
For more info, see the **[Authentication Docs](/docs/authentication.md)**
diff --git a/src/components/Settings/AuthButtons.vue b/src/components/Settings/AuthButtons.vue
index 64e222fd..d4940349 100644
--- a/src/components/Settings/AuthButtons.vue
+++ b/src/components/Settings/AuthButtons.vue
@@ -24,7 +24,7 @@
<script>
import router from '@/router';
import Keys from '@/utils/StoreMutations';
-import { logout as registerLogout } from '@/utils/auth/Auth';
+import { logout as registerLogout, getLogoutRedirectUrl } from '@/utils/auth/Auth';
import { getKeycloakAuth, isKeycloakEnabled } from '@/utils/auth/KeycloakAuth';
import { getOidcAuth, isOidcEnabled } from '@/utils/auth/OidcAuth';
import { localStorageKeys, userStateEnum } from '@/utils/config/defaults';
@@ -72,7 +72,11 @@ export default {
registerLogout();
this.$store.commit(Keys.AUTH_CHANGED);
this.$toast(this.$t('login.logout-message'));
- setTimeout(() => router.push({ path: '/login' }), 500);
+ const redirectUrl = getLogoutRedirectUrl();
+ setTimeout(() => {
+ if (redirectUrl) window.location.href = redirectUrl;
+ else router.push({ path: '/login' });
+ }, 500);
},
keycloakLogout() {
const keycloak = getKeycloakAuth();
diff --git a/src/utils/auth/Auth.js b/src/utils/auth/Auth.js
index 37ad29db..d221fb1c 100644
--- a/src/utils/auth/Auth.js
+++ b/src/utils/auth/Auth.js
@@ -183,6 +183,12 @@ export const logout = () => {
localStorage.removeItem(localStorageKeys.USERNAME);
};
+/* Returns the URL to redirect to after logout if set */
+export const getLogoutRedirectUrl = () => {
+ const auth = getAppConfig().auth || {};
+ return auth.logoutRedirectUrl || null;
+};
+
/**
* If correctly logged in as a valid, authenticated user,
* then returns the user object for the current user
diff --git a/src/utils/config/ConfigSchema.json b/src/utils/config/ConfigSchema.json
index d9636a92..71f4484c 100644
--- a/src/utils/config/ConfigSchema.json
+++ b/src/utils/config/ConfigSchema.json
@@ -573,6 +573,11 @@
"default": false,
"description": "If set to true, an unauthenticated user will be able to have read-only access to dashboard, without needing to login. Requires auth to be configured."
},
+ "logoutRedirectUrl": {
+ "title": "Logout Redirect URL",
+ "type": "string",
+ "description": "If set, the logout button will redirect here after logging out. Useful with header auth / to end auth proxy session"
+ },
"users": {
"title": "Users",
"type": "array",
diff --git a/src/views/Login.vue b/src/views/Login.vue
index a01c7994..7e6777c1 100644
--- a/src/views/Login.vue
+++ b/src/views/Login.vue
@@ -84,6 +84,7 @@ import {
isLoggedIn,
logout,
isGuestAccessEnabled,
+ getLogoutRedirectUrl,
} from '@/utils/auth/Auth';
export default {
@@ -183,7 +184,12 @@ export default {
logout();
this.status = 'success';
this.message = 'Logging out...';
- this.refreshPage();
+ const redirectUrl = getLogoutRedirectUrl();
+ if (redirectUrl) {
+ setTimeout(() => { window.location.href = redirectUrl; }, 250);
+ } else {
+ this.refreshPage();
+ }
},
/* Logged in user redirects to home page */
stayLoggedIn() {