@sungazer/role-auth
v17.0.0
Published
Simple library to handle role-based authorization, works very well with Symfony's role system.
Downloads
4
Readme
@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.