casbin / casbin-rs

An authorization library that supports access control models like ACL, RBAC, ABAC in Rust.
https://casbin.org
Apache License 2.0
861 stars 74 forks source link

feat: add key_get series built-in operator #338

Closed MuZhou233 closed 2 months ago

MuZhou233 commented 2 months ago

Fix: https://github.com/casbin/casbin-rs/issues/337

API changed: operator function definition changed due to different signature of key_get functions

github-actions[bot] commented 2 months ago

Benchmark for f4c3350

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 16.5±0.21ms | **10.3±0.26ms** | **+60.19%** | | benchmark priority model | 5.6±0.14µs | **4.3±0.11µs** | **+30.23%** | | benchmark_abac_model | 2.8±0.05µs | **2.5±0.04µs** | **+12.00%** | | benchmark_basic_model | 4.9±0.15µs | **3.9±0.15µs** | **+25.64%** | | benchmark_key_match | 8.5±0.12µs | **7.2±0.20µs** | **+18.06%** | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 8.6±0.11µs | **6.2±0.15µs** | **+38.71%** | | benchmark_rbac_model_medium | 1554.0±21.76µs | **858.8±16.30µs** | **+80.95%** | | benchmark_rbac_model_with_domains | 6.9±0.25µs | **6.0±0.09µs** | **+15.00%** | | benchmark_rbac_with_deny | 13.1±0.12µs | **8.4±0.08µs** | **+55.95%** | | benchmark_rbac_with_resource_roles | 5.6±0.08µs | **4.4±0.04µs** | **+27.27%** | | benchmark_role_manager_large | 7.6±0.04ms | **4.6±0.01ms** | **+65.22%** | | benchmark_role_manager_medium | 583.5±7.22µs | **304.7±3.85µs** | **+91.50%** | | benchmark_role_manager_small | 59.8±1.67µs | **29.5±0.44µs** | **+102.71%** |
github-actions[bot] commented 2 months ago

Benchmark for f4c3350

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 10.5±0.08ms | **10.1±0.03ms** | **+3.96%** | | benchmark priority model | 4.3±0.04µs | 4.3±0.05µs | 0.00% | | benchmark_abac_model | 2.6±0.08µs | **2.5±0.04µs** | **+4.00%** | | benchmark_basic_model | 3.9±0.03µs | 3.9±0.05µs | 0.00% | | benchmark_key_match | **7.2±0.11µs** | 7.3±0.08µs | **-1.37%** | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 6.3±0.08µs | **6.2±0.39µs** | **+1.61%** | | benchmark_rbac_model_medium | 932.3±7.23µs | **844.5±28.20µs** | **+10.40%** | | benchmark_rbac_model_with_domains | 6.0±0.05µs | 6.0±0.11µs | 0.00% | | benchmark_rbac_with_deny | 8.7±0.05µs | 8.7±0.22µs | 0.00% | | benchmark_rbac_with_resource_roles | 4.4±0.03µs | 4.4±0.09µs | 0.00% | | benchmark_role_manager_large | 4.6±0.03ms | 4.6±0.03ms | 0.00% | | benchmark_role_manager_medium | 300.2±4.33µs | 302.4±4.05µs | -0.73% | | benchmark_role_manager_small | **29.1±0.59µs** | 29.8±0.52µs | **-2.35%** |
github-actions[bot] commented 2 months ago

Benchmark for f4c3350

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | **10.2±0.08ms** | 10.3±0.04ms | **-0.97%** | | benchmark priority model | 4.4±0.08µs | **4.3±0.03µs** | **+2.33%** | | benchmark_abac_model | 2.6±0.06µs | **2.5±0.04µs** | **+4.00%** | | benchmark_basic_model | 3.9±0.18µs | 3.9±0.06µs | 0.00% | | benchmark_key_match | 7.1±0.08µs | 7.1±0.09µs | 0.00% | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 6.2±0.14µs | 6.3±0.15µs | -1.59% | | benchmark_rbac_model_medium | 878.1±9.74µs | **867.9±14.48µs** | **+1.18%** | | benchmark_rbac_model_with_domains | 6.1±0.09µs | **6.0±0.20µs** | **+1.67%** | | benchmark_rbac_with_deny | **8.6±0.15µs** | 9.1±0.15µs | **-5.49%** | | benchmark_rbac_with_resource_roles | 4.5±0.07µs | 4.5±0.08µs | 0.00% | | benchmark_role_manager_large | 4.6±0.04ms | 4.6±0.04ms | 0.00% | | benchmark_role_manager_medium | 302.3±4.11µs | 302.6±2.67µs | -0.10% | | benchmark_role_manager_small | 29.7±0.40µs | 29.6±0.60µs | +0.34% |
waterflier commented 2 months ago

Great, you're so quick! I've been researching these two days and found that adding keyGet functions requires a major adjustment to the add_function system~

Thank you so much for completing it in such a short time