From ff08f1d14ef74ab657161d5f933ab243cb375bd8 Mon Sep 17 00:00:00 2001 From: Joon Park Date: Wed, 21 Sep 2022 13:56:37 +0100 Subject: [PATCH] Frontend permission docs for integrators (#11039) * Frontend permission docs for integrators Signed-off-by: Joon Park * Update docs/permission/frontend-integration.md Co-authored-by: Joe Porpeglia Signed-off-by: Joon Park Signed-off-by: Joon Park Co-authored-by: Joe Porpeglia --- docs/permissions/frontend-integration.md | 38 ++++++++++++++++++++++++ microsite/sidebars.json | 1 + 2 files changed, 39 insertions(+) create mode 100644 docs/permissions/frontend-integration.md diff --git a/docs/permissions/frontend-integration.md b/docs/permissions/frontend-integration.md new file mode 100644 index 0000000000..2a429ea120 --- /dev/null +++ b/docs/permissions/frontend-integration.md @@ -0,0 +1,38 @@ +--- +id: frontend-integration +title: Frontend Integration +description: How to place your Backstage frontend components behind authorization +--- + +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. + +However, there are some cases where the integrator needs to supplement the policy on the frontend. One example is app level routing. + +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: + +```diff +// packages/app/src/App.tsx + +... + ++ import { PermissionedRoute } from '@backstage/plugin-permission-react'; ++ import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common'; + +... + +- } /> ++ ++ ++ ++ } ++ /> +... + +``` + +With this change, users who are denied the `catalogEntityCreatePermission` should now be unable to access the `/catalog-import` page. diff --git a/microsite/sidebars.json b/microsite/sidebars.json index 44d8e12869..8e77594376 100644 --- a/microsite/sidebars.json +++ b/microsite/sidebars.json @@ -286,6 +286,7 @@ "permissions/concepts", "permissions/getting-started", "permissions/writing-a-policy", + "permissions/frontend-integration", "permissions/custom-rules", { "type": "subcategory",