-
-
Notifications
You must be signed in to change notification settings - Fork 35
feat: add GetUsersForRoleInDomain and GetRolesForUserInDomain #211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Gabriel-403 <1499015923@qq.com>
abccc2c
to
2b3ce9f
Compare
* @return the users that for role in domain. | ||
*/ | ||
public async getUsersForRoleInDomain(name: string, domain: string): Promise<string[]> { | ||
const rm = this.rmMap.get('g'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return the roles that for user in domain. | ||
*/ | ||
public async getRolesForUserInDomain(name: string, domain: string): Promise<string[]> { | ||
const rm = this.rmMap.get('g'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public async getRolesForUserInDomain(name: string, domain: string): Promise<string[]> { | ||
const rm = this.rmMap.get('g'); | ||
if (rm) return rm.getRoles(name, domain); | ||
throw new Error("RoleManager didn't exist."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why throw an exception instead of returning something like "null"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RM may be empty when there is a problem with the acquisition or policy,I'm changing this part and wil commit them together with all the methods of the domain
public async getUsersForRoleInDomain(name: string, domain: string): Promise<string[]> { | ||
const rm = this.rmMap.get('g'); | ||
if (rm) return rm.getUsers(name, domain); | ||
throw new Error("RoleManager didn't exist."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why throw an exception instead of returning something like "null"?
* docs: RBAC with Domains API for casbin.js 1 casbin/casbin.js#211 * fix: Case problem * fix: Case problem
# 1.0.0-beta.1 (2021-08-22) ### Bug Fixes * `getImplicitPermissionsForUser` works with rmMap ([casbin#272](casbin#272)) ([0d59239](casbin@0d59239)) * add cache to generateGFunction ([e90bed2](casbin@e90bed2)) * add casbin-cpp to supported languages. ([b856734](casbin@b856734)) * add check if the adapter implements BatchAdapter ([a415838](casbin@a415838)) * add checks fieldValues to remove filtered policy ([6e144fb](casbin@6e144fb)) * Add examples. ([5cf950a](casbin@5cf950a)) * Add imports and batchFileAdapter implementation. ([3804c3d](casbin@3804c3d)) * add missing await ([523ce85](casbin@523ce85)) * Add tests for batch operations. ([e6ad7af](casbin@e6ad7af)) * Added ABAC policy logic to the private enforcer. ([c6fc487](casbin@c6fc487)) * Added util functions and util tests. ([72918bc](casbin@72918bc)) * check adapter type ([a74314d](casbin@a74314d)) * compatible types ([58242a5](casbin@58242a5)) * downgrade expression-eval back to v2.0.0 to avoid semantic-release failure, revert: casbin/node-casbin#222 ([8c0b1fd](casbin@8c0b1fd)) * downgrade target from ESNext to ES2017 for building esm ([7dfcf93](casbin@7dfcf93)) * fix buildRoleLinks to isolate groups ([0fb6ae7](casbin@0fb6ae7)) * fix CasbinJsGetPermissionForUser() ([casbin#251](casbin#251)) ([98c11f1](casbin@98c11f1)) * fix errror type ([dc9e5b5](casbin@dc9e5b5)) * fix logic error and add unittests ([82124e3](casbin@82124e3)) * fix unexpected parser action ([3074fa9](casbin@3074fa9)) * getImplicitPermissionsForUser missing domain parameter ([584624c](casbin@584624c)) * ignore print model ([f426131](casbin@f426131)) * improve load policy line ([9f12511](casbin@9f12511)) * improve tokens separator ([687e96f](casbin@687e96f)) * improve update into adapter before model ([0e9ccc6](casbin@0e9ccc6)) * Merge conflicts. ([7179b17](casbin@7179b17)) * remove lodash ([293a852](casbin@293a852)) * remove unused import ([2f8801c](casbin@2f8801c)) * remove use spread operator with await in array ([6e4f876](casbin@6e4f876)) * rename StringAdapter to MemoryAdapter ([aa92d40](casbin@aa92d40)) * stackoverflow in getImplicitRolesForUser ([d0fc49f](casbin@d0fc49f)) * support comments after expression ([c97cb26](casbin@c97cb26)) * Support for loadIncrementalFilteredPolicy ([72c2001](casbin@72c2001)) * support pattern function in 3rd args of g ([casbin#199](casbin#199)) ([27005f8](casbin@27005f8)) * tests. ([4da5291](casbin@4da5291)) * transfer from micromatch to picomatch ([casbin#264](casbin#264)) ([6be1b06](casbin@6be1b06)) * update expression-eval ([95de296](casbin@95de296)) * use csv-like format ([32ec20d](casbin@32ec20d)) * **builtinoperators:** fix function keyMatch3 ([1245aa0](casbin@1245aa0)), closes [casbin#214](casbin#214) * **enforcer.ts:** fix deleteUser and improve deleteRole description ([1e6af16](casbin@1e6af16)), closes [casbin#118](casbin#118) * **rbac:** fix defaultRoleManager hasRole method ([casbin#211](casbin#211)) ([4f3ba65](casbin@4f3ba65)) * update casbinJsGetPermissionForUser for v0.1.0 Casbin.js ([casbin#186](casbin#186)) ([6c277e8](casbin@6c277e8)) ### Features * add addMatchingFunc to DefaultRoleManager ([cc04e65](casbin@cc04e65)) * add BuildIncrementalRoleLinks ([b565005](casbin@b565005)) * add casbinJsGetPermissionForUser ([30ae126](casbin@30ae126)) * add enforceEx() ([casbin#271](casbin#271)) ([762efd9](casbin@762efd9)) * add getImplicitUsersForPermission ([ad9df14](casbin@ad9df14)) * add glob pattern to built-in function ([8415fc2](casbin@8415fc2)) * add initRmMap ([87f8011](casbin@87f8011)) * Add lazyload option at enforcer init method ([#289](https://github.com/casbin/casbin.js/issues/289)) ([e858dcb](casbin@e858dcb)) * add named addMatchingFunc ([65d3a26](casbin@65d3a26)) * add policyArrayToString and policyStringToArray to util ([e71b40f](casbin@e71b40f)) * add priority_policy_explicit support ([casbin#250](casbin#250)) ([763c18e](casbin@763c18e)) * add support for `in` operator ([a44c6a9](casbin@a44c6a9)) * add sync mode ([70e4e12](casbin@70e4e12)) * add unittest ([3cd5b73](casbin@3cd5b73)) * add updatePolicy() ([casbin#234](casbin#234)) ([a3218f1](casbin@a3218f1)), closes [casbin#235](casbin#235) * avoid miss initialize() ([1394e8d](casbin@1394e8d)) * changing TypeScript target from ES6 to ES2017 ([6f4f50f](casbin@6f4f50f)) * controls whether to automatically notify Watcher ([2ce07c2](casbin@2ce07c2)) * enforceSync ([ff41f0a](casbin@ff41f0a)) * implement csv parser ([f2ddaab](casbin@f2ddaab)) * implement string adapater ([fabd784](casbin@fabd784)) * implementation cachedEnforcer ([0ace1a6](casbin@0ace1a6)) * improve effector for improve performance ([57de7b2](casbin@57de7b2)) * support RBAC for syncedEnforcer ([casbin#150](casbin#150)) ([2bf4299](casbin@2bf4299)) * sync with upstream ([ca4b572](casbin@ca4b572)) * synchronized enforcer ([ecec514](casbin@ecec514)) * use new license format ([284d2a4](casbin@284d2a4)) ### improvement * convert all management_api to async function ([e9f4d38](casbin@e9f4d38)) ### BREAKING CHANGES * **model** addPolicies, removePolicies and removeFilteredPolicy returns [boolean, string[][]] * - provides a new interface for Effector * see #
# 1.0.0 (2021-10-30) ### Bug Fixes * `getImplicitPermissionsForUser` works with rmMap ([#272](#272)) ([0d59239](0d59239)) * add cache to generateGFunction ([e90bed2](e90bed2)) * add casbin-cpp to supported languages. ([b856734](b856734)) * add check if the adapter implements BatchAdapter ([a415838](a415838)) * add checks fieldValues to remove filtered policy ([6e144fb](6e144fb)) * Add examples. ([5cf950a](5cf950a)) * Add imports and batchFileAdapter implementation. ([3804c3d](3804c3d)) * add missing await ([523ce85](523ce85)) * Add tests for batch operations. ([e6ad7af](e6ad7af)) * Added ABAC policy logic to the private enforcer. ([c6fc487](c6fc487)) * Added util functions and util tests. ([72918bc](72918bc)) * check adapter type ([a74314d](a74314d)) * compatible types ([58242a5](58242a5)) * downgrade expression-eval back to v2.0.0 to avoid semantic-release failure, revert: casbin/node-casbin#222 ([8c0b1fd](8c0b1fd)) * downgrade target from ESNext to ES2017 for building esm ([7dfcf93](7dfcf93)) * fix buildRoleLinks to isolate groups ([0fb6ae7](0fb6ae7)) * fix CasbinJsGetPermissionForUser() ([#251](#251)) ([98c11f1](98c11f1)) * fix errror type ([dc9e5b5](dc9e5b5)) * fix logic error and add unittests ([82124e3](82124e3)) * fix ts4 build configuration ([a5034c8](a5034c8)) * fix unexpected parser action ([3074fa9](3074fa9)) * getImplicitPermissionsForUser missing domain parameter ([584624c](584624c)) * ignore print model ([f426131](f426131)) * improve load policy line ([9f12511](9f12511)) * improve tokens separator ([687e96f](687e96f)) * improve update into adapter before model ([0e9ccc6](0e9ccc6)) * Merge conflicts. ([7179b17](7179b17)) * remove lodash ([293a852](293a852)) * remove unused import ([2f8801c](2f8801c)) * remove use spread operator with await in array ([6e4f876](6e4f876)) * rename StringAdapter to MemoryAdapter ([aa92d40](aa92d40)) * stackoverflow in getImplicitRolesForUser ([d0fc49f](d0fc49f)) * support comments after expression ([c97cb26](c97cb26)) * Support for loadIncrementalFilteredPolicy ([72c2001](72c2001)) * support pattern function in 3rd args of g ([#199](#199)) ([27005f8](27005f8)) * tests. ([4da5291](4da5291)) * transfer from micromatch to picomatch ([#264](#264)) ([6be1b06](6be1b06)) * update expression-eval ([95de296](95de296)) * use csv-like format ([32ec20d](32ec20d)) * **builtinoperators:** fix function keyMatch3 ([1245aa0](1245aa0)), closes [#214](#214) * **enforcer.ts:** fix deleteUser and improve deleteRole description ([1e6af16](1e6af16)), closes [#118](#118) * **rbac:** fix defaultRoleManager hasRole method ([#211](#211)) ([4f3ba65](4f3ba65)) * update casbinJsGetPermissionForUser for v0.1.0 Casbin.js ([#186](#186)) ([6c277e8](6c277e8)) ### Features * add addMatchingFunc to DefaultRoleManager ([cc04e65](cc04e65)) * add BuildIncrementalRoleLinks ([b565005](b565005)) * add casbinJsGetPermissionForUser ([30ae126](30ae126)) * add enforceEx() ([#271](#271)) ([762efd9](762efd9)) * add getImplicitUsersForPermission ([ad9df14](ad9df14)) * add glob pattern to built-in function ([8415fc2](8415fc2)) * add initRmMap ([87f8011](87f8011)) * Add lazyload option at enforcer init method ([#289](https://github.com/casbin/casbin.js/issues/289)) ([e858dcb](e858dcb)) * add named addMatchingFunc ([65d3a26](65d3a26)) * add policyArrayToString and policyStringToArray to util ([e71b40f](e71b40f)) * add priority_policy_explicit support ([#250](#250)) ([763c18e](763c18e)) * add support for `in` operator ([a44c6a9](a44c6a9)) * add sync mode ([70e4e12](70e4e12)) * add unittest ([3cd5b73](3cd5b73)) * add updatePolicy() ([#234](#234)) ([a3218f1](a3218f1)), closes [#235](#235) * avoid miss initialize() ([1394e8d](1394e8d)) * changing TypeScript target from ES6 to ES2017 ([6f4f50f](6f4f50f)) * controls whether to automatically notify Watcher ([2ce07c2](2ce07c2)) * enforceSync ([ff41f0a](ff41f0a)) * Extend multiple sections type of escapeAssertion ([#180](#180)) ([4a8cc10](4a8cc10)) * implement csv parser ([f2ddaab](f2ddaab)) * implement string adapater ([fabd784](fabd784)) * implementation cachedEnforcer ([0ace1a6](0ace1a6)) * improve effector for improve performance ([57de7b2](57de7b2)) * Multiple sections type ([2635601](2635601)) * RBAC with Domains API ([5e49b41](5e49b41)) * support RBAC for syncedEnforcer ([#150](#150)) ([2bf4299](2bf4299)) * sync with upstream ([ca4b572](ca4b572)) * synchronized enforcer ([ecec514](ecec514)) * use new license format ([284d2a4](284d2a4)) ### improvement * convert all management_api to async function ([e9f4d38](e9f4d38)) ### BREAKING CHANGES * **model** addPolicies, removePolicies and removeFilteredPolicy returns [boolean, string[][]] * - provides a new interface for Effector * see #
|
No description provided.