Carlos Cifuentes
AngularJS library migration · authorization

Migrating angular-permission to modern Angular

angular-permission defined permissions and roles, protected ui-router states through data.permissions and hid elements with directives. It is tied to AngularJS and its routers.

What replaces it

OptionWhen to choose it
Route guards + your own directiveFunctional guards (canActivate, canMatch) for routes and a small structural directive to show or hide elements.
ngx-permissionsSimilar concepts to angular-permission: permissions, roles, a guard and directives.
CASL (@casl/angular)When rules depend on the action and the record, not only on a role.

How to migrate it

  1. Export the list of permissions and roles, and where each one is checked: states, templates and controllers.
  2. Create a PermissionService that loads the user's permissions once and is shared by both frameworks.
  3. Replace state permissions with route guards and the template directives with your own directive as each screen moves.

Watch out. Load permissions before the first navigation, or a page refresh sends logged-in users to the access-denied page. And hiding a button is not security: the API must enforce the same rules.

Other libraries

Planning a migration or a micro-frontend platform?

In a 20-minute call you describe your situation and I tell you how I'd approach it. If it isn't worth doing yet, I'll say so.

Message me on LinkedIn