Skip to content
This repository was archived by the owner on Feb 13, 2021. It is now read-only.

About

Loopback component authorization HRBAC

Resources

Contributing

Stars

8 stars

Watchers

1 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

loopback-component-authorization

Access controlling is one of the most important parts of every application, there are many kinds of models for access controlling like MAC (Mandatory Access Control), DAC (Discretionary Access Control), RBAC (Role Based Access Control) and etc (for more information about access models see this link)

loopback-component-authorization is a powerful and generic implementation of HRBAC (Hierarchical Role Based Access Control) access model

Installation

npm i --save loopback-component-authorization

Usage

Follow these steps to add authorization extension to your loopback4 application

  1. Optional: Define User, Role, Permission models
  2. Optional: Define User, Role, Permission repositories
  3. Optional: Define Permissions class
  4. Define your dataSource
  5. Add AuthorizationMixin to your application
  6. Add AuthorizationActionProvider to your custom http sequence handler
  7. Use GetUserPermissionsProvider to find user permissions when signin and save the permissions in user's session

Now, let's try these

Step 1 (Define Models)

Use the command lb4 model for simplifing your Entity model creation, then just replace Entity class with User, Role or Permission as the parent class

See this example: