Home

@ra-libs/react-rbac

NPM Version Package License Publish Status

React Admin complementary library that provides RBAC using CASL

Installation

Run npm install

npm install @ra-libs/react-rbac

Usage

Make sure your authProvider.getPermissions method returns the permissions following this interface

// authProvider

import { Role, Permission } from '@ra-libs/react-rbac';
import { AuthProvider } from 'react-admin';

export const authProvider: AuthProvider = {
  // ...
  getPermissions: (): Role[] => {
    // Fetch your permissions
    // Permissions should follow this type
    return [
      {
        name: 'admin',
        permissions: [
          {
            action: 'read',
            subject: 'Article',
          },
        ],
      },
    ];
  },
};

Check the Permission type for more details.

Last updated