From c312192e61dd6b31603d8794cf3df98beb4b9379 Mon Sep 17 00:00:00 2001 From: Brian Phillips <28457+brianphillips@users.noreply.github.com> Date: Wed, 17 May 2023 13:48:40 -0500 Subject: [PATCH 1/3] Expose devtools plugin permissions through the metadata endpoint Signed-off-by: Brian Phillips <28457+brianphillips@users.noreply.github.com> --- .changeset/fast-zebras-watch.md | 6 ++++++ plugins/devtools-backend/src/service/router.ts | 7 +++++++ plugins/devtools-common/src/permissions.ts | 12 ++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 .changeset/fast-zebras-watch.md diff --git a/.changeset/fast-zebras-watch.md b/.changeset/fast-zebras-watch.md new file mode 100644 index 0000000000..4a114347e1 --- /dev/null +++ b/.changeset/fast-zebras-watch.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-devtools-backend': patch +'@backstage/plugin-devtools-common': patch +--- + +Expose permissions through the metadata endpoint. diff --git a/plugins/devtools-backend/src/service/router.ts b/plugins/devtools-backend/src/service/router.ts index a346ad3183..fbeeb5af84 100644 --- a/plugins/devtools-backend/src/service/router.ts +++ b/plugins/devtools-backend/src/service/router.ts @@ -21,6 +21,7 @@ import { devToolsConfigReadPermission, devToolsExternalDependenciesReadPermission, devToolsInfoReadPermission, + devToolsPermissions, } from '@backstage/plugin-devtools-common'; import { Config } from '@backstage/config'; @@ -31,6 +32,7 @@ import Router from 'express-promise-router'; import { errorHandler } from '@backstage/backend-common'; import express from 'express'; import { getBearerTokenFromAuthorizationHeader } from '@backstage/plugin-auth-node'; +import { createPermissionIntegrationRouter } from '@backstage/plugin-permission-node'; /** @public */ export interface RouterOptions { @@ -51,6 +53,11 @@ export async function createRouter( const router = Router(); router.use(express.json()); + router.use( + createPermissionIntegrationRouter({ + permissions: devToolsPermissions, + }), + ); router.get('/health', (_req, res) => { res.status(200).json({ status: 'ok' }); diff --git a/plugins/devtools-common/src/permissions.ts b/plugins/devtools-common/src/permissions.ts index ae62cfdc19..ba464f7d80 100644 --- a/plugins/devtools-common/src/permissions.ts +++ b/plugins/devtools-common/src/permissions.ts @@ -47,3 +47,15 @@ export const devToolsExternalDependenciesReadPermission = createPermission({ name: 'devtools.external-dependencies', attributes: { action: 'read' }, }); + +/** + * List of all Devtools permissions + * + * @public + */ +export const devToolsPermissions = [ + devToolsAdministerPermission, + devToolsInfoReadPermission, + devToolsConfigReadPermission, + devToolsExternalDependenciesReadPermission, +]; From 4c7e90706e9a827a8a9bb9924b33281ad3a5dad2 Mon Sep 17 00:00:00 2001 From: Brian Phillips <28457+brianphillips@users.noreply.github.com> Date: Wed, 17 May 2023 14:01:42 -0500 Subject: [PATCH 2/3] add api report Signed-off-by: Brian Phillips <28457+brianphillips@users.noreply.github.com> --- plugins/devtools-common/api-report.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/devtools-common/api-report.md b/plugins/devtools-common/api-report.md index 7e38ff05b0..6594b0d8a4 100644 --- a/plugins/devtools-common/api-report.md +++ b/plugins/devtools-common/api-report.md @@ -40,6 +40,9 @@ export type DevToolsInfo = { // @public (undocumented) export const devToolsInfoReadPermission: BasicPermission; +// @public +export const devToolsPermissions: BasicPermission[]; + // @public (undocumented) export type Endpoint = { name: string; From 459331f657ece3dfdb41182a8c78aacdc8c35f37 Mon Sep 17 00:00:00 2001 From: Brian Phillips <28457+brianphillips@users.noreply.github.com> Date: Wed, 17 May 2023 20:37:51 -0500 Subject: [PATCH 3/3] Split changeset for each package Signed-off-by: Brian Phillips <28457+brianphillips@users.noreply.github.com> --- .changeset/fast-zebras-watch.md | 1 - .changeset/plenty-roses-raise.md | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .changeset/plenty-roses-raise.md diff --git a/.changeset/fast-zebras-watch.md b/.changeset/fast-zebras-watch.md index 4a114347e1..7466565e79 100644 --- a/.changeset/fast-zebras-watch.md +++ b/.changeset/fast-zebras-watch.md @@ -1,6 +1,5 @@ --- '@backstage/plugin-devtools-backend': patch -'@backstage/plugin-devtools-common': patch --- Expose permissions through the metadata endpoint. diff --git a/.changeset/plenty-roses-raise.md b/.changeset/plenty-roses-raise.md new file mode 100644 index 0000000000..71605705e3 --- /dev/null +++ b/.changeset/plenty-roses-raise.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-devtools-common': patch +--- + +Export the list of permissions