casbin / casbin.js

An authorization library that supports access control models like ACL, RBAC, ABAC in Frontend Javascript
https://casbin.org/docs/en/frontend
Apache License 2.0
165 stars 37 forks source link

fix: configure it with multiple policies #172

Closed Gabriel-403 closed 3 years ago

Gabriel-403 commented 3 years ago

If you need multiple policy definitions or multiple matcher, you can use like p2, m2. In fact, all of the above four sections can use multiple types and the syntax is r+number, such as r2, e2. By default these four sections should correspond one to one. Such as your r2 will only use matcher m2 to match policies p2.

coveralls commented 3 years ago

Pull Request Test Coverage Report for Build 1153894786


Totals Coverage Status
Change from base Build 1153544760: 0.04%
Covered Lines: 1329
Relevant Lines: 1674

💛 - Coveralls
coveralls commented 3 years ago

Pull Request Test Coverage Report for Build 1154275423


Totals Coverage Status
Change from base Build 1153544760: 0.04%
Covered Lines: 1329
Relevant Lines: 1674

💛 - Coveralls
nodece commented 3 years ago

@Gabriel-403 please add unit tests for this feature.

nodece commented 3 years ago

@Gabriel-403 You should keep consistent with the implementation of golang version.

kingiw commented 3 years ago

@Gabriel-403 You should keep consistent with the implementation of golang version.

Agree with @nodece. Casbin in Go uses a suffix to identify different enforcer contexts. You can refer to the implementation:

Implementation: https://github.com/casbin/casbin/blob/master/enforcer.go#L457 Usage example: https://github.com/casbin/casbin/blob/master/enforcer_test.go#L534

I think you can make a minor change so we can keep a same solution to multi policies in diverse Casbin project.

Gabriel-403 commented 3 years ago

@kingiw ok,Already completed!

kingiw commented 3 years ago

Besides, maybe you should fetch the origin repo, rebase locally and resolve the conflicts before making a pr.

hsluoyz commented 3 years ago

@Gabriel-403 plz resolve git conflicts locally

hsluoyz commented 3 years ago

Replaced by: https://github.com/casbin/casbin.js/pull/176

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 1153903237

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/coreEnforcer.ts 8 9 88.89%
<!-- Total: 11 12 91.67% -->
Totals Coverage Status
Change from base Build 1153544760: 0.04%
Covered Lines: 1329
Relevant Lines: 1674

💛 - Coveralls