sync: update from private repo (63a6e76)
CI / build-and-test (push) Has been cancelled

This commit is contained in:
oss-sync
2026-06-09 03:17:43 +00:00
parent d6d8e83867
commit 3848b5efd7
20 changed files with 386 additions and 29 deletions
+28 -2
View File
@@ -22,7 +22,7 @@ import { setSessionManager } from '../engine/tools/browser.js';
import { setUserFolderToolDeps } from '../engine/tools/user-folder.js';
import { setSkillToolDeps } from '../engine/tools/skills.js';
import { setAppDocsDeps } from '../engine/tools/app-docs.js';
import { setupAuth, requireAuth, requireAdmin } from './auth.js';
import { setupAuth, requireAuth, requireAdmin, isProviderConfigured } from './auth.js';
import { canUserSeeTask } from './visibility.js';
import { mountAdminApi } from './admin-api.js';
import { createAdminGatewayApi } from './admin-gateway-api.js';
@@ -219,7 +219,33 @@ export function createCoreServer(opts: CoreServerOptions): {
app.use('/api/local/reflection', express.json());
// === Auth setup ===
const authActive = !!(opts.authConfig?.providers);
// Auth activates when a provider is COMPLETELY configured (clientId +
// clientSecret + callbackUrl, plus baseUrl for Gitea).
//
// FAIL CLOSED on a partial config: if the operator clearly INTENDED auth
// (a provider has a client_id) but it's incomplete (typo'd / missing
// secret/callback), we must NOT silently fall back to no-auth — that would
// fail OPEN and expose /api/local, /api/config, etc. without authentication.
// Refuse to start instead, with a clear message. (A bare `auth` block with no
// client_id at all is treated as genuine no-auth mode.)
const _authProviders = opts.authConfig?.providers;
const authUsable =
isProviderConfigured(_authProviders?.google, 'google') ||
isProviderConfigured(_authProviders?.gitea, 'gitea');
// "Intended" = ANY OAuth field is present on a provider (not just client_id).
// Saving only client_secret/callback_url/base_url, or clearing client_id by
// mistake, must still fail closed rather than drop to no-auth.
const _hasAnyField = (p?: { clientId?: string; clientSecret?: string; callbackUrl?: string; baseUrl?: string }) =>
!!(p?.clientId || p?.clientSecret || p?.callbackUrl || p?.baseUrl);
const authIntended = _hasAnyField(_authProviders?.google) || _hasAnyField(_authProviders?.gitea);
if (authIntended && !authUsable) {
throw new Error(
'[auth] auth is partially configured: a provider has a client_id but is missing ' +
'client_secret / callback_url (Gitea also needs base_url). Refusing to start in an ' +
'insecure no-auth state — complete the provider config or remove it from config.yaml.',
);
}
const authActive = authUsable;
let authenticateUpgrade: import('./auth.js').UpgradeAuthChecker | undefined;
if (authActive) {