Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@beamnetwork/eco-casbin-mongoose-adapter
Advanced tools
Readme
Mongoose Adapter is the Mongoose adapter for Node-Casbin. With this library, Node-Casbin can load policy from Mongoose supported database or save policy to it. It is originally developed by @ghaiklor from @elasticio.
Based on Officially Supported Databases, The current supported database is MongoDB.
Install the package as dependency in your project:
npm install --save casbin-mongoose-adapter casbin
Note: casbin
as peerDependencies!
Require it in a place, where you are instantiating an enforcer (read more about enforcer here):
const path = require('path');
const { newEnforcer } = require('casbin');
const MongooseAdapter = require('casbin-mongoose-adapter');
const model = path.resolve(__dirname, './your_model.conf');
const adapter = await MongooseAdapter.newAdapter('mongodb://your_mongodb_uri:27017');
const enforcer = await newEnforcer(model, adapter);
That is all what required for integrating the adapter into casbin. Casbin itself calls adapter methods to persist updates you made through it.
You can pass mongooose-specific options when instantiating the adapter:
const MongooseAdapter = require('casbin-mongoose-adapter');
const adapter = await MongooseAdapter.newAdapter('mongodb://your_mongodb_uri:27017', { mongoose_options: 'here' });
Additional information regard to options you can pass in you can find in mongoose documentation
You can create an adapter instance that will load only those rules you need to.
A simple case for it is when you have separate policy rules for separate domains (tenants). You do not need to load all the rules for all domains to make an authorization in specific domain.
For such cases, filtered adapter exists in casbin.
const MongooseAdapter = require('casbin-mongoose-adapter');
const adapter = await MongooseAdapter.newFilteredAdapter('mongodb://your_mongodb_uri:27017');
FAQs
Mongoose adapter for Casbin
The npm package @beamnetwork/eco-casbin-mongoose-adapter receives a total of 6 weekly downloads. As such, @beamnetwork/eco-casbin-mongoose-adapter popularity was classified as not popular.
We found that @beamnetwork/eco-casbin-mongoose-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.