Home

Awesome

CASL and Aurelia integration

Read CASL in Aurelia app for details.

This blog application shows how to integrate CASL in Aurelia based application. Application uses standard aurelia cli setup with minor changes:

Note: refactored to use CASL 2.0. See @casl/ability and @casl/aurelia for details.

Installation

Clone this repository and run:

npm ci
npm start

Now you can open http://localhost:8080 to see application.

Configuration

To see application without CASL integration, checkout to without-casl branch.

Abilities

All abilities are defined in src/config/abilities and updated each time a new Session is created, found or destroyed (i.e., when user log in or log out). Application uses can value convertor with if binding:

<li if.bind="'Post' | can: 'create'">
  <a route-href="route: newPost">Add Post</a>
</li>

In this case if user has ability to create posts, he will see the button, otherwise button will be removed. For more information about value convertors please refer to Aurealia documentation