casbin / casbin-rs

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

feat: add `new_filtered_adapter()` to FileAdapter to make it act as a FilterAdapter. #319

Closed HGZ-20 closed 9 months ago

HGZ-20 commented 9 months ago

fix: #304

add new_filtered_adapter() to FileAdapter to make it act as a FilterAdapter.

And does not automatically load the policy when using the filter adapter.

github-actions[bot] commented 9 months ago

Benchmark for 49f090e

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 11.3±0.67ms | 11.2±0.15ms | +0.89% | | benchmark priority model | 4.9±0.14µs | 4.9±0.09µs | 0.00% | | benchmark_abac_model | **2.7±0.06µs** | 3.0±0.03µs | **-10.00%** | | benchmark_basic_model | 4.3±0.07µs | 4.3±0.05µs | 0.00% | | benchmark_key_match | 8.2±0.17µs | 8.2±0.10µs | 0.00% | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 7.1±0.22µs | 7.1±0.19µs | 0.00% | | benchmark_rbac_model_medium | **953.8±11.35µs** | 963.3±9.19µs | **-0.99%** | | benchmark_rbac_model_with_domains | **7.0±0.14µs** | 7.1±0.07µs | **-1.41%** | | benchmark_rbac_with_deny | 9.8±0.16µs | 9.9±0.18µs | -1.01% | | benchmark_rbac_with_resource_roles | **5.2±0.10µs** | 5.3±0.06µs | **-1.89%** | | benchmark_role_manager_large | **4.6±0.03ms** | 4.7±0.19ms | **-2.13%** | | benchmark_role_manager_medium | 317.1±9.40µs | 315.1±2.59µs | +0.63% | | benchmark_role_manager_small | 97.4±1.13µs | 97.8±2.00µs | -0.41% |
codecov[bot] commented 9 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (49f090e) 63.79% compared to head (023e525) 64.11%.

Files Patch % Lines
src/adapter/null_adapter.rs 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #319 +/- ## ========================================== + Coverage 63.79% 64.11% +0.32% ========================================== Files 24 24 Lines 1878 1881 +3 ========================================== + Hits 1198 1206 +8 + Misses 680 675 -5 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 9 months ago

Benchmark for 49f090e

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 10.2±0.14ms | 10.3±0.28ms | -0.97% | | benchmark priority model | **4.9±0.07µs** | 5.0±0.05µs | **-2.00%** | | benchmark_abac_model | 2.6±0.07µs | 2.6±0.13µs | 0.00% | | benchmark_basic_model | 4.4±0.08µs | **4.3±0.06µs** | **+2.33%** | | benchmark_key_match | **8.1±0.15µs** | 8.5±0.24µs | **-4.71%** | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 7.3±0.09µs | **7.2±0.19µs** | **+1.39%** | | benchmark_rbac_model_medium | 872.5±12.88µs | 872.8±13.83µs | -0.03% | | benchmark_rbac_model_with_domains | **7.1±0.28µs** | 7.4±0.46µs | **-4.05%** | | benchmark_rbac_with_deny | 9.8±0.13µs | **9.6±0.16µs** | **+2.08%** | | benchmark_rbac_with_resource_roles | 5.3±0.07µs | 5.3±0.10µs | 0.00% | | benchmark_role_manager_large | 4.8±0.03ms | **4.7±0.04ms** | **+2.13%** | | benchmark_role_manager_medium | 327.5±3.72µs | **322.2±3.17µs** | **+1.64%** | | benchmark_role_manager_small | 88.4±1.41µs | 88.0±1.65µs | +0.45% |