TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.
TypeScript graphviewkanban-boardnodejsproductivityproject-managementself-hostedtasktask-managementtask-managertodoapp
fix: disable dynamically register by default
Nikolai Giman3b8058fe3d93
diff --git a/api/.env.example b/api/.env.exampleindex f9333c8..5f7b2db 100644--- a/api/.env.example+++ b/api/.env.example@@ -23,10 +23,11 @@ JWT_ALG=HS256#SSO_TRUSTED_DOMAINS=company.com,corp.local# OAuth 2.1 for third-party MCP clients (ChatGPT, Claude connectors).-# Dynamic Client Registration is on by default; a cloud client cannot connect-# without it, since it has no way to pre-register with your instance. Turn it-# off on a private install that only uses manually seeded clients.-#OAUTH_DYNAMIC_REGISTRATION=false+# Dynamic Client Registration is OFF unless you set this to true. Cloud clients+# cannot connect without it: they have no way to pre-register with your+# instance, so enable it if you want ChatGPT or Claude to connect over OAuth.+# Leave it unset on a private install that only uses manually seeded clients.+#OAUTH_DYNAMIC_REGISTRATION=true# Public URL of this API. Used as the OAuth issuer in the discovery documents,# so it must be the URL clients actually reach — set it behind a proxy.#API_PUBLIC_URL=https://api.taskview.techdiff --git a/api/src/tv-modules/oauth/__tests__/OAuth.integration.spec.ts b/api/src/tv-modules/oauth/__tests__/OAuth.integration.spec.tsindex 8f7ae13..3d044c6 100644--- a/api/src/tv-modules/oauth/__tests__/OAuth.integration.spec.ts+++ b/api/src/tv-modules/oauth/__tests__/OAuth.integration.spec.ts@@ -88,6 +88,9 @@ describe('OAuth 2.1 authorization server', () => {}));beforeAll(async () => {+ // Registration is opt-in; the suite exercises it, so switch it on.+ process.env.OAUTH_DYNAMIC_REGISTRATION = 'true';+const db = Database.getInstance();const client = await db.getClient();@@ -115,6 +118,7 @@ describe('OAuth 2.1 authorization server', () => {});afterAll(async () => {+ delete process.env.OAUTH_DYNAMIC_REGISTRATION;// HTTP cleanup has to happen while the server is still listening.if (goalId) {await api.delete('/module/goals', {diff --git a/api/src/tv-modules/oauth/__tests__/OAuthDcrDisabled.integration.spec.ts b/api/src/tv-modules/oauth/__tests__/OAuthDcrDisabled.integration.spec.tsindex 6d131ec..51111db 100644--- a/api/src/tv-modules/oauth/__tests__/OAuthDcrDisabled.integration.spec.ts+++ b/api/src/tv-modules/oauth/__tests__/OAuthDcrDisabled.integration.spec.ts@@ -1,5 +1,5 @@import axios from 'axios';-import type http from 'http';+import http from 'http';import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';import App from '../../../App';@@ -7,26 +7,39 @@ const port = 1812;const url = `http://localhost:${port}`;let server: http.Server;-const api = axios.create({ baseURL: url, validateStatus: () => true });+// Each case boots its own server on the same port. A keep-alive socket pooled+// against the previous server would be dead by then, so pooling is off.+const api = axios.create({+ baseURL: url,+ validateStatus: () => true,+ httpAgent: new http.Agent({ keepAlive: false }),+});/**- * OAUTH_DYNAMIC_REGISTRATION=false is the lever a self-hosted operator pulls to- * keep the client registry closed. It has to do two things: refuse registration,- * and stop advertising the endpoint — a client that reads the metadata should- * never attempt a registration this instance will reject.+ * Dynamic client registration is opt-in: an instance where the operator has not+ * set OAUTH_DYNAMIC_REGISTRATION=true keeps the client registry closed. That has+ * to do two things: refuse registration, and stop advertising the endpoint — a+ * client that reads the metadata should never attempt a registration this+ * instance will reject. The default (variable unset) is what a fresh install+ * runs with, so it is the case that matters most.*/-describe('OAuth with dynamic client registration disabled', () => {+describe.each([+ { label: 'variable not set (default)', value: undefined },+ { label: 'variable set to false', value: 'false' },+])('OAuth with dynamic client registration disabled: $label', ({ value }) => {vi.mock('emailjs', () => ({SMTPClient: vi.fn().mockImplementation(() => ({ sendAsync: vi.fn().mockResolvedValue(true) })),}));beforeAll(() => {- process.env.OAUTH_DYNAMIC_REGISTRATION = 'false';+ if (value === undefined) delete process.env.OAUTH_DYNAMIC_REGISTRATION;+ else process.env.OAUTH_DYNAMIC_REGISTRATION = value;server = new App(port).listen();});- afterAll(() => {- server?.close();+ afterAll(async () => {+ // The next case listens on the same port, so wait for the socket to be released.+ await new Promise<void>((resolve) => server.close(() => resolve()));delete process.env.OAUTH_DYNAMIC_REGISTRATION;});diff --git a/api/src/tv-modules/oauth/__tests__/oauth.utils.test.ts b/api/src/tv-modules/oauth/__tests__/oauth.utils.test.tsindex b9970ba..c46fb42 100644--- a/api/src/tv-modules/oauth/__tests__/oauth.utils.test.ts+++ b/api/src/tv-modules/oauth/__tests__/oauth.utils.test.ts@@ -1,8 +1,9 @@-import { describe, it, expect } from 'vitest'+import { afterEach, describe, it, expect } from 'vitest'import { createHash, randomBytes } from 'crypto'import {buildRedirectUrl,isAcceptableRedirectUri,+ isDcrEnabled,matchesRegisteredRedirectUri,resourceMatches,verifyPkce,@@ -156,3 +157,34 @@ describe('resourceMatches', () => {expect(resourceMatches({ granted: null, requested: 'https://mcp.example.com' })).toBe(true)})})++describe('isDcrEnabled', () => {+ const original = process.env.OAUTH_DYNAMIC_REGISTRATION++ afterEach(() => {+ if (original === undefined) delete process.env.OAUTH_DYNAMIC_REGISTRATION+ else process.env.OAUTH_DYNAMIC_REGISTRATION = original+ })++ it('is off when the variable is not set', () => {+ delete process.env.OAUTH_DYNAMIC_REGISTRATION+ expect(isDcrEnabled()).toBe(false)+ })++ it('is off when the variable is empty', () => {+ process.env.OAUTH_DYNAMIC_REGISTRATION = ' '+ expect(isDcrEnabled()).toBe(false)+ })++ it('is on only for an explicit true, ignoring case and whitespace', () => {+ process.env.OAUTH_DYNAMIC_REGISTRATION = ' TRUE '+ expect(isDcrEnabled()).toBe(true)+ })++ it('is off for anything that is not true', () => {+ process.env.OAUTH_DYNAMIC_REGISTRATION = 'false'+ expect(isDcrEnabled()).toBe(false)+ process.env.OAUTH_DYNAMIC_REGISTRATION = 'yes'+ expect(isDcrEnabled()).toBe(false)+ })+})diff --git a/api/src/tv-modules/oauth/oauth.utils.ts b/api/src/tv-modules/oauth/oauth.utils.tsindex 598f565..84d8e69 100644--- a/api/src/tv-modules/oauth/oauth.utils.ts+++ b/api/src/tv-modules/oauth/oauth.utils.ts@@ -7,9 +7,7 @@ import type {} from './types'export function isDcrEnabled(): boolean {- const raw = process.env.OAUTH_DYNAMIC_REGISTRATION- if (raw === undefined || raw.trim() === '') return true- return raw.trim().toLowerCase() === 'true'+ return (process.env.OAUTH_DYNAMIC_REGISTRATION ?? '').trim().toLowerCase() === 'true'}export function sha256Hex(value: string): string {diff --git a/docs/3.integrations/2.mcp.md b/docs/3.integrations/2.mcp.mdindex f23a0ed..5597be3 100644--- a/docs/3.integrations/2.mcp.md+++ b/docs/3.integrations/2.mcp.md@@ -93,6 +93,10 @@ Put the port behind your reverse proxy with HTTPS for anything beyond local use.Cloud assistants have no field for a pasted token: claude.ai and Claude Desktop **custom connectors**, ChatGPT connectors and similar clients authorize over OAuth 2.1 instead. The shared HTTP server supports this with nothing extra to run. The MCP server presents itself as the protected resource and names your TaskView API as the authorization server; the API handles client registration, the consent screen and tokens.+::callout{icon="i-lucide-key-round" color="warning"}+Cloud clients register themselves on your instance before the first authorization (dynamic client registration, RFC 7591). That is **off by default**: set `OAUTH_DYNAMIC_REGISTRATION=true` on the API, or every cloud client fails at the registration step with `403` before the consent screen ever opens.+::+What happens when a client connects:1. The client calls `/mcp` without a token and gets `401` with a `WWW-Authenticate` header pointing at the resource metadata.@@ -108,7 +112,7 @@ To connect, paste the MCP URL (`https://mcp.your-domain.com/mcp`) into the clien- `MCP_PUBLIC_URL` on the MCP server — the public URL of the server exactly as clients reach it. This is the OAuth resource identifier. When unset it is derived from the request's `Host` and `X-Forwarded-Proto` headers.- `TASKVIEW_URL` on the MCP server — advertised to clients as the authorization server, so for OAuth it must be the **public** API URL (`https://api.your-domain.com`), not the docker-network address from the example above.- `API_PUBLIC_URL` and `APP_URL` on the API — the first names the authorization server in its metadata, the second is where the consent screen lives. See [environment variables](/docs/configuration/environment-variables#application).-- `OAUTH_DYNAMIC_REGISTRATION=false` on the API — stops new clients from registering themselves, which closes OAuth for new connections on a locked-down instance. Existing connected apps keep working.+- `OAUTH_DYNAMIC_REGISTRATION=true` on the API — lets clients register themselves. Without it the registration endpoint answers `403`, is left out of the discovery metadata, and no new OAuth connection can be started. Turning it off again later does not affect apps that are already connected.**Mounted under a path.** When the MCP server sits behind a reverse proxy at `https://api.your-domain.com/mcp` rather than on its own host, put the full path into `MCP_PUBLIC_URL`. The resource metadata then also lives at `/.well-known/oauth-protected-resource/mcp` (RFC 9728), which is where a client that computes the address from the spec will look. The server publishes it at both that address and the root one, but the proxy has to route the path-inserted address to the MCP server too:diff --git a/docs/4.configuration/1.environment-variables.md b/docs/4.configuration/1.environment-variables.mdindex 42c0453..72481d8 100644--- a/docs/4.configuration/1.environment-variables.md+++ b/docs/4.configuration/1.environment-variables.md@@ -51,7 +51,7 @@ Unlike everything else on this page, this variable is set on the **web app conta| `AUTH_LOGIN_METHODS` | No | all enabled | Comma-separated list of login methods to offer: `magic-link`, `password`, `sso`, `social`. Disabled methods disappear from the login page and their API endpoints return 403. The API refuses to start if the list contains a typo or disables every method. || `PASSWORD_CHANGE_CONFIRMATION` | No | `email` | How account password changes are confirmed: `email` — a confirmation code is sent to the user's email (requires SMTP); `password` — the user confirms with their current password (works without SMTP, recommended for installs without a mail server). || `ALLOW_PUBLIC_REGISTRATION` | No | `true` | Set to `false` to close the instance: strangers can no longer create accounts — the registration endpoint returns 403, and magic-link / social sign-in stop auto-creating users. Emails invited to an organization or project can still sign in and get their account created on first login. |-| `OAUTH_DYNAMIC_REGISTRATION` | No | `true` | Whether AI clients may register themselves as OAuth clients (RFC 7591) when connecting to the [MCP server](/docs/integrations/mcp#oauth-cloud-clients). Set to `false` on a locked-down instance: the registration endpoint returns 403 and no new OAuth connection can be started; apps already connected keep working. |+| `OAUTH_DYNAMIC_REGISTRATION` | No | `false` | Whether AI clients may register themselves as OAuth clients (RFC 7591) when connecting to the [MCP server](/docs/integrations/mcp#oauth-cloud-clients). Off by default: the registration endpoint returns 403 and cloud clients such as ChatGPT or Claude cannot start an OAuth connection. Set to `true` to let them connect. Turning it back off later does not affect apps that are already connected. || `SSO_TRUSTED_DOMAINS` | No | empty | Comma-separated email domains that skip DNS/HTTP ownership checks for SSO (air-gapped / closed-network installs). Example: `company.com,corp.local`. On a public instance leave this unset so every org must prove it owns the domain. || `WEBHOOKS_ALLOW_PRIVATE_URLS` | No | `false` | Outgoing [webhooks](/docs/features/webhooks) may only target public addresses: loopback, private (`10/8`, `172.16/12`, `192.168/16`), link-local and cloud-metadata ranges are refused when a webhook is saved and again on every delivery, and redirects are never followed. Set to `true` on a self-hosted install whose receivers (n8n, CI, internal bots) live on the same private network. Never enable this on a public multi-tenant instance. The value must be `true` or `false`; anything else stops the server at startup. |