Authorization
RBAC Authorization Policy
Custom Policy Example
Zuplo is extensible, so we don't have a built-in policy for RBAC Authorization, instead we've a template here that shows you how you can use your superpower (code) to achieve your goals. To learn more about custom policies see the documentation.
RBAC policies can be built many ways depending on your requirements. This example shows how to perform a simple check of whether or not the current user is a member of a set of allowed roles.
ts
Configuration
The example below shows how to configure a custom code policy in the 'policies.json' document that utilizes the above example policy code.
json
Policy Configuration
name
<string>
- The name of your policy instance. This is used as a reference in your routes.policyType
<string>
- The identifier of the policy. This is used by the Zuplo UI. Value should berbac-policy-inbound
.handler.export
<string>
- The name of the exported type. Value should bedefault
.handler.module
<string>
- The module containing the policy. Value should be$import(./modules/YOUR_MODULE)
.handler.options
<object>
- The options for this policy. See Policy Options below.
Policy Options
The options for this policy are specified below. All properties are optional unless specifically marked as required.
allowedRoles
<string[]>
- The roles allowed to access the resource Defaults to[]
.
Using the Policy
Read more about how policies work