0.7.0 • Published 7 months ago

@kagari/rbac v0.7.0

Weekly downloads
-
License
-
Repository
github
Last release
7 months ago

@kagari/rbac

rbac implement for kagari framework, needs work with @kagari/auth together.

usage

// prepare business logic
import { CanActivateFunction, RoleBasedAccessControlModule } from '@kagari/rbac';
import { ExecutionContext, UseGuards } from '@nestjs/common';
import { UserEntity } from './User.entity';
import { RoleEntity } from './Role.entity';
import { PermissionEntity } from './Permission.entity';
import { LocalAuthenticatedGuard } from './local-authenticated.guard';

const canActivate: CanActivateFunction = function(context: ExecutionContext) {
  // your logic check if this user can pass
  
  // this referes to RoleBasedAccessControlModule
  // which injects Reflector, you can get any injectable by it
}

RoleBasedAccessControlModule.forRoot({
  entities: {
    user: UserEntity,
    role: RoleEntity,
    permission: PermissionEntity
  },
  canActivate: canActivate
})

@UseGuards(LocalAuthenticatedGuard, RoleBasedAccessControlModule)
class SomeController {
  // all handlers under this controller will be protected by rbac strategy
}
0.6.2

9 months ago

0.6.4

7 months ago

0.7.0

7 months ago

0.5.10

12 months ago

0.5.11

12 months ago

0.6.1

12 months ago

0.4.9

1 year ago

0.4.8

1 year ago

0.5.4

1 year ago

0.5.2

1 year ago

0.2.1

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.12

1 year ago

0.3.1

1 year ago

0.1.0

2 years ago

0.0.4

2 years ago