π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
π Sign out when session expired (#2159)
Alicia Sykesa6f9ca33b2df
diff --git a/docs/troubleshooting.md b/docs/troubleshooting.mdindex 1d92597c..92f55e65 100644--- a/docs/troubleshooting.md+++ b/docs/troubleshooting.md@@ -532,6 +532,11 @@ Dashy's server is rejecting the id_token. Check Dashy's container logs for `[aut- **Dashy server can't reach Authentik**. The Dashy container fails to fetch the discovery document. Exec into the container and try `wget -qO- https://auth.example.com/application/o/dashy/.well-known/openid-configuration`- **Clock skew**. The middleware allows 30 seconds of drift. If a container's clock is further off than that, `exp`/`iat` checks fail+If you've exhausted these and need a stop-gap, set `oidc.disableServerSideCheck: true` to skip server-side verification and fall back to client-side-only auth. This leaves Dashy's server routes unprotected, so only use it in a trusted environment (see the [OIDC docs](/docs/authentication/oidc.md)).++### Sent back to the login page after a while+Your SSO session's id_token expired, so Dashy signs you out (rather than leaving a logged-in-looking UI whose API calls all silently 401). For OIDC, set `oidc.enableSilentRenew: true` to refresh the session in the background before it lapses; this needs your provider to issue refresh tokens (Dashy adds the `offline_access` scope automatically when it's on). Otherwise, just sign in again when prompted.+### Logged in but no admin controlsThe id_token doesn't include the groups claim. Open browser devtools after logging in, find the call to `/application/o/dashy/userinfo/`, and check the response. You should see a `groups` array containing `dashy-admins`. If not:- The `groups` scope mapping doesn't exist, or is not attached to the provider's property mappingsdiff --git a/src/utils/auth/Auth.js b/src/utils/auth/Auth.jsindex 0d5d75c4..b8e99c6f 100644--- a/src/utils/auth/Auth.js+++ b/src/utils/auth/Auth.js@@ -2,7 +2,7 @@ import sha256 from 'crypto-js/sha256';import ConfigAccumulator from '@/utils/config/ConfigAccumalator';import ErrorHandler from '@/utils/logging/ErrorHandler';import { cookieKeys, localStorageKeys, userStateEnum } from '@/utils/config/defaults';-import getApiAuthHeader from '@/utils/auth/getApiAuthHeader';+import getApiAuthHeader, { getApiAuthState } from '@/utils/auth/getApiAuthHeader';import { isKeycloakEnabled } from '@/utils/auth/KeycloakAuth';import { isOidcEnabled } from '@/utils/auth/OidcAuth';@@ -81,6 +81,9 @@ export const makeBasicAuthHeaders = () => {return password ? { headers: { Authorization: basicAuth } } : {};};+/* True when server-side OIDC token verification is turned off / client-only mode */+const isServerSideCheckDisabled = () => Boolean(getAppConfig().auth?.oidc?.disableServerSideCheck);+/*** Checks if the user is currently authenticated* @returns {Boolean} Will return true if the user is logged in, else false@@ -90,11 +93,14 @@ export const isLoggedIn = () => {const cookieToken = getCookieToken();if (isOidcEnabled() || isKeycloakEnabled()) {- const username = localStorage[localStorageKeys.USERNAME]; // Get username+ const username = localStorage[localStorageKeys.USERNAME];if (!username) return false; // No username- return users.some((user) => (- user.user === username || generateUserToken(user) === cookieToken- ));+ // If client-only mode, then skip the need to verify id_token, trust username+ if (isServerSideCheckDisabled()) return true;+ // The id_token is our server credential, so once it expires every API call 401s+ if (getApiAuthState().ok) return true;+ // Valid built-in cookie session (for mixed OIDC + users setup)+ return users.some((user) => (user.hash || user.password) && generateUserToken(user) === cookieToken);}return users.some((user) => {diff --git a/src/utils/auth/getApiAuthHeader.js b/src/utils/auth/getApiAuthHeader.jsindex 8662c0b3..0179b3a2 100644--- a/src/utils/auth/getApiAuthHeader.js+++ b/src/utils/auth/getApiAuthHeader.js@@ -8,6 +8,9 @@import { localStorageKeys } from '@/utils/config/defaults';+// Grace period on token expiry, 30 seconds+const CLOCK_TOLERANCE_MS = 30 * 1000;+/* Base64URL β utf-8 string decode */function decodeBase64Url(input) {const padded = input.replace(/-/g, '+').replace(/_/g, '/');@@ -36,7 +39,7 @@ export function getApiAuthState() {let claims;try {claims = decodeClaims(token);- if (typeof claims.exp === 'number' && claims.exp * 1000 <= Date.now()) {+ if (typeof claims.exp === 'number' && claims.exp * 1000 + CLOCK_TOLERANCE_MS <= Date.now()) {return { ok: false, reason: 'expired' };}} catch {