diff --git a/plugins/scaffolder-common/package.json b/plugins/scaffolder-common/package.json index c08763d98b..d315754462 100644 --- a/plugins/scaffolder-common/package.json +++ b/plugins/scaffolder-common/package.json @@ -39,6 +39,7 @@ }, "dependencies": { "@backstage/catalog-model": "workspace:^", + "@backstage/plugin-permission-common": "workspace:^", "@backstage/types": "workspace:^" }, "devDependencies": { diff --git a/plugins/scaffolder-common/src/index.ts b/plugins/scaffolder-common/src/index.ts index 7f9792a1ba..4953a27f9e 100644 --- a/plugins/scaffolder-common/src/index.ts +++ b/plugins/scaffolder-common/src/index.ts @@ -25,4 +25,5 @@ export { templateEntityV1beta3Validator, isTemplateEntityV1beta3, } from './TemplateEntityV1beta3'; +export * from './permissions'; export type { TemplateEntityV1beta3 } from './TemplateEntityV1beta3'; diff --git a/plugins/scaffolder-common/src/permissions.ts b/plugins/scaffolder-common/src/permissions.ts new file mode 100644 index 0000000000..578ef09311 --- /dev/null +++ b/plugins/scaffolder-common/src/permissions.ts @@ -0,0 +1,29 @@ +/* + * Copyright 2022 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 { createPermission } from '@backstage/plugin-permission-common'; + +export const RESOURCE_TYPE_SCAFFOLDER_TEMPLATE = 'scaffolder-field'; + +export const templateSchemaExecutePermission = createPermission({ + name: 'scaffolder.template.schema.execute', + attributes: { + action: 'create', + }, + resourceType: RESOURCE_TYPE_SCAFFOLDER_TEMPLATE, +}); + +export const scaffolderPermissions = [templateSchemaExecutePermission];