{"id":13454991,"url":"https://github.com/casbin/node-casbin","last_synced_at":"2026-02-19T15:07:51.286Z","repository":{"id":38424260,"uuid":"140996605","full_name":"casbin/node-casbin","owner":"casbin","description":"An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js and Browser","archived":false,"fork":false,"pushed_at":"2025-01-23T06:35:44.000Z","size":3286,"stargazers_count":2724,"open_issues_count":20,"forks_count":217,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-05-11T08:37:48.397Z","etag":null,"topics":["abac","access-control","acl","auth","authorization","authz","casbin","javascript","js","node","nodejs","permission","permissions","rbac"],"latest_commit_sha":null,"homepage":"https://casbin.org","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/casbin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"casbin"}},"created_at":"2018-07-15T03:55:31.000Z","updated_at":"2025-05-10T20:08:12.000Z","dependencies_parsed_at":"2023-11-07T17:03:59.699Z","dependency_job_id":"362627eb-7b46-4c86-a6d9-bcd9646a82e2","html_url":"https://github.com/casbin/node-casbin","commit_stats":{"total_commits":570,"total_committers":47,"mean_commits":"12.127659574468085","dds":0.7210526315789474,"last_synced_commit":"1591055979c87094af5543b82c98fa5de936dbed"},"previous_names":[],"tags_count":139,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fnode-casbin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fnode-casbin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fnode-casbin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fnode-casbin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casbin","download_url":"https://codeload.github.com/casbin/node-casbin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253540673,"owners_count":21924523,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abac","access-control","acl","auth","authorization","authz","casbin","javascript","js","node","nodejs","permission","permissions","rbac"],"created_at":"2024-07-31T08:01:00.090Z","updated_at":"2026-01-03T17:17:36.236Z","avatar_url":"https://github.com/casbin.png","language":"TypeScript","readme":"# Node-Casbin\n\n[![GitHub Actions](https://github.com/casbin/node-casbin/workflows/main/badge.svg)](https://github.com/casbin/node-casbin/actions)\n[![Coverage Status](https://coveralls.io/repos/github/casbin/node-casbin/badge.svg?branch=master)](https://coveralls.io/github/casbin/node-casbin?branch=master)\n[![Release](https://img.shields.io/github/release/casbin/node-casbin.svg)](https://github.com/casbin/node-casbin/releases/latest)\n[![NPM version][npm-image]][npm-url]\n[![NPM download][download-image]][download-url]\n[![install size](https://packagephobia.now.sh/badge?p=casbin)](https://packagephobia.now.sh/result?p=casbin)\n[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord\u0026label=discord\u0026color=5865F2)](https://discord.gg/S5UjpzGZjN)\n\n[npm-image]: https://img.shields.io/npm/v/casbin.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/casbin\n[download-image]: https://img.shields.io/npm/dm/casbin.svg?style=flat-square\n[download-url]: https://npmjs.org/package/casbin\n\n**News**: still worry about how to write the correct `node-casbin` policy? [Casbin online editor](http://casbin.org/editor) is coming to help!\n\n![casbin Logo](casbin-logo.png)\n\n`node-casbin` is a powerful and efficient open-source access control library for Node.JS projects. It provides support for enforcing authorization based on various [access control models](https://wikipedia.org/wiki/Computer_security_model).\n\n## All the languages supported by Casbin:\n\n| [![golang](https://casbin.org/img/langs/golang.png)](https://github.com/casbin/casbin) | [![java](https://casbin.org/img/langs/java.png)](https://github.com/casbin/jcasbin) | [![nodejs](https://casbin.org/img/langs/nodejs.png)](https://github.com/casbin/node-casbin) | [![php](https://casbin.org/img/langs/php.png)](https://github.com/php-casbin/php-casbin) |\n| -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |\n| [Casbin](https://github.com/casbin/casbin)                                             | [jCasbin](https://github.com/casbin/jcasbin)                                        | [node-Casbin](https://github.com/casbin/node-casbin)                                        | [PHP-Casbin](https://github.com/php-casbin/php-casbin)                                   |\n| production-ready                                                                       | production-ready                                                                    | production-ready                                                                            | production-ready                                                                         |\n\n| [![python](https://casbin.org/img/langs/python.png)](https://github.com/casbin/pycasbin) | [![dotnet](https://casbin.org/img/langs/dotnet.png)](https://github.com/casbin-net/Casbin.NET) | [![c++](https://casbin.org/img/langs/cpp.png)](https://github.com/casbin/casbin-cpp) | [![rust](https://casbin.org/img/langs/rust.png)](https://github.com/casbin/casbin-rs) |\n| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------- |\n| [PyCasbin](https://github.com/casbin/pycasbin)                                           | [Casbin.NET](https://github.com/casbin-net/Casbin.NET)                                         | [Casbin-CPP](https://github.com/casbin/casbin-cpp)                                   | [Casbin-RS](https://github.com/casbin/casbin-rs)                                      |\n| production-ready                                                                         | production-ready                                                                               | beta-test                                                                            | production-ready                                                                      |\n\n## Documentation\n\nhttps://casbin.org/docs/overview\n\n## Installation\n\n```shell script\n# NPM\nnpm install casbin --save\n\n# Yarn\nyarn add casbin\n```\n\n## Get started\n\nNew a `node-casbin` enforcer with a model file and a policy file, see [Model](#official-model) section for details:\n\n```node.js\n// For Node.js:\nconst { newEnforcer } = require('casbin');\n// For browser:\n// import { newEnforcer } from 'casbin';\n\nconst enforcer = await newEnforcer('basic_model.conf', 'basic_policy.csv');\n```\n\n\u003e **Note**: you can also initialize an enforcer with policy in DB instead of file, see [Persistence](#policy-persistence) section for details.\n\nAdd an enforcement hook into your code right before the access happens:\n\n```node.js\nconst sub = 'alice'; // the user that wants to access a resource.\nconst obj = 'data1'; // the resource that is going to be accessed.\nconst act = 'read'; // the operation that the user performs on the resource.\n\n// Async:\nconst res = await enforcer.enforce(sub, obj, act);\n// Sync:\n// const res = enforcer.enforceSync(sub, obj, act);\n\nif (res) {\n  // permit alice to read data1\n} else {\n  // deny the request, show an error\n}\n```\n\nBesides the static policy file, `node-casbin` also provides API for permission management at run-time.\nFor example, You can get all the roles assigned to a user as below:\n\n```node.js\nconst roles = await enforcer.getRolesForUser('alice');\n```\n\nSee [Policy management APIs](#policy-management) for more usage.\n\n## Policy management\n\nCasbin provides two sets of APIs to manage permissions:\n\n- [Management API](https://casbin.org/docs/management-api): the primitive API that provides full support for Casbin policy management.\n- [RBAC API](https://casbin.org/docs/rbac-api): a more friendly API for RBAC. This API is a subset of Management API. The RBAC users could use this API to simplify the code.\n\n## Official Model\n\nhttps://casbin.org/docs/supported-models\n\n## Policy persistence\n\nhttps://casbin.org/docs/adapters\n\n## Policy consistence between multiple nodes\n\nhttps://casbin.org/docs/watchers\n\n## Role manager\n\nhttps://casbin.org/docs/role-managers\n\n## Contributors\n\nThis project exists thanks to all the people who contribute.\n\u003ca href=\"https://github.com/casbin/node-casbin/graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/node-casbin/contributors.svg?width=890\u0026button=false\" /\u003e\u003c/a\u003e\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=casbin/node-casbin\u0026type=Date)](https://star-history.com/#casbin/node-casbin\u0026Date)\n\n## License\n\nThis project is licensed under the [Apache 2.0 license](LICENSE).\n\n## Contact\n\nIf you have any issues or feature requests, please contact us. PR is welcomed.\n- https://github.com/casbin/node-casbin/issues\n- https://discord.gg/S5UjpzGZjN\n","funding_links":["https://github.com/sponsors/casbin"],"categories":["Packages","TypeScript","Repository","资源","包","Authorization","目录","Implementations(Examples/Demos)","nodejs","Authorization Development","Uncategorized"],"sub_categories":["Authorization","集成","授权","\u003ca name=\"authZ-node\"\u003e\u003c/a\u003eNode.js","授权库","Invalidating JWT","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fnode-casbin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasbin%2Fnode-casbin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fnode-casbin/lists"}