Skip to main content
Home

🛡️ Mixins for Moleculer to allow using CASL as a distributed authz rules engine

This package works with Node.js, BrowsersIt is unknown whether this package works with Cloudflare Workers, Deno, Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
This package works with Browsers
JSR Score
100%
Published
a year ago (0.1.4)

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

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@nicholai/moleculer-casl

Import symbol

import * as moleculer_casl from "@nicholai/moleculer-casl";
or

Import directly with a jsr specifier

import * as moleculer_casl from "jsr:@nicholai/moleculer-casl";

Add Package

pnpm i jsr:@nicholai/moleculer-casl
or (using pnpm 10.8 or older)
pnpm dlx jsr add @nicholai/moleculer-casl

Import symbol

import * as moleculer_casl from "@nicholai/moleculer-casl";

Add Package

yarn add jsr:@nicholai/moleculer-casl
or (using Yarn 4.8 or older)
yarn dlx jsr add @nicholai/moleculer-casl

Import symbol

import * as moleculer_casl from "@nicholai/moleculer-casl";

Add Package

vlt install jsr:@nicholai/moleculer-casl

Import symbol

import * as moleculer_casl from "@nicholai/moleculer-casl";

Add Package

npx jsr add @nicholai/moleculer-casl

Import symbol

import * as moleculer_casl from "@nicholai/moleculer-casl";

Add Package

bunx jsr add @nicholai/moleculer-casl

Import symbol

import * as moleculer_casl from "@nicholai/moleculer-casl";