casbin / casbin-cpp

An authorization library that supports access control models like ACL, RBAC, ABAC in C/C++
https://casbin.org
Apache License 2.0
218 stars 61 forks source link

fix: add KeyGet for built_in_functions #212

Closed cs1137195420 closed 1 year ago

cs1137195420 commented 1 year ago

part of: #209 add KeyGet(), KeyGet2() and KeyGet3() for built_in_functions

casbin-bot commented 1 year ago

@EmperorYP7 @sheny1xuan please review

hsluoyz commented 1 year ago

@cs1137195420 plz also port all related tests from Go to CPP

hsluoyz commented 1 year ago

@JalinWang plz review

JalinWang commented 1 year ago

There are too many if-else statements, making the code hard to understand. Would it be better if you add some comments to illustrate what the case the code is dealing with?

cs1137195420 commented 1 year ago

@hsluoyz @JalinWang I tested the functions in built_in_functions with Casbin's test cases, and found that some of the original keymatch functions still failed in some examples. I will implement these error functions with regular matching later, and upload them together with the test case. For example, KeyMatch3 will return false for the regular expression /proxy/{id}/*/{res} and the string /proxy/myid/res/res2/res3.

hsluoyz commented 1 year ago

@cs1137195420 a good practice is using exactly the same logic as Golang, just port Go code to C++.

cs1137195420 commented 1 year ago

@cs1137195420 a good practice is using exactly the same logic as Golang, just port Go code to C++.

I agree with you. That is exactly what I am going to do next.

hsluoyz commented 1 year ago

@cs1137195420 fix all errors:

image

hsluoyz commented 1 year ago

@JalinWang @sheny1xuan @EmperorYP7 plz review

hsluoyz commented 1 year ago

@sheny1xuan

hsluoyz commented 1 year ago

@cs1137195420 fix:

image

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 1.50.4 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: