{"id":43412,"library":"nestjs-casbin-mongodb","title":"NestJS Casbin MongoDB","description":"A NestJS module integrating Casbin with a MongoDB adapter for policy storage. Current stable version is 1.2.5, with no updates since 2021. It provides a ready-to-use module that configures Casbin with MongoDB as the policy backend, supporting model files and custom collections. Key differentiators include tight integration with NestJS dependency injection and a simple forRoot setup. Compared to alternatives like nestjs-casbin, this package specifically targets MongoDB users and avoids the need to manually configure adapters.","status":"maintenance","version":"1.2.5","language":"javascript","source_language":"en","source_url":"https://github.com/juicycleff/nestjs-casbin-mongodb","tags":["javascript","typescript"],"install":[{"cmd":"npm install nestjs-casbin-mongodb","lang":"bash","label":"npm"},{"cmd":"yarn add nestjs-casbin-mongodb","lang":"bash","label":"yarn"},{"cmd":"pnpm add nestjs-casbin-mongodb","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for NestJS decorators and module system","package":"@nestjs/common","optional":false},{"reason":"Peer dependency providing the core Casbin authorization library","package":"casbin","optional":false},{"reason":"Peer dependency needed for MongoDB Native Driver to connect and query the database","package":"mongodb","optional":false}],"imports":[{"note":"Module is ESM-only; named import must be used.","wrong":"const { NestCasbinModule } = require('nestjs-casbin-mongodb')","symbol":"NestCasbinModule","correct":"import { NestCasbinModule } from 'nestjs-casbin-mongodb'"}],"quickstart":{"code":"import { Module } from '@nestjs/common';\nimport { NestCasbinModule } from 'nestjs-casbin-mongodb';\nimport { join } from 'path';\n\n@Module({\n  imports: [\n    NestCasbinModule.forRoot({\n      uri: process.env.MONGO_URI ?? 'mongodb://localhost:27017',\n      casbinModelPath: join(__dirname, './rbac_model.conf'),\n      collectionName: 'casbin_rule',\n      databaseName: 'casbin_db',\n    }),\n  ],\n})\nexport class AppModule {}","lang":"typescript","description":"Shows how to set up NestJS Casbin module with MongoDB adapter, including configuration parameters."},"warnings":[{"fix":"Use casbin v4.x and mongodb driver v3.x or pin versions in package.json.","message":"Package does not support casbin v5+ due to API changes in the adapter interface.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Consider migrating to nestjs-casbin with a separate MongoDB adapter.","message":"The package has not been updated since 2021 and may contain unpatched vulnerabilities.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Always specify a unique 'collectionName' or ensure the default is acceptable.","message":"If you omit the 'collectionName' option, it defaults to 'casbin_rule' which may conflict with existing collections.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.2.5':20 '2021':25 'adapt':12,83 'altern':65 'avoid':77 'backend':42 'casbin':2,8,36,69 'collect':48 'compar':63 'configur':35,82 'current':16 'custom':47 'depend':56 'differenti':50 'file':45 'forroot':61 'includ':51 'inject':57 'integr':7,53 'javascript':84 'key':49 'like':66 'manual':81 'model':44 'modul':6,33 'mongodb':3,11,38,74 'need':79 'nestj':1,5,55,68 'nestjs-casbin':67 'packag':71 'polici':14,41 'provid':27 'readi':30 'ready-to-us':29 'setup':62 'simpl':60 'sinc':24 'specif':72 'stabl':17 'storag':15 'support':43 'target':73 'tight':52 'typescript':85 'updat':23 'use':32 'user':75 'version':18","created_at":"2026-06-05T16:59:40.951757+00:00","updated_at":"2026-06-05T16:59:40.951757+00:00","problems":[{"fix":"Run 'npm install nestjs-casbin-mongodb @nestjs/common casbin mongodb' to include all peer deps.","cause":"Running npm install without peer dependencies being installed correctly.","error":"Cannot find module 'nestjs-casbin-mongodb'"},{"fix":"Ensure MongoDB is running and the URI is correct, e.g., 'mongodb://localhost:27017/my-db'.","cause":"MongoDB connection URI is misconfigured or MongoDB is not running.","error":"MongoError: failed to connect to server [localhost:27017]"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/juicycleff/nestjs-casbin-mongodb","github":"https://github.com/juicycleff/nestjs-casbin-mongodb","docs":null,"changelog":null,"pypi":null,"npm":"nestjs-casbin-mongodb","openapi_spec":null,"status_page":null,"smithery":null,"categories":["security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}