catalog-backend: remove CatalogPermissionRule type
Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
@@ -306,13 +306,6 @@ export type CatalogEnvironment = {
|
||||
permissions: PermissionAuthorizer;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type CatalogPermissionRule<TParams extends unknown[]> = PermissionRule<
|
||||
Entity,
|
||||
EntitiesSearchFilter,
|
||||
TParams
|
||||
>;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "CatalogProcessingEngine" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
@@ -531,8 +524,8 @@ export class CommonDatabase implements Database {
|
||||
|
||||
// @public
|
||||
export const createCatalogPermissionRule: <TParams extends unknown[]>(
|
||||
rule: CatalogPermissionRule<TParams>,
|
||||
) => CatalogPermissionRule<TParams>;
|
||||
rule: PermissionRule<Entity, EntitiesSearchFilter, TParams>,
|
||||
) => PermissionRule<Entity, EntitiesSearchFilter, TParams>;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "CreateDatabaseOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
@@ -1318,7 +1311,11 @@ export class NextCatalogBuilder {
|
||||
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
|
||||
addEntityProvider(...providers: EntityProvider[]): NextCatalogBuilder;
|
||||
addPermissionRules(
|
||||
...permissionRules: CatalogPermissionRule<unknown[]>[]
|
||||
...permissionRules: PermissionRule<
|
||||
Entity,
|
||||
EntitiesSearchFilter,
|
||||
unknown[]
|
||||
>[]
|
||||
): void;
|
||||
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
|
||||
addProcessor(...processors: CatalogProcessor[]): NextCatalogBuilder;
|
||||
@@ -1367,7 +1364,7 @@ export interface NextRouterOptions {
|
||||
// (undocumented)
|
||||
logger: Logger_2;
|
||||
// (undocumented)
|
||||
permissionRules?: CatalogPermissionRule<unknown[]>[];
|
||||
permissionRules?: PermissionRule<Entity, EntitiesSearchFilter, unknown[]>[];
|
||||
// (undocumented)
|
||||
refreshService?: RefreshService;
|
||||
}
|
||||
@@ -1402,12 +1399,28 @@ export function parseEntityYaml(
|
||||
|
||||
// @public
|
||||
export const permissionRules: {
|
||||
hasAnnotation: CatalogPermissionRule<[annotation: string]>;
|
||||
hasLabel: CatalogPermissionRule<[label: string]>;
|
||||
hasMetadata: CatalogPermissionRule<[key: string, value?: string | undefined]>;
|
||||
hasSpec: CatalogPermissionRule<[key: string, value?: string | undefined]>;
|
||||
isEntityKind: CatalogPermissionRule<[kinds: string[]]>;
|
||||
isEntityOwner: CatalogPermissionRule<[claims: string[]]>;
|
||||
hasAnnotation: PermissionRule<
|
||||
Entity,
|
||||
EntitiesSearchFilter,
|
||||
[annotation: string]
|
||||
>;
|
||||
hasLabel: PermissionRule<Entity, EntitiesSearchFilter, [label: string]>;
|
||||
hasMetadata: PermissionRule<
|
||||
Entity,
|
||||
EntitiesSearchFilter,
|
||||
[key: string, value?: string | undefined]
|
||||
>;
|
||||
hasSpec: PermissionRule<
|
||||
Entity,
|
||||
EntitiesSearchFilter,
|
||||
[key: string, value?: string | undefined]
|
||||
>;
|
||||
isEntityKind: PermissionRule<Entity, EntitiesSearchFilter, [kinds: string[]]>;
|
||||
isEntityOwner: PermissionRule<
|
||||
Entity,
|
||||
EntitiesSearchFilter,
|
||||
[claims: string[]]
|
||||
>;
|
||||
};
|
||||
|
||||
// Warning: (ae-missing-release-tag) "PlaceholderProcessor" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
|
||||
@@ -15,4 +15,3 @@
|
||||
*/
|
||||
|
||||
export * from './rules';
|
||||
export type { CatalogPermissionRule } from './types';
|
||||
|
||||
@@ -18,8 +18,9 @@ import { Entity } from '@backstage/catalog-model';
|
||||
import { createCatalogPermissionRule } from './util';
|
||||
|
||||
/**
|
||||
* A {@link CatalogPermissionRule} which filters for the presence of an
|
||||
* annotation on a given entity.
|
||||
* A catalog {@link @backstage/plugin-permission-node#PermissionRule} which
|
||||
* filters for the presence of an annotation on a given entity.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const hasAnnotation = createCatalogPermissionRule({
|
||||
|
||||
@@ -18,8 +18,8 @@ import { Entity } from '@backstage/catalog-model';
|
||||
import { createCatalogPermissionRule } from './util';
|
||||
|
||||
/**
|
||||
* A {@link CatalogPermissionRule} which filters for entities with a specified
|
||||
* label in its metadata.
|
||||
* A catalog {@link @backstage/plugin-permission-node#PermissionRule} which
|
||||
* filters for entities with a specified label in its metadata.
|
||||
* @public
|
||||
*/
|
||||
export const hasLabel = createCatalogPermissionRule({
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
import { createPropertyRule } from './createPropertyRule';
|
||||
|
||||
/**
|
||||
* A {@link CatalogPermissionRule} which filters for entities with the specified
|
||||
* metadata subfield. Also matches on values if value is provided.
|
||||
* A catalog {@link @backstage/plugin-permission-node#PermissionRule} which
|
||||
* filters for entities with the specified metadata subfield. Also matches on
|
||||
* values if value is provided.
|
||||
*
|
||||
* The key argument to the `apply` and `toQuery` methods can be nested, such as
|
||||
* 'field.nestedfield'.
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
import { createPropertyRule } from './createPropertyRule';
|
||||
|
||||
/**
|
||||
* A {@link CatalogPermissionRule} which filters for entities with the specified
|
||||
* spec subfield. Also matches on values if value is provided.
|
||||
* A catalog {@link @backstage/plugin-permission-node#PermissionRule} which
|
||||
* filters for entities with the specified spec subfield. Also matches on values
|
||||
* if value is provided.
|
||||
*
|
||||
* The key argument to the `apply` and `toQuery` methods can be nested, such as
|
||||
* 'field.nestedfield'.
|
||||
|
||||
@@ -18,8 +18,8 @@ import { EntitiesSearchFilter } from '../../catalog/types';
|
||||
import { createCatalogPermissionRule } from './util';
|
||||
|
||||
/**
|
||||
* A {@link CatalogPermissionRule} which filters for entities with a specified
|
||||
* kind.
|
||||
* A catalog {@link @backstage/plugin-permission-node#PermissionRule} which
|
||||
* filters for entities with a specified kind.
|
||||
* @public
|
||||
*/
|
||||
export const isEntityKind = createCatalogPermissionRule({
|
||||
|
||||
@@ -22,8 +22,8 @@ import {
|
||||
import { createCatalogPermissionRule } from './util';
|
||||
|
||||
/**
|
||||
* A {@link CatalogPermissionRule} which filters for entities with a specified
|
||||
* owner.
|
||||
* A catalog {@link @backstage/plugin-permission-node#PermissionRule} which
|
||||
* filters for entities with a specified owner.
|
||||
* @public
|
||||
*/
|
||||
export const isEntityOwner = createCatalogPermissionRule({
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { CatalogPermissionRule } from '../types';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { makeCreatePermissionRule } from '@backstage/plugin-permission-node';
|
||||
import { EntitiesSearchFilter } from '../../catalog/types';
|
||||
|
||||
/**
|
||||
* Helper function for creating correctly-typed
|
||||
@@ -23,6 +25,7 @@ import { CatalogPermissionRule } from '../types';
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const createCatalogPermissionRule = <TParams extends unknown[]>(
|
||||
rule: CatalogPermissionRule<TParams>,
|
||||
) => rule;
|
||||
export const createCatalogPermissionRule = makeCreatePermissionRule<
|
||||
Entity,
|
||||
EntitiesSearchFilter
|
||||
>();
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2021 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { PermissionRule } from '@backstage/plugin-permission-node';
|
||||
import { EntitiesSearchFilter } from '../catalog/types';
|
||||
|
||||
/**
|
||||
* A conditional rule that can be used to filter catalog entities for an
|
||||
* authorization request. See
|
||||
* {@link @backstage/plugin-permission-node#PermissionRule} for more details.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type CatalogPermissionRule<TParams extends unknown[]> = PermissionRule<
|
||||
Entity,
|
||||
EntitiesSearchFilter,
|
||||
TParams
|
||||
>;
|
||||
@@ -17,6 +17,7 @@
|
||||
import { PluginDatabaseManager, UrlReader } from '@backstage/backend-common';
|
||||
import {
|
||||
DefaultNamespaceEntityPolicy,
|
||||
Entity,
|
||||
EntityPolicies,
|
||||
EntityPolicy,
|
||||
FieldFormatEntityPolicy,
|
||||
@@ -29,7 +30,7 @@ import { ScmIntegrations } from '@backstage/integration';
|
||||
import { createHash } from 'crypto';
|
||||
import { Router } from 'express';
|
||||
import lodash from 'lodash';
|
||||
import { EntitiesCatalog } from '../catalog';
|
||||
import { EntitiesCatalog, EntitiesSearchFilter } from '../catalog';
|
||||
import {
|
||||
DatabaseLocationsCatalog,
|
||||
LocationsCatalog,
|
||||
@@ -83,9 +84,9 @@ import { Config } from '@backstage/config';
|
||||
import { Logger } from 'winston';
|
||||
import { LocationService } from './types';
|
||||
import { connectEntityProviders } from '../processing/connectEntityProviders';
|
||||
import { CatalogPermissionRule } from '../permissions/types';
|
||||
import { permissionRules as catalogPermissionRules } from '../permissions/rules';
|
||||
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
|
||||
import { PermissionRule } from '@backstage/plugin-permission-node';
|
||||
|
||||
export type CatalogEnvironment = {
|
||||
logger: Logger;
|
||||
@@ -130,7 +131,11 @@ export class NextCatalogBuilder {
|
||||
maxSeconds: 150,
|
||||
});
|
||||
private locationAnalyzer: LocationAnalyzer | undefined = undefined;
|
||||
private permissionRules: CatalogPermissionRule<unknown[]>[];
|
||||
private permissionRules: PermissionRule<
|
||||
Entity,
|
||||
EntitiesSearchFilter,
|
||||
unknown[]
|
||||
>[];
|
||||
|
||||
constructor(env: CatalogEnvironment) {
|
||||
this.env = env;
|
||||
@@ -331,7 +336,13 @@ export class NextCatalogBuilder {
|
||||
*
|
||||
* @param permissionRules - Additional permission rules
|
||||
*/
|
||||
addPermissionRules(...permissionRules: CatalogPermissionRule<unknown[]>[]) {
|
||||
addPermissionRules(
|
||||
...permissionRules: PermissionRule<
|
||||
Entity,
|
||||
EntitiesSearchFilter,
|
||||
unknown[]
|
||||
>[]
|
||||
) {
|
||||
this.permissionRules.push(...permissionRules);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,14 +25,16 @@ import {
|
||||
import { Config } from '@backstage/config';
|
||||
import { NotFoundError } from '@backstage/errors';
|
||||
import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common';
|
||||
import { createPermissionIntegrationRouter } from '@backstage/plugin-permission-node';
|
||||
import {
|
||||
createPermissionIntegrationRouter,
|
||||
PermissionRule,
|
||||
} from '@backstage/plugin-permission-node';
|
||||
import express from 'express';
|
||||
import Router from 'express-promise-router';
|
||||
import { Logger } from 'winston';
|
||||
import yn from 'yn';
|
||||
import { EntitiesCatalog } from '../catalog';
|
||||
import { EntitiesCatalog, EntitiesSearchFilter } from '../catalog';
|
||||
import { LocationAnalyzer } from '../ingestion/types';
|
||||
import { CatalogPermissionRule } from '../permissions/types';
|
||||
import {
|
||||
basicEntityFilter,
|
||||
parseEntityFilterParams,
|
||||
@@ -49,7 +51,7 @@ export interface NextRouterOptions {
|
||||
refreshService?: RefreshService;
|
||||
logger: Logger;
|
||||
config: Config;
|
||||
permissionRules?: CatalogPermissionRule<unknown[]>[];
|
||||
permissionRules?: PermissionRule<Entity, EntitiesSearchFilter, unknown[]>[];
|
||||
}
|
||||
|
||||
export async function createNextRouter(
|
||||
|
||||
Reference in New Issue
Block a user