diff --git a/plugins/catalog-backend/src/service/AuthorizedLocationAnalyzer.ts b/plugins/catalog-backend/src/service/AuthorizedLocationAnalyzer.ts index 3968a0ab73..de0cc189b3 100644 --- a/plugins/catalog-backend/src/service/AuthorizedLocationAnalyzer.ts +++ b/plugins/catalog-backend/src/service/AuthorizedLocationAnalyzer.ts @@ -17,7 +17,10 @@ import { NotAllowedError } from '@backstage/errors'; import { catalogLocationCreatePermission } from '@backstage/plugin-catalog-common/alpha'; import { AuthorizeResult } from '@backstage/plugin-permission-common'; -import { PermissionsService } from '@backstage/backend-plugin-api'; +import { + BackstageCredentials, + PermissionsService, +} from '@backstage/backend-plugin-api'; import { LocationAnalyzer } from '@backstage/plugin-catalog-node'; import { AnalyzeLocationRequest } from '@backstage/plugin-catalog-common'; import { AnalyzeLocationResponse } from '@backstage/plugin-catalog-common'; @@ -30,6 +33,7 @@ export class AuthorizedLocationAnalyzer implements LocationAnalyzer { async analyzeLocation( request: AnalyzeLocationRequest, + credentials: BackstageCredentials, ): Promise { const authorizeDecision = ( await this.permissionApi.authorize( @@ -38,12 +42,12 @@ export class AuthorizedLocationAnalyzer implements LocationAnalyzer { permission: catalogLocationCreatePermission, }, ], - { credentials: request.credentials }, + { credentials: credentials }, ) )[0]; if (authorizeDecision.result !== AuthorizeResult.ALLOW) { throw new NotAllowedError(); } - return this.service.analyzeLocation(request); + return this.service.analyzeLocation(request, credentials); } } diff --git a/plugins/catalog-backend/src/service/createRouter.ts b/plugins/catalog-backend/src/service/createRouter.ts index abba18b0fe..70e8054909 100644 --- a/plugins/catalog-backend/src/service/createRouter.ts +++ b/plugins/catalog-backend/src/service/createRouter.ts @@ -303,10 +303,10 @@ export async function createRouter( }); const credentials = await httpAuth.credentials(req); const parsedBody = schema.parse(body); - const analyzeLocationRequest = { ...parsedBody, credentials }; try { const output = await locationAnalyzer.analyzeLocation( - analyzeLocationRequest, + parsedBody, + credentials, ); res.status(200).json(output); } catch (err) { diff --git a/plugins/catalog-common/package.json b/plugins/catalog-common/package.json index e4eee51e7f..cfcfee74d8 100644 --- a/plugins/catalog-common/package.json +++ b/plugins/catalog-common/package.json @@ -56,7 +56,6 @@ "test": "backstage-cli package test" }, "dependencies": { - "@backstage/backend-plugin-api": "workspace:^", "@backstage/catalog-model": "workspace:^", "@backstage/plugin-permission-common": "workspace:^", "@backstage/plugin-search-common": "workspace:^" diff --git a/plugins/catalog-common/src/ingestion/LocationAnalyzer.ts b/plugins/catalog-common/src/ingestion/LocationAnalyzer.ts index 8dd40a015e..08ae5ef0cb 100644 --- a/plugins/catalog-common/src/ingestion/LocationAnalyzer.ts +++ b/plugins/catalog-common/src/ingestion/LocationAnalyzer.ts @@ -17,13 +17,11 @@ import { LocationSpec } from '../common'; import { Entity } from '@backstage/catalog-model'; import { RecursivePartial } from './RecursivePartial'; -import { BackstageCredentials } from '@backstage/backend-plugin-api'; /** @public */ export type AnalyzeLocationRequest = { location: LocationSpec; catalogFilename?: string; - credentials: BackstageCredentials; }; /** @public */ diff --git a/plugins/catalog-node/api-report.md b/plugins/catalog-node/api-report.md index 7c1c8b5911..383f1b5072 100644 --- a/plugins/catalog-node/api-report.md +++ b/plugins/catalog-node/api-report.md @@ -172,6 +172,7 @@ export type EntityRelationSpec = { export type LocationAnalyzer = { analyzeLocation( location: AnalyzeLocationRequest, + credentials: BackstageCredentials ): Promise; }; diff --git a/plugins/catalog-node/src/processing/types.ts b/plugins/catalog-node/src/processing/types.ts index e3d3c305fc..625effc4df 100644 --- a/plugins/catalog-node/src/processing/types.ts +++ b/plugins/catalog-node/src/processing/types.ts @@ -22,6 +22,7 @@ import { } from '@backstage/plugin-catalog-common'; import { JsonValue } from '@backstage/types'; import { CatalogProcessorEmit } from '../api'; +import { BackstageCredentials } from '@backstage/backend-plugin-api'; /** * Entities that are not yet processed. @@ -66,6 +67,7 @@ export type LocationAnalyzer = { */ analyzeLocation( location: AnalyzeLocationRequest, + credentials: BackstageCredentials, ): Promise; }; diff --git a/yarn.lock b/yarn.lock index c3d374b1cd..d489203875 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5742,7 +5742,6 @@ __metadata: version: 0.0.0-use.local resolution: "@backstage/plugin-catalog-common@workspace:plugins/catalog-common" dependencies: - "@backstage/backend-plugin-api": "workspace:^" "@backstage/catalog-model": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/plugin-permission-common": "workspace:^"