17.0.0 • Published 3 months ago

@sungazer/role-auth v17.0.0

Weekly downloads
5
License
-
Repository
-
Last release
3 months 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

3 months ago

0.0.2

3 years ago

0.0.1

4 years ago