@sungazer/role-auth
TypeScript icon, indicating that this package has built-in type declarations

17.0.0 • Public • Published

@Sungazer/RoleAuth

Simple library to handle role-based authorization, works very well with Symfony's role system.

Usage

Include RoleAuthModule in your AppModule

import { RoleAuthModule } from '@sungazer/role-auth';

Then specify the role hierarchy structure.

RoleAuthModule.forRoot({
      roles: {
        "ROLE_ADMIN": ["ROLE_USER","ROLE_OTHER_ROLE"],
        "ROLE_OTHER_ROLE": ["ROLE_USER"],
        "ROLE_USER": []
      }
    })

Finally, inject RoleAuthService in your components. When the user logs-in, set his or her roles using the setAuthenticatedUserRoles function. After that, you can check for a role by invoking the isGranted function from the RoleAuthService.

Readme

Keywords

none

Package Sidebar

Install

npm i @sungazer/role-auth

Weekly Downloads

1

Version

17.0.0

License

none

Unpacked Size

26.4 kB

Total Files

14

Last publish

Collaborators

  • lnardelli