chore: remove action read scaffolder permission
Signed-off-by: Frank Kong <frkong@redhat.com>
This commit is contained in:
@@ -30,12 +30,7 @@ import {
|
||||
UserEntity,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Config, readDurationFromConfig } from '@backstage/config';
|
||||
import {
|
||||
InputError,
|
||||
NotAllowedError,
|
||||
NotFoundError,
|
||||
stringifyError,
|
||||
} from '@backstage/errors';
|
||||
import { InputError, NotFoundError, stringifyError } from '@backstage/errors';
|
||||
import { ScmIntegrations } from '@backstage/integration';
|
||||
import { HumanDuration, JsonObject, JsonValue } from '@backstage/types';
|
||||
import {
|
||||
@@ -56,7 +51,6 @@ import {
|
||||
templateParameterReadPermission,
|
||||
templateStepReadPermission,
|
||||
scaffolderTaskPermissions,
|
||||
actionReadPermission,
|
||||
} from '@backstage/plugin-scaffolder-common/alpha';
|
||||
import express from 'express';
|
||||
import Router from 'express-promise-router';
|
||||
@@ -78,10 +72,7 @@ import {
|
||||
import { createDryRunner } from '../scaffolder/dryrun';
|
||||
import { StorageTaskBroker } from '../scaffolder/tasks/StorageTaskBroker';
|
||||
import { findTemplate, getEntityBaseUrl, getWorkingDirectory } from './helpers';
|
||||
import {
|
||||
AuthorizeResult,
|
||||
PermissionRuleParams,
|
||||
} from '@backstage/plugin-permission-common';
|
||||
import { PermissionRuleParams } from '@backstage/plugin-permission-common';
|
||||
import {
|
||||
createConditionAuthorizer,
|
||||
createPermissionIntegrationRouter,
|
||||
@@ -420,12 +411,8 @@ export async function createRouter(
|
||||
permissions: scaffolderActionPermissions,
|
||||
rules: actionRules,
|
||||
},
|
||||
{
|
||||
resourceType: 'basic',
|
||||
permissions: scaffolderTaskPermissions,
|
||||
rules: [],
|
||||
},
|
||||
],
|
||||
permissions: scaffolderTaskPermissions,
|
||||
});
|
||||
|
||||
router.use(permissionIntegrationRouter);
|
||||
@@ -464,20 +451,7 @@ export async function createRouter(
|
||||
});
|
||||
},
|
||||
)
|
||||
.get('/v2/actions', async (req, res) => {
|
||||
const credentials = await httpAuth.credentials(req);
|
||||
if (permissions) {
|
||||
const authorizationResponse = (
|
||||
await permissions.authorizeConditional(
|
||||
[{ permission: actionReadPermission }],
|
||||
{ credentials: credentials },
|
||||
)
|
||||
)[0];
|
||||
if (authorizationResponse.result === AuthorizeResult.DENY) {
|
||||
throw new NotAllowedError();
|
||||
}
|
||||
}
|
||||
|
||||
.get('/v2/actions', async (_req, res) => {
|
||||
const actionsList = actionRegistry.list().map(action => {
|
||||
return {
|
||||
id: action.id,
|
||||
|
||||
@@ -42,19 +42,6 @@ export const actionExecutePermission = createPermission({
|
||||
resourceType: RESOURCE_TYPE_SCAFFOLDER_ACTION,
|
||||
});
|
||||
|
||||
// TODO: Figure out whether to convert this to a basic permission or remove it completely since the current rules aren't applicable to this permission
|
||||
/**
|
||||
* This permission is used to authorize actions that involve access the action registry
|
||||
*
|
||||
* @alpha
|
||||
*/
|
||||
export const actionReadPermission = createPermission({
|
||||
name: 'scaffolder.action.read',
|
||||
attributes: {
|
||||
action: 'read',
|
||||
},
|
||||
resourceType: RESOURCE_TYPE_SCAFFOLDER_ACTION,
|
||||
});
|
||||
/**
|
||||
* This permission is used to authorize actions that involve reading
|
||||
* one or more parameters from a template.
|
||||
@@ -126,15 +113,6 @@ export const taskCancelPermission = createPermission({
|
||||
attributes: {},
|
||||
});
|
||||
|
||||
/**
|
||||
* List of all the scaffolder permissions
|
||||
* @alpha
|
||||
*/
|
||||
export const scaffolderPermissions = [
|
||||
templateParameterReadPermission,
|
||||
templateStepReadPermission,
|
||||
];
|
||||
|
||||
/**
|
||||
* List of the scaffolder permissions that are associated with template steps and parameters.
|
||||
* @alpha
|
||||
@@ -148,10 +126,7 @@ export const scaffolderTemplatePermissions = [
|
||||
* List of the scaffolder permissions that are associated with scaffolder actions.
|
||||
* @alpha
|
||||
*/
|
||||
export const scaffolderActionPermissions = [
|
||||
actionExecutePermission,
|
||||
actionReadPermission,
|
||||
];
|
||||
export const scaffolderActionPermissions = [actionExecutePermission];
|
||||
|
||||
/**
|
||||
* List of the scaffolder permissions that are associated with scaffolder tasks.
|
||||
@@ -162,3 +137,13 @@ export const scaffolderTaskPermissions = [
|
||||
taskCreatePermission,
|
||||
taskReadPermission,
|
||||
];
|
||||
|
||||
/**
|
||||
* List of all the scaffolder permissions
|
||||
* @alpha
|
||||
*/
|
||||
export const scaffolderPermissions = [
|
||||
...scaffolderTemplatePermissions,
|
||||
...scaffolderActionPermissions,
|
||||
...scaffolderTaskPermissions,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user