diff --git a/.changeset/cyan-turtles-relax.md b/.changeset/cyan-turtles-relax.md
new file mode 100644
index 0000000000..4f7857c30c
--- /dev/null
+++ b/.changeset/cyan-turtles-relax.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-catalog-common': patch
+---
+
+Adds new `catalogEntityCreatePermission` which can be imported and used when authoring a permission policy to restrict/grant a user's access to the catalog import plugin. (And the "Register Existing Component" button which navigates there).
diff --git a/.changeset/fresh-insects-attack.md b/.changeset/fresh-insects-attack.md
new file mode 100644
index 0000000000..3c22df67c0
--- /dev/null
+++ b/.changeset/fresh-insects-attack.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-scaffolder': patch
+---
+
+Permission the Register Existing Component button
diff --git a/.changeset/silver-eagles-reply.md b/.changeset/silver-eagles-reply.md
new file mode 100644
index 0000000000..db69525768
--- /dev/null
+++ b/.changeset/silver-eagles-reply.md
@@ -0,0 +1,25 @@
+---
+'@backstage/create-app': patch
+---
+
+Permission the `catalog-import` route
+
+The following changes are **required** if you intend to add permissions to your existing app.
+
+Use the `PermissionedRoute` for `CatalogImportPage` instead of the normal `Route`:
+
+```diff
+// packages/app/src/App.tsx
+...
++ import { PermissionedRoute } from '@backstage/plugin-permission-react';
++ import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common';
+
+...
+
+- } />
++ }
++ />
+```
diff --git a/packages/app/package.json b/packages/app/package.json
index 6f2e921c81..c6e7be8c5d 100644
--- a/packages/app/package.json
+++ b/packages/app/package.json
@@ -17,6 +17,7 @@
"@backstage/plugin-apache-airflow": "^0.1.5-next.0",
"@backstage/plugin-badges": "^0.2.21-next.0",
"@backstage/plugin-catalog": "^0.7.11-next.0",
+ "@backstage/plugin-catalog-common": "^0.1.1",
"@backstage/plugin-catalog-graph": "^0.2.9-next.0",
"@backstage/plugin-catalog-import": "^0.8.0-next.0",
"@backstage/plugin-catalog-react": "^0.6.13-next.0",
@@ -38,6 +39,7 @@
"@backstage/plugin-newrelic-dashboard": "^0.1.5-next.0",
"@backstage/plugin-org": "^0.4.1-next.0",
"@backstage/plugin-pagerduty": "0.3.24-next.0",
+ "@backstage/plugin-permission-react": "^0.3.0",
"@backstage/plugin-rollbar": "^0.3.25-next.0",
"@backstage/plugin-scaffolder": "^0.12.1-next.0",
"@backstage/plugin-search": "^0.6.1-next.0",
diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx
index 9be424a145..345915189a 100644
--- a/packages/app/src/App.tsx
+++ b/packages/app/src/App.tsx
@@ -86,6 +86,8 @@ import * as plugins from './plugins';
import { techDocsPage } from './components/techdocs/TechDocsPage';
import { ApacheAirflowPage } from '@backstage/plugin-apache-airflow';
+import { PermissionedRoute } from '@backstage/plugin-permission-react';
+import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common';
const app = createApp({
apis,
@@ -140,7 +142,11 @@ const routes = (
>
{entityPage}
- } />
+ }
+ />
}
/>
- } />
+ }
+ />
}>
{searchPage}
diff --git a/plugins/catalog-common/api-report.md b/plugins/catalog-common/api-report.md
index e2ee2d3225..9826a8ddef 100644
--- a/plugins/catalog-common/api-report.md
+++ b/plugins/catalog-common/api-report.md
@@ -5,6 +5,9 @@
```ts
import { Permission } from '@backstage/plugin-permission-common';
+// @public
+export const catalogEntityCreatePermission: Permission;
+
// @public
export const catalogEntityDeletePermission: Permission;
diff --git a/plugins/catalog-common/src/index.ts b/plugins/catalog-common/src/index.ts
index 05d5ed2ba5..9eddf37452 100644
--- a/plugins/catalog-common/src/index.ts
+++ b/plugins/catalog-common/src/index.ts
@@ -24,6 +24,7 @@
export {
RESOURCE_TYPE_CATALOG_ENTITY,
catalogEntityReadPermission,
+ catalogEntityCreatePermission,
catalogEntityDeletePermission,
catalogEntityRefreshPermission,
catalogLocationReadPermission,
diff --git a/plugins/catalog-common/src/permissions.ts b/plugins/catalog-common/src/permissions.ts
index b4c6c4377c..52c225e441 100644
--- a/plugins/catalog-common/src/permissions.ts
+++ b/plugins/catalog-common/src/permissions.ts
@@ -38,6 +38,20 @@ export const catalogEntityReadPermission: Permission = {
resourceType: RESOURCE_TYPE_CATALOG_ENTITY,
};
+/**
+ * This permission is used to authorize actions that involve creating a new
+ * catalog entity. This includes registering an existing component into the
+ * catalog.
+ * @public
+ */
+export const catalogEntityCreatePermission: Permission = {
+ name: 'catalog.entity.create',
+ attributes: {
+ action: 'create',
+ },
+ resourceType: RESOURCE_TYPE_CATALOG_ENTITY,
+};
+
/**
* This permission is used to designate actions that involve removing one or
* more entities from the catalog.
diff --git a/plugins/scaffolder/package.json b/plugins/scaffolder/package.json
index 8a48e7b29f..a85d13f56e 100644
--- a/plugins/scaffolder/package.json
+++ b/plugins/scaffolder/package.json
@@ -39,7 +39,9 @@
"@backstage/errors": "^0.2.0",
"@backstage/integration": "^0.7.2",
"@backstage/integration-react": "^0.1.20-next.0",
+ "@backstage/plugin-catalog-common": "^0.1.1",
"@backstage/plugin-catalog-react": "^0.6.13-next.0",
+ "@backstage/plugin-permission-react": "^0.3.0",
"@backstage/plugin-scaffolder-common": "^0.1.3",
"@backstage/theme": "^0.2.14",
"@backstage/types": "^0.1.1",
diff --git a/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx b/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx
index c147c8e118..116b7ed82a 100644
--- a/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx
+++ b/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx
@@ -37,6 +37,8 @@ import React, { ComponentType } from 'react';
import { registerComponentRouteRef } from '../../routes';
import { TemplateList } from '../TemplateList';
import { TemplateTypePicker } from '../TemplateTypePicker';
+import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common';
+import { usePermission } from '@backstage/plugin-permission-react';
const useStyles = makeStyles(theme => ({
contentWrapper: {
@@ -72,6 +74,8 @@ export const ScaffolderPageContents = ({
},
};
+ const { allowed } = usePermission(catalogEntityCreatePermission);
+
return (
-
+ {allowed && (
+
+ )}
Create new software components using standard templates. Different
templates create different kinds of components (services, websites,