backstage

Форк
0
104 строки · 2.8 Кб
1
/*
2
 * Copyright 2022 The Backstage Authors
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
import { createPermission } from '@backstage/plugin-permission-common';
18

19
/**
20
 * Permission resource type which corresponds to a scaffolder templates.
21
 *
22
 * @alpha
23
 */
24
export const RESOURCE_TYPE_SCAFFOLDER_TEMPLATE = 'scaffolder-template';
25

26
/**
27
 * Permission resource type which corresponds to a scaffolder action.
28
 *
29
 * @alpha
30
 */
31
export const RESOURCE_TYPE_SCAFFOLDER_ACTION = 'scaffolder-action';
32

33
/**
34
 * This permission is used to authorize actions that involve executing
35
 * an action from a template.
36
 *
37
 * @alpha
38
 */
39
export const actionExecutePermission = createPermission({
40
  name: 'scaffolder.action.execute',
41
  attributes: {},
42
  resourceType: RESOURCE_TYPE_SCAFFOLDER_ACTION,
43
});
44

45
/**
46
 * This permission is used to authorize actions that involve reading
47
 * one or more parameters from a template.
48
 *
49
 * If this permission is not authorized, it will appear that the
50
 * parameter does not exist in the template — both in the frontend
51
 * and in API responses.
52
 *
53
 * @alpha
54
 */
55
export const templateParameterReadPermission = createPermission({
56
  name: 'scaffolder.template.parameter.read',
57
  attributes: {
58
    action: 'read',
59
  },
60
  resourceType: RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,
61
});
62

63
/**
64
 * This permission is used to authorize actions that involve reading
65
 * one or more steps from a template.
66
 *
67
 * If this permission is not authorized, it will appear that the
68
 * step does not exist in the template — both in the frontend
69
 * and in API responses. Steps will also not be executed.
70
 *
71
 * @alpha
72
 */
73
export const templateStepReadPermission = createPermission({
74
  name: 'scaffolder.template.step.read',
75
  attributes: {
76
    action: 'read',
77
  },
78
  resourceType: RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,
79
});
80

81
/**
82
 * List of all the scaffolder permissions
83
 * @alpha
84
 */
85
export const scaffolderPermissions = [
86
  actionExecutePermission,
87
  templateParameterReadPermission,
88
  templateStepReadPermission,
89
];
90

91
/**
92
 * List of the scaffolder permissions that are associated with template steps and parameters.
93
 * @alpha
94
 */
95
export const scaffolderTemplatePermissions = [
96
  templateParameterReadPermission,
97
  templateStepReadPermission,
98
];
99

100
/**
101
 * List of the scaffolder permissions that are associated with scaffolder actions.
102
 * @alpha
103
 */
104
export const scaffolderActionPermissions = [actionExecutePermission];
105

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.