authorization
This package offers an Authorization
wrapper component for use within Hub that wraps an app or a specific component, and exposes permission and feature toggle props to its children via a Context Provider.
It also offers the AuthorizationToggle
(a React functional component) that verifies your permissions and allows you to choose the behaviour for when the permission is granted
or notGranted
.
Note: this component must be wrapped in an <Auth>
component to use Feature Toggles, as a parentEntityId
is required to get Feature Toggles.
#
Installation#
Props#
AuthorizationName | Type | Required | Default |
---|---|---|---|
children | ReactNode | yes | undefined |
permissions | string[] | no | undefined |
featureToggles | string[] | no | undefined |
#
AuthorizationToggleName | Type | Required | Default |
---|---|---|---|
children | {granted: ReactNode , notGranted: ReactNode } | yes | undefined |
permissions | string[] | no | undefined |
featureToggles | string[] | no | undefined |
#
Interfaces#
Examples#
Authorization#
PermissionsAlternatively, we can check permission before using it:
This can be useful when you want to allow either one of two or more permissions.