Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
@bonio-tw/casbin-mongoose-adapter
Advanced tools
Install the package as dependency in your project:
npm install --save @bonio-tw/casbin-mongoose-adapter
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('@bonio-tw/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('@bonio-tw/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('@elastic.io/casbin-mongoose-adapter');
const adapter = await MongooseAdapter.newFilteredAdapter('mongodb://your_mongodb_uri:27017');
FAQs
Adapter for Casbin
The npm package @bonio-tw/casbin-mongoose-adapter receives a total of 1 weekly downloads. As such, @bonio-tw/casbin-mongoose-adapter popularity was classified as not popular.
We found that @bonio-tw/casbin-mongoose-adapter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 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
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.