diff --git a/src/core/server/index.ts b/src/core/server/index.ts index bee904ac5adc0..30c024239fdec 100644 --- a/src/core/server/index.ts +++ b/src/core/server/index.ts @@ -233,7 +233,7 @@ export type { SafeRouteMethod, } from './http'; -export { kibanaResponseFactory, validBodyOutput } from './http'; +export { kibanaResponseFactory, validBodyOutput, CoreKibanaRequest } from './http'; export type { KibanaRequest } from './http'; export type { diff --git a/x-pack/plugins/actions/server/lib/task_runner_factory.ts b/x-pack/plugins/actions/server/lib/task_runner_factory.ts index 3c94c243b56a5..51672865d6771 100644 --- a/x-pack/plugins/actions/server/lib/task_runner_factory.ts +++ b/x-pack/plugins/actions/server/lib/task_runner_factory.ts @@ -14,6 +14,7 @@ import { Logger, SavedObjectsClientContract, KibanaRequest, + CoreKibanaRequest, SavedObjectReference, IBasePath, SavedObject, @@ -226,7 +227,7 @@ function getFakeRequest(apiKey?: string) { // Since we're using API keys and accessing elasticsearch can only be done // via a request, we're faking one with the proper authorization headers. - const fakeRequest = KibanaRequest.from({ + const fakeRequest = CoreKibanaRequest.from({ headers: requestHeaders, path: '/', route: { settings: {} }, diff --git a/x-pack/plugins/alerting/server/task_runner/rule_loader.ts b/x-pack/plugins/alerting/server/task_runner/rule_loader.ts index 2019226c537fb..75fcff9f4510f 100644 --- a/x-pack/plugins/alerting/server/task_runner/rule_loader.ts +++ b/x-pack/plugins/alerting/server/task_runner/rule_loader.ts @@ -8,7 +8,7 @@ import { PublicMethodsOf } from '@kbn/utility-types'; import type { Request } from '@hapi/hapi'; import { addSpaceIdToPath } from '@kbn/spaces-plugin/server'; -import { KibanaRequest } from '@kbn/core/server'; +import { CoreKibanaRequest } from '@kbn/core/server'; import { TaskRunnerContext } from './task_runner_factory'; import { ErrorWithReason, validateRuleTypeParams } from '../lib'; import { @@ -127,7 +127,7 @@ export function getFakeKibanaRequest( const path = addSpaceIdToPath('/', spaceId); - const fakeRequest = KibanaRequest.from({ + const fakeRequest = CoreKibanaRequest.from({ headers: requestHeaders, path: '/', route: { settings: {} }, diff --git a/x-pack/plugins/reporting/server/core.ts b/x-pack/plugins/reporting/server/core.ts index 44a2d29a141cf..51bf6b801df3e 100644 --- a/x-pack/plugins/reporting/server/core.ts +++ b/x-pack/plugins/reporting/server/core.ts @@ -17,7 +17,7 @@ import type { StatusServiceSetup, UiSettingsServiceStart, } from '@kbn/core/server'; -import { KibanaRequest, ServiceStatusLevels } from '@kbn/core/server'; +import { KibanaRequest, CoreKibanaRequest, ServiceStatusLevels } from '@kbn/core/server'; import type { PluginStart as DataPluginStart } from '@kbn/data-plugin/server'; import type { PluginSetupContract as FeaturesPluginSetup } from '@kbn/features-plugin/server'; import type { FieldFormatsStart } from '@kbn/field-formats-plugin/server'; @@ -322,7 +322,7 @@ export class ReportingCore { } public getFakeRequest(baseRequest: object, spaceId: string | undefined, logger = this.logger) { - const fakeRequest = KibanaRequest.from({ + const fakeRequest = CoreKibanaRequest.from({ path: '/', route: { settings: {} }, url: { href: '/' }, diff --git a/x-pack/plugins/security/server/anonymous_access/anonymous_access_service.ts b/x-pack/plugins/security/server/anonymous_access/anonymous_access_service.ts index 6507f579841c3..f7d1b53468d57 100644 --- a/x-pack/plugins/security/server/anonymous_access/anonymous_access_service.ts +++ b/x-pack/plugins/security/server/anonymous_access/anonymous_access_service.ts @@ -14,7 +14,7 @@ import type { IClusterClient, Logger, } from '@kbn/core/server'; -import { KibanaRequest } from '@kbn/core/server'; +import { KibanaRequest, CoreKibanaRequest } from '@kbn/core/server'; import { addSpaceIdToPath } from '@kbn/spaces-plugin/common'; import type { SpacesServiceStart } from '@kbn/spaces-plugin/server'; @@ -165,7 +165,7 @@ export class AnonymousAccessService { * anonymous service account credentials. */ private createFakeAnonymousRequest({ authenticateRequest }: { authenticateRequest: boolean }) { - return KibanaRequest.from({ + return CoreKibanaRequest.from({ headers: authenticateRequest && this.httpAuthorizationHeader ? { authorization: this.httpAuthorizationHeader.toString() } diff --git a/x-pack/plugins/security/server/authentication/authenticator.ts b/x-pack/plugins/security/server/authentication/authenticator.ts index 7f42bde1e397d..5ed6ca853decd 100644 --- a/x-pack/plugins/security/server/authentication/authenticator.ts +++ b/x-pack/plugins/security/server/authentication/authenticator.ts @@ -6,7 +6,7 @@ */ import type { IBasePath, IClusterClient, LoggerFactory } from '@kbn/core/server'; -import { KibanaRequest } from '@kbn/core/server'; +import { KibanaRequest, CoreKibanaRequest } from '@kbn/core/server'; import type { Logger } from '@kbn/logging'; import type { PublicMethodsOf } from '@kbn/utility-types'; @@ -131,7 +131,7 @@ const ACCESS_AGREEMENT_ROUTE = '/security/access_agreement'; const OVERWRITTEN_SESSION_ROUTE = '/security/overwritten_session'; function assertRequest(request: KibanaRequest) { - if (!(request instanceof KibanaRequest)) { + if (!(request instanceof CoreKibanaRequest)) { throw new Error(`Request should be a valid "KibanaRequest" instance, was [${typeof request}].`); } }