From b2fbe64f587cac83be18be3c3655ddbbe5002dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Gr=C3=A9goire?= <32612304+valentingregoire@users.noreply.github.com> Date: Thu, 22 May 2025 17:47:39 +0200 Subject: [PATCH 1/5] fix(docs): Fixed code examples for Writing a permission policy. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Valentin Grégoire <32612304+valentingregoire@users.noreply.github.com> --- docs/permissions/writing-a-policy.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/permissions/writing-a-policy.md b/docs/permissions/writing-a-policy.md index a479684287..576afcac21 100644 --- a/docs/permissions/writing-a-policy.md +++ b/docs/permissions/writing-a-policy.md @@ -92,6 +92,13 @@ import { catalogEntityDeletePermission, } from '@backstage/plugin-catalog-common/alpha'; /* highlight-add-end */ +import { + PermissionPolicy, + PolicyQuery, + /* highlight-add-next-line */ + PolicyQueryUser, +} from '@backstage/plugin-permission-node'; + class CustomPermissionPolicy implements PermissionPolicy { /* highlight-remove-next-line */ @@ -143,8 +150,8 @@ import { PolicyDecision, /* highlight-remove-next-line */ isPermission, - isResourcePermission, /* highlight-add-next-line */ + isResourcePermission, } from '@backstage/plugin-permission-common'; import { catalogConditions, @@ -155,6 +162,11 @@ import { catalogEntityDeletePermission, } from '@backstage/plugin-catalog-common/alpha'; /* highlight-remove-end */ +import { + PermissionPolicy, + PolicyQuery, + PolicyQueryUser, +} from '@backstage/plugin-permission-node'; class CustomPermissionPolicy implements PermissionPolicy { async handle( From 046d2177bc869427dc9c1cd11156a0d733f88e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Gr=C3=A9goire?= <32612304+valentingregoire@users.noreply.github.com> Date: Thu, 22 May 2025 18:09:23 +0200 Subject: [PATCH 2/5] fix(docs): Fixed the code example for the Permissions - Frontend Integration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current default code is exactly what it is in this example, except for the flawed import. Signed-off-by: Valentin Grégoire <32612304+valentingregoire@users.noreply.github.com> --- docs/permissions/frontend-integration.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/docs/permissions/frontend-integration.md b/docs/permissions/frontend-integration.md index 1e83f8ad7d..a3949d3606 100644 --- a/docs/permissions/frontend-integration.md +++ b/docs/permissions/frontend-integration.md @@ -13,16 +13,11 @@ However, there are some cases where the integrator needs to supplement the polic If your Backstage permission policy may return a `DENY` for users requesting the `catalogEntityCreatePermission`, it may make sense, for example, to remove access to the `/catalog-import` page entirely: ```tsx title="packages/app/src/App.tsx" -/* highlight-add-start */ import { RequirePermission } from '@backstage/plugin-permission-react'; -import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common'; -/* highlight-add-end */ +import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha'; const routes = ( - {/* highlight-remove-next-line */} - } /> - {/* highlight-add-start */} } /> - {/* highlight-add-end */} {/* ... */} ); From 01bb34675d698df5a44d32f64dc36e8ab117a4f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Gr=C3=A9goire?= Date: Mon, 26 May 2025 11:08:29 +0200 Subject: [PATCH 3/5] fix(docs): Added note for code example. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Valentin Grégoire --- docs/permissions/frontend-integration.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/permissions/frontend-integration.md b/docs/permissions/frontend-integration.md index a3949d3606..be24516129 100644 --- a/docs/permissions/frontend-integration.md +++ b/docs/permissions/frontend-integration.md @@ -4,6 +4,10 @@ title: Frontend Integration description: How to place your Backstage frontend components behind authorization --- +:::info +Starting with a [fresh Backstage installation](https://backstage.io/docs/getting-started/), the code example below is already implemented, so there are no code actual code changes required. +::: + Now that we understand how to [author a permission policy](./writing-a-policy.md), let's consider cases where we'll need to supplement our policy with authorization checks on the frontend. In most cases, actual functionality that live within various plugins will already have been placed behind authorization by the plugin authors. The permission backend will use your permission policy to return an authorization result, and the plugin frontend will correspondingly show/hide/disable the relevant UI component. From c4a18f4334fd35df3f53505bc65442b42b6293c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Gr=C3=A9goire?= <32612304+valentingregoire@users.noreply.github.com> Date: Fri, 6 Jun 2025 09:08:32 +0200 Subject: [PATCH 4/5] fix(docs): spelling mistake fixed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: Valentin Grégoire <32612304+valentingregoire@users.noreply.github.com> --- docs/permissions/frontend-integration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/permissions/frontend-integration.md b/docs/permissions/frontend-integration.md index be24516129..c7dbb90479 100644 --- a/docs/permissions/frontend-integration.md +++ b/docs/permissions/frontend-integration.md @@ -5,7 +5,7 @@ description: How to place your Backstage frontend components behind authorizatio --- :::info -Starting with a [fresh Backstage installation](https://backstage.io/docs/getting-started/), the code example below is already implemented, so there are no code actual code changes required. +Starting with a [fresh Backstage installation](https://backstage.io/docs/getting-started/), the code example below is already implemented, so there are no actual code changes required. ::: Now that we understand how to [author a permission policy](./writing-a-policy.md), let's consider cases where we'll need to supplement our policy with authorization checks on the frontend. From c0aa0a9a37d098b287d7463fe5a5b4c3baa1498c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Gr=C3=A9goire?= <32612304+valentingregoire@users.noreply.github.com> Date: Sun, 8 Jun 2025 22:22:51 +0200 Subject: [PATCH 5/5] fix(docs): added highlight for clearer docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Valentin Grégoire <32612304+valentingregoire@users.noreply.github.com> --- docs/permissions/frontend-integration.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/permissions/frontend-integration.md b/docs/permissions/frontend-integration.md index c7dbb90479..d5329eca96 100644 --- a/docs/permissions/frontend-integration.md +++ b/docs/permissions/frontend-integration.md @@ -25,6 +25,7 @@ const routes = (