chore(release): 1.0.0 [skip ci] # 1.0.0 (2026-02-02) ### Bug Fixes * 'eval' not detected ([86e2add](https://github.com/casbin/casbin-core/commit/86e2add7c5aaa7901d21c1c4b9cb8e6d0b8bef75)) * *matcher result should be boolean or number* for KeyGet2 ([#347](https://github.com/casbin/casbin-core/issues/347)) ([762e3fb](https://github.com/casbin/casbin-core/commit/762e3fb82f13f635bd1ac4b58da23911b5f35fc3)) * `getImplicitPermissionsForUser` works with rmMap ([#272](https://github.com/casbin/casbin-core/issues/272)) ([0d59239](https://github.com/casbin/casbin-core/commit/0d5923998fa71648c8f77a23f67ffffac2a09343)) * add cache to generateGFunction ([e90bed2](https://github.com/casbin/casbin-core/commit/e90bed24f6e6e3cd5b33a433c4fe7a27e494cabe)) * add casbin-cpp to supported languages. ([b856734](https://github.com/casbin/casbin-core/commit/b85673432f8a150490fd5134797508ccd368b81f)) * add check if the adapter implements BatchAdapter ([a415838](https://github.com/casbin/casbin-core/commit/a415838a514706af8a9399c899959bdb069619d4)) * add checks fieldValues to remove filtered policy ([6e144fb](https://github.com/casbin/casbin-core/commit/6e144fb9a895332245006ef3a28c47d022654895)) * Add examples. ([5cf950a](https://github.com/casbin/casbin-core/commit/5cf950ad25eecfad59281d5ba9d6ddae5cde199e)) * add full supoort for `in` operator ([#310](https://github.com/casbin/casbin-core/issues/310)) ([446f8c7](https://github.com/casbin/casbin-core/commit/446f8c700ab13cea5413d311da33e80dd6165f0e)) * Add imports and batchFileAdapter implementation. ([3804c3d](https://github.com/casbin/casbin-core/commit/3804c3d76802614104016a011c07c11c54a94632)) * add missing await ([523ce85](https://github.com/casbin/casbin-core/commit/523ce8508ce45d7e79673bb0b498ed017772815d)) * add support for legacy array definition method ([#313](https://github.com/casbin/casbin-core/issues/313)) ([635eece](https://github.com/casbin/casbin-core/commit/635eece1bead0bb365b9ea50f325860d1df3abc6)) * Add tests for batch operations. ([e6ad7af](https://github.com/casbin/casbin-core/commit/e6ad7af69344a5bd95b6490f162dba83d10c98fb)) * Added ABAC policy logic to the private enforcer. ([c6fc487](https://github.com/casbin/casbin-core/commit/c6fc48750313b400fb98e12802b3422bfc1921bf)) * Added util functions and util tests. ([72918bc](https://github.com/casbin/casbin-core/commit/72918bc677e898251dd4375516c31254e79eb6b8)) * **builtinoperators:** fix function keyMatch3 ([1245aa0](https://github.com/casbin/casbin-core/commit/1245aa072b47135b49cb70abeed0796908a8feb7)), closes [#214](https://github.com/casbin/casbin-core/issues/214) * check adapter type ([a74314d](https://github.com/casbin/casbin-core/commit/a74314d6c4e1e1c8731128e6bfe9e2de1b3f45ce)) * compatible types ([58242a5](https://github.com/casbin/casbin-core/commit/58242a56f9f72b1a06e4901867f502b73674d640)) * created two regex expressions ([de5f2f4](https://github.com/casbin/casbin-core/commit/de5f2f4f27f40941b125bf068b8f90e44ba69fb1)) * downgrade expression-eval back to v2.0.0 to avoid semantic-release failure, revert: https://github.com/casbin/node-casbin/pull/222 ([8c0b1fd](https://github.com/casbin/casbin-core/commit/8c0b1fd6b59c39350e90c768c54577396f89fefe)) * downgrade target from ESNext to ES2017 for building esm ([7dfcf93](https://github.com/casbin/casbin-core/commit/7dfcf93a2eb7a9c9116f55341537a4c81840e3d4)) * EnforceEx return allow reason ([#363](https://github.com/casbin/casbin-core/issues/363)) ([0c18aa4](https://github.com/casbin/casbin-core/commit/0c18aa4deae78b325b4479813bf2053522661d70)) * **enforcer.ts:** fix deleteUser and improve deleteRole description ([1e6af16](https://github.com/casbin/casbin-core/commit/1e6af16e939543a56dbf9cb5d39924263186fc9a)), closes [#118](https://github.com/casbin/casbin-core/issues/118) * export watcherEx ([#15](https://github.com/casbin/casbin-core/issues/15)) ([699c8f5](https://github.com/casbin/casbin-core/commit/699c8f5b78b0f40387e4c5a109f0906fe2617edb)) * fix `in` opertor ([17f3588](https://github.com/casbin/casbin-core/commit/17f35881522d1ad454de1a70ee1b12db7735788a)) * fix buildRoleLinks to isolate groups ([0fb6ae7](https://github.com/casbin/casbin-core/commit/0fb6ae798ef692aaef890472421f980b58a4dfec)) * fix CasbinJsGetPermissionForUser() ([#251](https://github.com/casbin/casbin-core/issues/251)) ([98c11f1](https://github.com/casbin/casbin-core/commit/98c11f1451e71b0b002b140387f2a38bb9957c38)) * fix cherry-pick ([242ba50](https://github.com/casbin/casbin-core/commit/242ba50ab3c7cbabf588977f54fe3c994d08ec45)) * fix error overloading for role manager ([#319](https://github.com/casbin/casbin-core/issues/319)) ([e69450b](https://github.com/casbin/casbin-core/commit/e69450b53a06be4abda9b1669d578ef1e27dc19d)) * fix errror type ([dc9e5b5](https://github.com/casbin/casbin-core/commit/dc9e5b5db766d64918a7670f6b3b72f70e84ca28)) * fix library ([164a29a](https://github.com/casbin/casbin-core/commit/164a29acd4900fc65f8f1005281a4fbf3ed18873)) * fix logic error and add unittests ([e36cc23](https://github.com/casbin/casbin-core/commit/e36cc239b1588e884453e5441eda184350fdae39)) * fix unexpected parser action ([3074fa9](https://github.com/casbin/casbin-core/commit/3074fa9050ca073eb4c0f4197c63f13e9e7f9ebf)) * getImplicitPermissionsForUser missing domain parameter ([584624c](https://github.com/casbin/casbin-core/commit/584624c99eabca68fc790d66fc4737511d92b074)) * ignore print model ([f426131](https://github.com/casbin/casbin-core/commit/f426131e752143251db6c11a7352d91d959cb503)) * improve load policy line ([9f12511](https://github.com/casbin/casbin-core/commit/9f12511e5fbfb16646b38ad30e345beee5179c9d)) * improve tokens separator ([687e96f](https://github.com/casbin/casbin-core/commit/687e96f1495de12bc7acd37bf56af57af490b0b6)) * improve update into adapter before model ([0e9ccc6](https://github.com/casbin/casbin-core/commit/0e9ccc6b2e4387b9130df8af4fa0e23f7e73958b)) * Merge conflicts. ([7179b17](https://github.com/casbin/casbin-core/commit/7179b17f7733f72fdd1d13ca6a7818415deb6d9c)) * **rbac:** fix defaultRoleManager hasRole method ([#211](https://github.com/casbin/casbin-core/issues/211)) ([4f3ba65](https://github.com/casbin/casbin-core/commit/4f3ba65429f91250485b8a0b070f16cb750955cd)) * remove lodash ([293a852](https://github.com/casbin/casbin-core/commit/293a852803d5e83562a36bc35cdf48def0f0088b)) * remove unused import ([2f8801c](https://github.com/casbin/casbin-core/commit/2f8801c47e716f69c36b49a73a45c67d9c751b92)) * remove use spread operator with await in array ([6e4f876](https://github.com/casbin/casbin-core/commit/6e4f87676301470a178ccd10efd28f6758cc738e)) * rename StringAdapter to MemoryAdapter ([0b1019a](https://github.com/casbin/casbin-core/commit/0b1019aa2324ea4ea4c37119728dadac1bcf1fc3)) * **replaceeval:** add third param to replaceEval and only replace eval() w/ matching ruleName ([#316](https://github.com/casbin/casbin-core/issues/316)) ([bd4f5bf](https://github.com/casbin/casbin-core/commit/bd4f5bfb726c56b323d1417dc415deca21d2c170)), closes [#315](https://github.com/casbin/casbin-core/issues/315) * stackoverflow in getImplicitRolesForUser ([d0fc49f](https://github.com/casbin/casbin-core/commit/d0fc49fb12c7cbb9f985d444c1ed7613ded0121b)) * support comments after expression ([c97cb26](https://github.com/casbin/casbin-core/commit/c97cb26441d79316960a0464e8d56918859d969c)) * Support for loadIncrementalFilteredPolicy ([72c2001](https://github.com/casbin/casbin-core/commit/72c2001ab064d190bfa5bcd305829d083eca52f7)) * support pattern function in 3rd args of g ([#199](https://github.com/casbin/casbin-core/issues/199)) ([27005f8](https://github.com/casbin/casbin-core/commit/27005f85829f11193cb4ecfd14be5ed6e64ad63c)) * tests. ([4da5291](https://github.com/casbin/casbin-core/commit/4da52916d27f262a4813d2b4ff78461312b67c22)) * transfer from micromatch to picomatch ([#264](https://github.com/casbin/casbin-core/issues/264)) ([6be1b06](https://github.com/casbin/casbin-core/commit/6be1b06f2225bc906b2a0e215ff8635c6dd3422f)) * update casbinJsGetPermissionForUser for v0.1.0 Casbin.js ([#186](https://github.com/casbin/casbin-core/issues/186)) ([6c277e8](https://github.com/casbin/casbin-core/commit/6c277e8858cf07d9a098817b72710a30c4117fa9)) * update expression-eval ([95de296](https://github.com/casbin/casbin-core/commit/95de29650251af781d8638011dcc5cabeef2784c)) * use csv-like format ([3b54c93](https://github.com/casbin/casbin-core/commit/3b54c934d0d9d08a4af18799c1292f9dc728e6a4)) * use minimatch instead of picomatch ([90e7128](https://github.com/casbin/casbin-core/commit/90e7128d6ed502a72f6f92cbcaafa63dccb6ebf3)) ### Features * [#357](https://github.com/casbin/casbin-core/issues/357) Support keyMatch5 ([#359](https://github.com/casbin/casbin-core/issues/359)) ([c8195db](https://github.com/casbin/casbin-core/commit/c8195dbfa9717aa7492fcfe6fb2e1afc6492cbcb)) * add addMatchingFunc to DefaultRoleManager ([cc04e65](https://github.com/casbin/casbin-core/commit/cc04e659a1c3b78bb12dcccbb2149bfd9d96c97c)) * add BuildIncrementalRoleLinks ([b565005](https://github.com/casbin/casbin-core/commit/b5650055a6e8c47da49dc3b7eb8646bb5bda90d9)) * add casbinJsGetPermissionForUser ([30ae126](https://github.com/casbin/casbin-core/commit/30ae126b962df6fc580ce943f20e8bf0ce5349c3)) * add enforceEx() ([#271](https://github.com/casbin/casbin-core/issues/271)) ([762efd9](https://github.com/casbin/casbin-core/commit/762efd9d9766fbc8e95f9d5160413ed2a8c6ce88)) * add getImplicitUsersForPermission ([ad9df14](https://github.com/casbin/casbin-core/commit/ad9df1417cbdb7e0d9065c78e86181d193778adf)) * add glob pattern to built-in function ([8415fc2](https://github.com/casbin/casbin-core/commit/8415fc2648796d033c85771e27219bd32541982e)) * add initRmMap ([87f8011](https://github.com/casbin/casbin-core/commit/87f801109e9cf4b0b423e3b76e1a8b9987b1b600)) * add keyGet and keyGet2 ([#302](https://github.com/casbin/casbin-core/issues/302)) ([36e83cf](https://github.com/casbin/casbin-core/commit/36e83cf6fef78d954062ae61d26a74842e6367d2)) * Add lazyload option at enforcer init method ([#289](https://github.com/casbin/casbin-core/issues/289)) ([e858dcb](https://github.com/casbin/casbin-core/commit/e858dcbab2351de038e2c5385bbfd20b7aa255ad)) * add named addMatchingFunc ([65d3a26](https://github.com/casbin/casbin-core/commit/65d3a2655c638085938de9df4efa5a7d16bfa788)) * add policyArrayToString and policyStringToArray to util ([0f66bc1](https://github.com/casbin/casbin-core/commit/0f66bc1b2fcddfd9c6e847dd06fd4a5f53c55fa9)) * add priority_policy_explicit support ([#250](https://github.com/casbin/casbin-core/issues/250)) ([763c18e](https://github.com/casbin/casbin-core/commit/763c18e7f3cfa068e7b61fdd7491dd0365b86dca)) * add support for `in` operator ([a44c6a9](https://github.com/casbin/casbin-core/commit/a44c6a99ed36634a67e7888472e8f6d324b257f4)) * add sync mode ([70e4e12](https://github.com/casbin/casbin-core/commit/70e4e12610dc42b6f25f8df268611ee1a0cbc7bd)) * add unittest ([3cd5b73](https://github.com/casbin/casbin-core/commit/3cd5b7307b54342849029c957ceec81fc84f0fdd)) * add updatePolicy() ([#234](https://github.com/casbin/casbin-core/issues/234)) ([a3218f1](https://github.com/casbin/casbin-core/commit/a3218f1a5d134838c0fb90c8ad1c8751e26c6332)), closes [#235](https://github.com/casbin/casbin-core/issues/235) * add WatcherEX interface ([#13](https://github.com/casbin/casbin-core/issues/13)) ([e0079fb](https://github.com/casbin/casbin-core/commit/e0079fbbb58e4218544f1528597294c48340d5ae)) * addPoliciesWithAffected & removePoliciesWithAffected ([#12](https://github.com/casbin/casbin-core/issues/12)) ([57fcebd](https://github.com/casbin/casbin-core/commit/57fcebd356237c2216b507324d82cc6dc6d6a26f)) * avoid miss initialize() ([1394e8d](https://github.com/casbin/casbin-core/commit/1394e8ddfdc4cc9d8859ae034a8f36fb9e3b54e7)) * **batchenforce:** added batchEnforce ([#338](https://github.com/casbin/casbin-core/issues/338)) ([56e55bd](https://github.com/casbin/casbin-core/commit/56e55bd58b0f5be4a45e753f5ad58b01a27ef8b2)), closes [#321](https://github.com/casbin/casbin-core/issues/321) * call watcherEx methods ([#16](https://github.com/casbin/casbin-core/issues/16)) ([b7ce2a9](https://github.com/casbin/casbin-core/commit/b7ce2a9e54c34605b827b2f5c673650b52fca376)) * changing TypeScript target from ES6 to ES2017 ([6f4f50f](https://github.com/casbin/casbin-core/commit/6f4f50f205dfb7187e34a0439f2b4f0bf6ed5a47)) * controls whether to automatically notify Watcher ([2ce07c2](https://github.com/casbin/casbin-core/commit/2ce07c29cd49c6da304063e8075923b739fc5145)) * enforcer reactjs test ([#2](https://github.com/casbin/casbin-core/issues/2)) ([a111a1a](https://github.com/casbin/casbin-core/commit/a111a1acc244d8cb0aa3b862be05f49d76431f4e)) * enforceSync ([ff41f0a](https://github.com/casbin/casbin-core/commit/ff41f0a7c6eebbfafe985a929eba9e70f2c4b162)) * Extend multiple sections type of escapeAssertion ([#180](https://github.com/casbin/casbin-core/issues/180)) ([33c784c](https://github.com/casbin/casbin-core/commit/33c784cbdc0d650ba75b8177b69f41dc0ca11fae)) * fix and update CI scripts ([#24](https://github.com/casbin/casbin-core/issues/24)) ([c637584](https://github.com/casbin/casbin-core/commit/c637584657bad40391557b487a6270a7307cbb74)) * fix CI: fix TS18046 errors in catch blocks for strict mode compliance ([#21](https://github.com/casbin/casbin-core/issues/21)) ([4ef4abd](https://github.com/casbin/casbin-core/commit/4ef4abd2faa4f50d1724e6f189c218156a8b3aaf)) * getAllUsersByDomain, getFieldIndex ([#14](https://github.com/casbin/casbin-core/issues/14)) ([99f7735](https://github.com/casbin/casbin-core/commit/99f7735714f7a305353b33e9fb5322c42e2d161b)) * getImplicitUsersForRole ([#341](https://github.com/casbin/casbin-core/issues/341)) ([ebfaede](https://github.com/casbin/casbin-core/commit/ebfaede003cf0a4eef8a16f815f06518e74974fb)) * implement csv parser ([968a232](https://github.com/casbin/casbin-core/commit/968a23237b3193e594910f5f798bf349d6bff04c)) * implement string adapater ([0c59cae](https://github.com/casbin/casbin-core/commit/0c59cae0eba851509ff754b6f523a4feafc11f80)) * implementation cachedEnforcer ([0ace1a6](https://github.com/casbin/casbin-core/commit/0ace1a66a36d5fe3ada37bfaaa938b84fc001c58)) * improve effector for improve performance ([57de7b2](https://github.com/casbin/casbin-core/commit/57de7b2f1d21ceebb7097552c86721d94cac2275)) * improve README ([2522ae8](https://github.com/casbin/casbin-core/commit/2522ae8af858ee3853a5719e73afb94e5cd21f97)) * modernize CI workflows and README badges, regenerate yarn.lock ([#19](https://github.com/casbin/casbin-core/issues/19)) ([e48735c](https://github.com/casbin/casbin-core/commit/e48735c32b366b7074b5e625801ea05800bca3d2)) * Multiple sections type ([cc58c57](https://github.com/casbin/casbin-core/commit/cc58c57ae4a7c3202c7217497bef8016df93fe26)) * RBAC with Domains API ([3e38bb5](https://github.com/casbin/casbin-core/commit/3e38bb5a7223657fae21896ba2e0b9b39e099481)) * **rbac:** add `getUsersForRoleInDomain` & `getRolesForUserInDomain` ([#351](https://github.com/casbin/casbin-core/issues/351)) ([c787b12](https://github.com/casbin/casbin-core/commit/c787b12c6d3cb646e622cf9ce9089376a1d1cc97)), closes [#304](https://github.com/casbin/casbin-core/issues/304) * synchronized enforcer ([ecec514](https://github.com/casbin/casbin-core/commit/ecec514a582f1bfad94214b61ee06fc1cab3fc36)) * use new license format ([284d2a4](https://github.com/casbin/casbin-core/commit/284d2a48cd67db8c197de24a99029858dbbe2da8)) ### improvement * convert all management_api to async function ([e9f4d38](https://github.com/casbin/casbin-core/commit/e9f4d38e153b10ffbd4fa09355ec72eb3dae47cd)) ### BREAKING CHANGES * **model** addPolicies, removePolicies and removeFilteredPolicy returns [boolean, string[][]] * - provides a new interface for Effector * see #
News: still worry about how to write the correct casbin-core policy? Casbin online editor is coming to help!
casbin-core is a powerful and efficient open-source access control library for JavaScript projects. It provides support for enforcing authorization based on various access control models.
![]() | ![]() | ![]() | ![]() |
|---|---|---|---|
| Casbin | jCasbin | node-Casbin | PHP-Casbin |
| production-ready | production-ready | production-ready | production-ready |
![]() | ![]() | ![]() | ![]() |
|---|---|---|---|
| PyCasbin | Casbin.NET | Casbin-CPP | Casbin-RS |
| production-ready | production-ready | beta-test | production-ready |
https://casbin.org/docs/en/overview
Note: The project is under development and the API is unstable.
# NPM npm install casbin-core@beta --save # Yarn yarn add casbin-core@beta
New an enforcer with a model string and a memory policy, see Model section for details:
import { newEnforcer, newModel, MemoryAdapter } from 'casbin-core'; const model = newModel(` [request_definition] r = sub, obj, act [policy_definition] p = sub, obj, act [role_definition] g = _, _ [policy_effect] e = some(where (p.eft == allow)) [matchers] m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act `); const adapter = new MemoryAdapter(` p, alice, data1, read p, bob, data2, write p, data2_admin, data2, read p, data2_admin, data2, write g, alice, data2_admin `); const enforcer = await newEnforcer(model, adapter);
Note: you can also initialize an enforcer with policy in DB instead of file, see Persistence section for details.
Add an enforcement hook into your code right before the access happens:
const sub = 'alice'; // the user that wants to access a resource. const obj = 'data1'; // the resource that is going to be accessed. const act = 'read'; // the operation that the user performs on the resource. // Async: const res = await enforcer.enforce(sub, obj, act); // Sync: // const res = enforcer.enforceSync(sub, obj, act); if (res) { // permit alice to read data1 } else { // deny the request, show an error }
Besides the static policy file, casbin-core also provides API for permission management at run-time. For example, You can get all the roles assigned to a user as below:
const roles = await enforcer.getRolesForUser('alice');
See Policy management APIs for more usage.
Casbin provides two sets of APIs to manage permissions:
https://casbin.org/docs/en/supported-models
https://casbin.org/docs/en/adapters
https://casbin.org/docs/en/watchers
https://casbin.org/docs/en/role-managers
This project exists thanks to all the people who contribute.
Thank you to all our backers! 🙏 [Become a backer]
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
This project is licensed under the Apache 2.0 license.
If you have any issues or feature requests, please contact us. PR is welcomed.