Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@casbin/mongo-changestream-watcher
Advanced tools
Casbin Watcher based on MongoDB Change Streams
For more information about MongoDB Change Streams, look here.
More information about Casbin Watchers, look here.
# NPM
npm install --save @casbin/mongo-changestream-watcher
# Yarn
yarn add @casbin/mongo-changestream-watcher
import { MongoChangeStreamWatcher } from '@casbin/mongo-changestream-watcher';
import { newEnforcer } from 'casbin';
// Initialize the watcher by connecting to a replica set.
const watcher = await MongoChangeStreamWatcher.newWatcher('mongodb://localhost:27001,localhost:27002/casbin?replicaSet=rs0', {collectionName: 'casbin_rule'});
const adapter = await MongooseAdapter.newAdapter('mongodb://localhost:27001,localhost:27002/casbin?replicaSet=rs0');
const enforcer = await newEnforcer('test/fixtures/basic_model.conf', adapter);
// Initialize the enforcer.
const enforcer = await newEnforcer('examples/authz_model.conf', 'examples/authz_policy.csv');
enforcer.setWatcher(watcher);
// By default, the watcher's callback is automatically set to the
// enforcer's loadPolicy() in the setWatcher() call.
// We can change it by explicitly setting a callback.
watcher.setUpdateCallback(() => console.log('Casbin need update'));
This watcher does not operate with update
-calls typically found in other watchers. Mongo Change Stream directly reacts to changes in the database collection, and therefore all other watchers listening to the same stream will be automatically notified when changes do occur. However, this means that watcher also gets notified by its own changes.
FAQs
Casbin Watcher based on MongoDB Change Streams
We found that @casbin/mongo-changestream-watcher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.