Skip to main content

@backstage/plugin-permission-react

Home > @backstage/plugin-permission-react

Classes

ClassDescription
IdentityPermissionApiThe default implementation of the PermissionApi, which simply calls the authorize method of the given PermissionClient.

Functions

FunctionDescription
RequirePermission(props)

A boundary that only renders its child elements if the user has the specified permission.

While loading, nothing will be rendered. If the user does not have permission, the errorPage element will be rendered, falling back to the NotFoundErrorPage app component if no errorPage is provider.

usePermission(input)

React hook utility for authorization. Given either a non-resource Permission or a ResourcePermission and an optional resourceRef, it will return whether or not access is allowed (for the given resource, if resourceRef is provided). See for more details.

The resourceRef field is optional to allow calling this hook with an entity that might be loading asynchronously, but when resourceRef is not supplied, the value of allowed will always be false.

Note: This hook uses stale-while-revalidate to help avoid flicker in UI elements that would be conditionally rendered based on the allowed result of this hook.

Variables

VariableDescription
permissionApiRefA Backstage ApiRef for the Permission API. See https://backstage.io/docs/api/utility-apis for more information on Backstage ApiRefs.
PermissionedRouteReturns a React Router Route which only renders the element when authorized. If unauthorized, the Route will render a NotFoundErrorPage (see AppComponents).

Type Aliases

Type AliasDescription
AsyncPermissionResult
PermissionApiThis API is used by various frontend utilities that allow developers to implement authorization within their frontend plugins. A plugin developer will likely not have to interact with this API or its implementations directly, but rather with the aforementioned utility components/hooks.
RequirePermissionPropsProperties for RequirePermission()