diff --git a/src/core/server/server.ts b/src/core/server/server.ts index dbaee6c12400..47a72cfe6cbb 100644 --- a/src/core/server/server.ts +++ b/src/core/server/server.ts @@ -261,10 +261,7 @@ export class Server { opensearch: opensearchStart, savedObjects: savedObjectsStart, }); - await this.workspaces.start({ - savedObjects: savedObjectsStart, - uiSettings: uiSettingsStart, - }); + await this.workspaces.start(); this.coreStart = { capabilities: capabilitiesStart, diff --git a/src/core/server/workspaces/workspaces_service.ts b/src/core/server/workspaces/workspaces_service.ts index cac4b551650b..f86c0e7ca4d3 100644 --- a/src/core/server/workspaces/workspaces_service.ts +++ b/src/core/server/workspaces/workspaces_service.ts @@ -8,13 +8,9 @@ import { CoreContext } from '../core_context'; import { InternalHttpServiceSetup } from '../http'; import { Logger } from '../logging'; import { registerRoutes } from './routes'; -import { - InternalSavedObjectsServiceSetup, - InternalSavedObjectsServiceStart, -} from '../saved_objects'; +import { InternalSavedObjectsServiceSetup } from '../saved_objects'; import { IWorkspaceDBImpl } from './types'; import { WorkspacesClientWithSavedObject } from './workspaces_client'; -import { UiSettingsServiceStart } from '../ui_settings/types'; import { WorkspaceSavedObjectsClientWrapper } from './saved_objects'; export interface WorkspacesServiceSetup { @@ -33,47 +29,27 @@ export interface WorkspacesSetupDeps { export type InternalWorkspacesServiceSetup = WorkspacesServiceSetup; export type InternalWorkspacesServiceStart = WorkspacesServiceStart; -/** @internal */ -export interface WorkspacesStartDeps { - savedObjects: InternalSavedObjectsServiceStart; - uiSettings: UiSettingsServiceStart; -} - export class WorkspacesService implements CoreService { private logger: Logger; private client?: IWorkspaceDBImpl; - private startDeps?: WorkspacesStartDeps; + constructor(coreContext: CoreContext) { this.logger = coreContext.logger.get('workspaces-service'); } private proxyWorkspaceTrafficToRealHandler(setupDeps: WorkspacesSetupDeps) { /** - * Proxy all {basePath}/w/{workspaceId}{osdPath*} paths to - * {basePath}{osdPath*} when workspace is enabled - * - * Return HTTP 404 if accessing {basePath}/w/{workspaceId} when workspace is disabled + * Proxy all {basePath}/w/{workspaceId}{osdPath*} paths to {basePath}{osdPath*} */ setupDeps.http.registerOnPreRouting(async (request, response, toolkit) => { const regexp = /\/w\/([^\/]*)/; const matchedResult = request.url.pathname.match(regexp); if (matchedResult) { - if (this.startDeps) { - const savedObjectsClient = this.startDeps.savedObjects.getScopedClient(request); - const uiSettingsClient = this.startDeps.uiSettings.asScopedToClient(savedObjectsClient); - const workspacesEnabled = await uiSettingsClient.get('workspace:enabled'); - - if (workspacesEnabled) { - const requestUrl = new URL(request.url.toString()); - requestUrl.pathname = requestUrl.pathname.replace(regexp, ''); - return toolkit.rewriteUrl(requestUrl.toString()); - } else { - // If workspace was disable, return HTTP 404 - return response.notFound(); - } - } + const requestUrl = new URL(request.url.toString()); + requestUrl.pathname = requestUrl.pathname.replace(regexp, ''); + return toolkit.rewriteUrl(requestUrl.toString()); } return toolkit.next(); }); @@ -108,8 +84,7 @@ export class WorkspacesService }; } - public async start(deps: WorkspacesStartDeps): Promise { - this.startDeps = deps; + public async start(): Promise { this.logger.debug('Starting SavedObjects service'); return {