From 363f64ebfaa6b61f90f2bb34ee3d3075d94124e8 Mon Sep 17 00:00:00 2001 From: Finn Weigand <52424812+Hudint@users.noreply.github.com> Date: Sun, 21 Sep 2025 17:38:25 +0200 Subject: [PATCH] feat: add dedicated sign-up config for oauth (#13610) Currently, it is only possible to disable all registrations. However, it would be helpful if you could disable normal registration but enable OAuth registration. ## Summary by CodeRabbit * **New Features** * Added a setting to enable/disable new user signups via OAuth (default: enabled). * Admin Settings (Authentication) now includes a toggle for OAuth signups. * OAuth signup flow now respects this setting, preventing new registrations via OAuth when disabled. * Self-hosted configuration schema updated to include the new option. --------- Signed-off-by: Hudint Finn Weigand Co-authored-by: DarkSky Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> --- .docker/selfhost/schema.json | 5 +++++ packages/backend/server/src/core/auth/config.ts | 5 +++++ packages/backend/server/src/plugins/oauth/controller.ts | 2 +- packages/frontend/admin/src/config.json | 4 ++++ packages/frontend/admin/src/modules/settings/config.ts | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.docker/selfhost/schema.json b/.docker/selfhost/schema.json index d8356b1dc1..3b46680d17 100644 --- a/.docker/selfhost/schema.json +++ b/.docker/selfhost/schema.json @@ -148,6 +148,11 @@ "description": "Whether allow new registrations.\n@default true", "default": true }, + "allowSignupForOauth": { + "type": "boolean", + "description": "Whether allow new registrations via configured oauth.\n@default true", + "default": true + }, "requireEmailDomainVerification": { "type": "boolean", "description": "Whether require email domain record verification before accessing restricted resources.\n@default false", diff --git a/packages/backend/server/src/core/auth/config.ts b/packages/backend/server/src/core/auth/config.ts index 05e5695c6f..afd5900541 100644 --- a/packages/backend/server/src/core/auth/config.ts +++ b/packages/backend/server/src/core/auth/config.ts @@ -8,6 +8,7 @@ export interface AuthConfig { ttr: number; }; allowSignup: boolean; + allowSignupForOauth: boolean; requireEmailDomainVerification: boolean; requireEmailVerification: boolean; passwordRequirements: ConfigItem<{ @@ -27,6 +28,10 @@ defineModuleConfig('auth', { desc: 'Whether allow new registrations.', default: true, }, + allowSignupForOauth: { + desc: 'Whether allow new registrations via configured oauth.', + default: true, + }, requireEmailDomainVerification: { desc: 'Whether require email domain record verification before accessing restricted resources.', default: false, diff --git a/packages/backend/server/src/plugins/oauth/controller.ts b/packages/backend/server/src/plugins/oauth/controller.ts index 7738688587..eb7e909e43 100644 --- a/packages/backend/server/src/plugins/oauth/controller.ts +++ b/packages/backend/server/src/plugins/oauth/controller.ts @@ -224,7 +224,7 @@ export class OAuthController { return connectedAccount.user; } - if (!this.config.auth.allowSignup) { + if (!this.config.auth.allowSignupForOauth) { throw new SignUpForbidden(); } diff --git a/packages/frontend/admin/src/config.json b/packages/frontend/admin/src/config.json index b267abd9a0..386ec175eb 100644 --- a/packages/frontend/admin/src/config.json +++ b/packages/frontend/admin/src/config.json @@ -63,6 +63,10 @@ "type": "Boolean", "desc": "Whether allow new registrations." }, + "allowSignupForOauth": { + "type": "Boolean", + "desc": "Whether allow new registrations via configured oauth." + }, "requireEmailDomainVerification": { "type": "Boolean", "desc": "Whether require email domain record verification before accessing restricted resources." diff --git a/packages/frontend/admin/src/modules/settings/config.ts b/packages/frontend/admin/src/modules/settings/config.ts index 4c36fd93ed..815ba3248d 100644 --- a/packages/frontend/admin/src/modules/settings/config.ts +++ b/packages/frontend/admin/src/modules/settings/config.ts @@ -55,6 +55,7 @@ export const KNOWN_CONFIG_GROUPS = [ module: 'auth', fields: [ 'allowSignup', + 'allowSignupForOauth', // nested json object { key: 'passwordRequirements',