Gathering detailed insights and metrics for casbin-mongoose-adapter
Gathering detailed insights and metrics for casbin-mongoose-adapter
Gathering detailed insights and metrics for casbin-mongoose-adapter
Gathering detailed insights and metrics for casbin-mongoose-adapter
npm install casbin-mongoose-adapter
Typescript
Module System
Min. Node Version
Node Version
NPM Version
79.2
Supply Chain
91.2
Quality
80.5
Maintenance
100
Vulnerability
98.9
License
JavaScript (64.42%)
TypeScript (35.58%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
34 Stars
129 Commits
32 Forks
2 Watchers
1 Branches
21 Contributors
Updated on Jan 22, 2025
Latest Version
5.3.1
Package Id
casbin-mongoose-adapter@5.3.1
Unpacked Size
175.84 kB
Size
26.34 kB
File Count
49
NPM Version
9.6.7
Node Version
18.17.0
Published on
Aug 06, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
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.
Mongoose Adapter has been rewritten to TypeScript since v3.x.
Install the package as dependency in your project:
1npm 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):
1const path = require('path'); 2const { newEnforcer } = require('casbin'); 3const { MongooseAdapter } = require('casbin-mongoose-adapter'); 4 5// const MongooseAdapter = require('casbin-mongoose-adapter'); 6// You should use this in v2.x 7 8const model = path.resolve(__dirname, './your_model.conf'); 9const adapter = await MongooseAdapter.newAdapter('mongodb://your_mongodb_uri:27017'); 10const 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:
1const { MongooseAdapter } = require('casbin-mongoose-adapter'); 2const 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.
1const { MongooseAdapter } = require('casbin-mongoose-adapter'); 2const adapter = await MongooseAdapter.newFilteredAdapter('mongodb://your_mongodb_uri:27017');
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
Found 10/23 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
25 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More