moleculer-casl
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

moleculer-casl

npm version jsr version bundle JSDocs License

CASL authorisation for Moleculer with service-provided ability definition and caching.

Note: This module is heavily under development.

Usage

Ability provider

Add this mixin to your auth service, to provide rules for other services.

import { createCASLAbilityProvider } from 'moleculer-casl'

const AuthService = {
  mixins: [createCASLAbilityProvider(rulesFor)]
}

Ability consumer

Add this mixin to any service that needs to use Abilities.

import { createCASLAbilityConsumer } from 'moleculer-casl'

const ProductService: Service & AbilityConsumerMethods = {
  mixins: [createCASLAbilityConsumer()],
  actions: {
    create(ctx) {
      const ability = await this.abilityFor(ctx.meta.user)
    }
  }
}

License

MIT License © 2023-PRESENT Nicholai Nissen

Readme

Keywords

none

Package Sidebar

Install

npm i moleculer-casl

Weekly Downloads

7

Version

0.1.4

License

MIT

Unpacked Size

11.2 kB

Total Files

8

Last publish

Collaborators

  • nicholai