17.0.0 • Published 1 year ago

@sungazer/role-auth v17.0.0

Weekly downloads
5
License
-
Repository
-
Last release
1 year ago

@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.

17.0.0

1 year ago

0.0.2

5 years ago

0.0.1

6 years ago