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 option to disable server-side OIDC checks

Alicia Sykesa08491e25ad5
diff --git a/docs/authentication/oidc.md b/docs/authentication/oidc.md
index 7cac9d08..b5da10eb 100644
--- a/docs/authentication/oidc.md
+++ b/docs/authentication/oidc.md
@@ -29,6 +29,7 @@ appConfig:
adminRole: dashy-admin # Or grant admin by role instead
enableSilentRenew: true # Refresh the session in the background before it expires
# allowedIssuers: [] # Only for multi-tenant providers to override discovery document
+ # disableServerSideCheck: false # Leave as false / unset. Setting to true makes auth just client-side
```
Because Dashy is a SPA, a [public client](https://datatracker.ietf.org/doc/html/rfc6749#section-2.1) registration with PKCE is needed.
@@ -69,12 +70,23 @@ Set `enableGuestAccess: true` to let people view the dashboard read-only without
If you turn on the service worker for offline use (`enableServiceWorker: true`), turn on `enableAuthProxyCompat: true` as well. Without it, when your session expires the cached app can keep showing the old page instead of letting the login redirect through. With it on, Dashy spots the expired session on load, drops the service worker, and reloads so you can sign in again.
+
+
## How server-side enforcement works
Dashy's server reads `auth.oidc` from `conf.yml` at boot, lazily fetches the OIDC discovery doc + JWKS from your `endpoint`, then verifies the `id_token` the SPA attaches to every API call as `Authorization: Bearer <id_token>`. Tokens that fail signature / issuer / audience / expiry verification are rejected with `401`. Write endpoints (`POST /config-manager/save`) additionally require the `adminGroup` (or `adminRole`) to be present in the token's `groups` / `roles` claims, and non-admins receive `403`. Unauthenticated requests for `/conf.yml` get a stripped response containing only the `auth` block plus a minimal `pageInfo`, just enough for the SPA to bootstrap the login flow. The full config is only served to authenticated users.
Your IdP must include `groups` / `roles` in the id_token, not only the access token, for the admin check to work (most IdPs do this when the `groups` scope is requested).
+### Opting out of server-side enforcement
+
+> [!CAUTION]
+> This is not recommended (on untrusted networks), as it allows users to bypass all the server-side protection.
+
+Set `disableServerSideCheck: true` under `auth.oidc` to turn off the server-side enforcement.
+This should only be done in a trusted environment, or where you've got your own protections in place or for when server-side verification isn't supported by your provider. It makes OIDC become a purely client-side login page.
+
+
## Silent token renewal
By default, when your access token expires Dashy sends you back through the provider's login page to get a new one. On a long-lived session this is visible as a brief flash of the sign-out button and a reload. Setting `enableSilentRenew: true` avoids it: Dashy requests a refresh token and uses it to renew the session in the background, before the token expires, with no interactive round-trip.
diff --git a/docs/configuring.md b/docs/configuring.md
index 526b1825..fa65d51f 100644
--- a/docs/configuring.md
+++ b/docs/configuring.md
@@ -214,6 +214,7 @@ For more info, see the **[Authentication Docs](/docs/authentication.md)**
**`scope`** | `string` | Required | The scope(s) to request from the OIDC provider
**`enableSilentRenew`** | `boolean` | _Optional_ | If set to `true`, your session is silently renewed in the background before it expires (only works for providers which support the `offline_access` scope)
**`allowedIssuers`** | `array` | _Optional_ | List of issuer URLs to accept tokens from. Needed for multi-tenant providers (e.g. Microsoft Entra) where the token issuer differs from the configured `endpoint`. If unset, the issuer from the discovery document is used
+**`disableServerSideCheck`** | `boolean` | _Optional_ | If `true`, the server skips token verification and endpoint protection, so OIDC is client-side only. Not recommended. Defaults to `false`
**[⬆️ Back to Top](#configuring)**
diff --git a/services/auth-oidc.js b/services/auth-oidc.js
index e7ed82bc..13b353ff 100644
--- a/services/auth-oidc.js
+++ b/services/auth-oidc.js
@@ -22,6 +22,10 @@ function loadOidcSettings(authConfig) {
if (!authConfig || typeof authConfig !== 'object') return null;
if (authConfig.enableOidc && authConfig.oidc) {
+ if (authConfig.oidc.disableServerSideCheck) {
+ console.warn('[auth-oidc] disableServerSideCheck is set, skipping auth check'); // eslint-disable-line no-console
+ return null;
+ }
const {
endpoint, clientId, adminGroup, adminRole, allowedIssuers,
} = authConfig.oidc;
diff --git a/src/utils/config/ConfigSchema.json b/src/utils/config/ConfigSchema.json
index 71f4484c..3ce2af86 100644
--- a/src/utils/config/ConfigSchema.json
+++ b/src/utils/config/ConfigSchema.json
@@ -672,6 +672,12 @@
"type": "array",
"items": { "type": "string" },
"description": "List of issuer URLs to accept tokens from, overriding the issuer in the discovery document. Only needed for multi-tenant providers where the token issuer differs from the configured endpoint"
+ },
+ "disableServerSideCheck": {
+ "title": "Disable Server-Side Check",
+ "type": "boolean",
+ "default": false,
+ "description": "If set to true, the server skips token verification and endpoint protection, making OIDC client-side only. Not recommended"
}
}
},
diff --git a/tests/server/auth-oidc.test.js b/tests/server/auth-oidc.test.js
index 83ff5cc6..29515937 100644
--- a/tests/server/auth-oidc.test.js
+++ b/tests/server/auth-oidc.test.js
@@ -50,4 +50,8 @@ describe('loadOidcSettings allowedIssuers', () => {
expect(loadOidcSettings({ ...base, oidc: { ...base.oidc, allowedIssuers: [] } }).allowedIssuers).toBe(null);
expect(loadOidcSettings({ ...base, oidc: { ...base.oidc, allowedIssuers: 'nope' } }).allowedIssuers).toBe(null);
});
+
+ it('returns null when disableServerSideCheck is set', () => {
+ expect(loadOidcSettings({ ...base, oidc: { ...base.oidc, disableServerSideCheck: true } })).toBe(null);
+ });
});
diff --git a/tests/server/conf-no-server-check.test.js b/tests/server/conf-no-server-check.test.js
new file mode 100644
index 00000000..13087620
--- /dev/null
+++ b/tests/server/conf-no-server-check.test.js
@@ -0,0 +1,59 @@
+// @vitest-environment node
+import fs from 'fs';
+import os from 'os';
+import path from 'path';
+import { load as yamlLoad } from 'js-yaml';
+import { describe, it, expect, beforeAll } from 'vitest';
+import request from 'supertest';
+
+const CONF = `appConfig:
+ auth:
+ enableOidc: true
+ oidc:
+ endpoint: https://example.test/
+ clientId: dashy-test
+ disableServerSideCheck: true
+pageInfo:
+ title: My Dashboard
+sections:
+ - name: Internal Services
+ items:
+ - title: secret-host
+ url: http://10.0.0.5
+`;
+
+let app;
+let tmpDir;
+
+beforeAll(() => {
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'dashy-no-check-test-'));
+ fs.writeFileSync(path.join(tmpDir, 'conf.yml'), CONF);
+ fs.writeFileSync(path.join(tmpDir, 'sub.yml'), 'pageInfo:\n title: Sub\n');
+ process.env.USER_DATA_DIR = tmpDir;
+ delete require.cache[require.resolve('../../services/app')];
+ delete require.cache[require.resolve('../../services/auth-oidc')];
+ app = require('../../services/app');
+});
+
+describe('OIDC with disableServerSideCheck', () => {
+ it('serves the full, unstripped conf.yml without auth', async () => {
+ const res = await request(app).get('/conf.yml');
+ expect(res.status).toBe(200);
+ const body = yamlLoad(res.text);
+ expect(body._bootstrap).toBeUndefined();
+ expect(body.sections).toHaveLength(1);
+ expect(body.pageInfo.title).toBe('My Dashboard');
+ });
+
+ it('serves non-root yml files without auth', async () => {
+ const res = await request(app).get('/sub.yml');
+ expect(res.status).toBe(200);
+ });
+
+ it('does not reject API routes on an invalid Bearer token', async () => {
+ const res = await request(app)
+ .get('/status-check')
+ .set('Authorization', 'Bearer not-a-real-token');
+ expect(res.status).not.toBe(401);
+ });
+});