casbin / casbin-rs

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

feat: added enforcer context to enable multiple section type #317

Closed worapolw closed 11 months ago

worapolw commented 11 months ago

Added enforcer context struct + function for enabling multiple section type

P.S. I'm very new to the community. So, If I do anything wrong, please don't hesitate to tell and correct me.

Thank you

CLAassistant commented 11 months ago

CLA assistant check
All committers have signed the CLA.

github-actions[bot] commented 11 months ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 10.2±0.24ms | **9.9±0.12ms** | **+3.03%** | | benchmark priority model | **5.0±0.08µs** | 5.1±0.12µs | **-1.96%** | | benchmark_abac_model | 2.7±0.07µs | **2.6±0.06µs** | **+3.85%** | | benchmark_basic_model | **4.3±0.05µs** | 4.5±0.09µs | **-4.44%** | | benchmark_key_match | 8.4±0.09µs | 8.4±0.40µs | 0.00% | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 7.2±0.18µs | 7.3±0.11µs | -1.37% | | benchmark_rbac_model_medium | 877.7±14.38µs | **843.0±13.43µs** | **+4.12%** | | benchmark_rbac_model_with_domains | 7.3±0.14µs | **7.2±0.07µs** | **+1.39%** | | benchmark_rbac_with_deny | 10.0±0.14µs | **9.7±0.18µs** | **+3.09%** | | benchmark_rbac_with_resource_roles | 5.5±0.21µs | **5.4±0.09µs** | **+1.85%** | | benchmark_role_manager_large | 4.9±0.04ms | **4.7±0.02ms** | **+4.26%** | | benchmark_role_manager_medium | **317.6±5.69µs** | 323.0±4.96µs | **-1.67%** | | benchmark_role_manager_small | **31.6±1.22µs** | 32.2±0.43µs | **-1.86%** |
github-actions[bot] commented 11 months ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | **10.0±0.23ms** | 10.3±0.71ms | **-2.91%** | | benchmark priority model | **4.9±0.09µs** | 5.0±0.09µs | **-2.00%** | | benchmark_abac_model | 2.7±0.07µs | **2.6±0.07µs** | **+3.85%** | | benchmark_basic_model | 4.5±0.08µs | 4.5±0.09µs | 0.00% | | benchmark_key_match | 8.4±0.10µs | 8.3±0.18µs | +1.20% | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 7.3±0.22µs | 7.4±0.13µs | -1.35% | | benchmark_rbac_model_medium | 868.4±34.70µs | 868.8±9.08µs | -0.05% | | benchmark_rbac_model_with_domains | **7.2±0.24µs** | 7.4±0.17µs | **-2.70%** | | benchmark_rbac_with_deny | **9.6±0.17µs** | 9.8±0.19µs | **-2.04%** | | benchmark_rbac_with_resource_roles | 5.5±0.37µs | 5.4±0.22µs | +1.85% | | benchmark_role_manager_large | 4.7±0.03ms | 4.7±0.03ms | 0.00% | | benchmark_role_manager_medium | 351.0±2.71µs | **324.3±16.13µs** | **+8.23%** | | benchmark_role_manager_small | 30.8±0.94µs | 30.5±0.64µs | +0.98% |
github-actions[bot] commented 11 months ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 10.3±0.17ms | 10.3±0.21ms | 0.00% | | benchmark priority model | **5.0±0.08µs** | 5.1±0.08µs | **-1.96%** | | benchmark_abac_model | 2.8±0.17µs | 2.8±0.13µs | 0.00% | | benchmark_basic_model | 4.5±0.20µs | **4.4±0.05µs** | **+2.27%** | | benchmark_key_match | 8.5±0.13µs | 8.6±0.12µs | -1.16% | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | **7.1±0.17µs** | 7.5±0.42µs | **-5.33%** | | benchmark_rbac_model_medium | 873.2±8.88µs | **851.5±14.19µs** | **+2.55%** | | benchmark_rbac_model_with_domains | 7.3±0.13µs | 7.3±0.11µs | 0.00% | | benchmark_rbac_with_deny | 10.0±0.09µs | **9.8±0.17µs** | **+2.04%** | | benchmark_rbac_with_resource_roles | **5.4±0.09µs** | 5.5±0.12µs | **-1.82%** | | benchmark_role_manager_large | 5.0±0.07ms | **4.8±0.02ms** | **+4.17%** | | benchmark_role_manager_medium | 337.6±5.41µs | **319.1±4.59µs** | **+5.80%** | | benchmark_role_manager_small | 32.9±0.27µs | **31.0±0.48µs** | **+6.13%** |
github-actions[bot] commented 11 months ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 10.0±0.38ms | 10.0±0.17ms | 0.00% | | benchmark priority model | 5.0±0.16µs | 5.0±0.23µs | 0.00% | | benchmark_abac_model | **2.6±0.09µs** | 2.7±0.10µs | **-3.70%** | | benchmark_basic_model | 4.4±0.06µs | **4.3±0.05µs** | **+2.33%** | | benchmark_key_match | 8.5±0.17µs | 8.5±0.17µs | 0.00% | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 7.2±0.13µs | 7.2±0.13µs | 0.00% | | benchmark_rbac_model_medium | 837.0±10.63µs | 844.0±13.18µs | -0.83% | | benchmark_rbac_model_with_domains | 7.4±0.42µs | **7.1±0.07µs** | **+4.23%** | | benchmark_rbac_with_deny | 9.8±0.19µs | 9.7±0.25µs | +1.03% | | benchmark_rbac_with_resource_roles | 5.4±0.10µs | **5.3±0.07µs** | **+1.89%** | | benchmark_role_manager_large | **4.7±0.04ms** | 4.8±0.14ms | **-2.08%** | | benchmark_role_manager_medium | 326.2±7.21µs | 328.7±4.28µs | -0.76% | | benchmark_role_manager_small | **31.6±0.97µs** | 32.6±0.52µs | **-3.07%** |
github-actions[bot] commented 11 months ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | **10.1±0.18ms** | 10.7±0.16ms | **-5.61%** | | benchmark priority model | 5.0±0.23µs | 4.9±0.18µs | +2.04% | | benchmark_abac_model | 2.6±0.08µs | 2.6±0.07µs | 0.00% | | benchmark_basic_model | 4.5±0.05µs | **4.4±0.05µs** | **+2.27%** | | benchmark_key_match | **8.4±0.08µs** | 8.5±0.14µs | **-1.18%** | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 7.4±0.08µs | 7.4±0.12µs | 0.00% | | benchmark_rbac_model_medium | **872.3±10.34µs** | 913.3±24.16µs | **-4.49%** | | benchmark_rbac_model_with_domains | 7.2±0.13µs | 7.1±0.11µs | +1.41% | | benchmark_rbac_with_deny | 9.9±0.53µs | 9.9±0.49µs | 0.00% | | benchmark_rbac_with_resource_roles | **5.2±0.24µs** | 5.4±0.09µs | **-3.70%** | | benchmark_role_manager_large | 4.8±0.03ms | 4.8±0.02ms | 0.00% | | benchmark_role_manager_medium | 325.9±8.59µs | **319.1±4.70µs** | **+2.13%** | | benchmark_role_manager_small | 32.1±0.35µs | 31.8±0.37µs | +0.94% |
github-actions[bot] commented 11 months ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 11.0±0.36ms | **10.2±0.31ms** | **+7.84%** | | benchmark priority model | 5.0±0.18µs | 5.0±0.08µs | 0.00% | | benchmark_abac_model | **2.6±0.06µs** | 2.7±0.09µs | **-3.70%** | | benchmark_basic_model | 4.4±0.09µs | 4.4±0.07µs | 0.00% | | benchmark_key_match | **8.3±0.19µs** | 8.7±0.13µs | **-4.60%** | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 7.4±0.23µs | 7.4±0.12µs | 0.00% | | benchmark_rbac_model_medium | 931.4±8.61µs | **870.9±30.74µs** | **+6.95%** | | benchmark_rbac_model_with_domains | **7.1±0.30µs** | 7.3±0.09µs | **-2.74%** | | benchmark_rbac_with_deny | 9.9±0.43µs | 9.8±0.11µs | +1.02% | | benchmark_rbac_with_resource_roles | 5.3±0.11µs | 5.3±0.18µs | 0.00% | | benchmark_role_manager_large | 4.8±0.03ms | 4.8±0.01ms | 0.00% | | benchmark_role_manager_medium | 331.0±4.26µs | **321.4±5.05µs** | **+2.99%** | | benchmark_role_manager_small | **30.6±0.52µs** | 31.3±0.59µs | **-2.24%** |
github-actions[bot] commented 11 months ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 11.0±0.16ms | **10.1±0.08ms** | **+8.91%** | | benchmark priority model | 5.0±0.11µs | 4.9±0.14µs | +2.04% | | benchmark_abac_model | 2.7±0.08µs | **2.6±0.08µs** | **+3.85%** | | benchmark_basic_model | 4.5±0.09µs | **4.4±0.08µs** | **+2.27%** | | benchmark_key_match | 8.5±0.15µs | **8.1±0.17µs** | **+4.94%** | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 7.3±0.12µs | 7.3±0.09µs | 0.00% | | benchmark_rbac_model_medium | 972.5±19.87µs | **863.4±12.28µs** | **+12.64%** | | benchmark_rbac_model_with_domains | 7.3±0.11µs | 7.2±0.17µs | +1.39% | | benchmark_rbac_with_deny | 10.1±0.20µs | **9.8±0.17µs** | **+3.06%** | | benchmark_rbac_with_resource_roles | 5.4±0.08µs | 5.4±0.10µs | 0.00% | | benchmark_role_manager_large | 4.8±0.02ms | 4.8±0.02ms | 0.00% | | benchmark_role_manager_medium | 326.4±7.16µs | 323.5±3.34µs | +0.90% | | benchmark_role_manager_small | **30.4±0.32µs** | 31.7±1.72µs | **-4.10%** |
github-actions[bot] commented 11 months ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 10.7±0.10ms | 10.6±0.14ms | +0.94% | | benchmark priority model | **4.9±0.13µs** | 5.1±0.12µs | **-3.92%** | | benchmark_abac_model | **2.6±0.09µs** | 2.7±0.06µs | **-3.70%** | | benchmark_basic_model | **4.4±0.07µs** | 4.6±0.05µs | **-4.35%** | | benchmark_key_match | 8.4±0.11µs | **8.2±0.09µs** | **+2.44%** | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | **7.1±0.26µs** | 7.5±0.07µs | **-5.33%** | | benchmark_rbac_model_medium | 937.9±17.99µs | 921.1±21.01µs | +1.82% | | benchmark_rbac_model_with_domains | **7.1±0.08µs** | 7.3±0.06µs | **-2.74%** | | benchmark_rbac_with_deny | 10.0±0.14µs | 10.0±0.13µs | 0.00% | | benchmark_rbac_with_resource_roles | 5.4±0.18µs | 5.5±0.10µs | -1.82% | | benchmark_role_manager_large | 4.8±0.02ms | **4.7±0.03ms** | **+2.13%** | | benchmark_role_manager_medium | 330.1±4.51µs | **324.3±4.06µs** | **+1.79%** | | benchmark_role_manager_small | 31.5±0.58µs | 31.5±0.45µs | 0.00% |
github-actions[bot] commented 11 months ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 10.8±0.14ms | 10.8±0.04ms | 0.00% | | benchmark priority model | **4.9±0.09µs** | 5.0±0.07µs | **-2.00%** | | benchmark_abac_model | 2.6±0.06µs | 2.6±0.07µs | 0.00% | | benchmark_basic_model | 4.4±0.08µs | 4.4±0.04µs | 0.00% | | benchmark_key_match | 8.5±0.20µs | **8.2±0.11µs** | **+3.66%** | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 7.4±0.10µs | **7.3±0.10µs** | **+1.37%** | | benchmark_rbac_model_medium | 923.2±12.33µs | **915.0±8.01µs** | **+0.90%** | | benchmark_rbac_model_with_domains | **7.1±0.10µs** | 7.3±0.12µs | **-2.74%** | | benchmark_rbac_with_deny | 9.9±0.16µs | 9.9±0.12µs | 0.00% | | benchmark_rbac_with_resource_roles | **5.3±0.06µs** | 5.4±0.09µs | **-1.85%** | | benchmark_role_manager_large | 4.8±0.02ms | 4.8±0.03ms | 0.00% | | benchmark_role_manager_medium | **322.4±4.97µs** | 331.6±5.02µs | **-2.77%** | | benchmark_role_manager_small | **30.9±0.15µs** | 31.3±0.51µs | **-1.28%** |
github-actions[bot] commented 11 months ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 10.4±0.12ms | 10.3±0.20ms | +0.97% | | benchmark priority model | 4.9±0.04µs | 4.9±0.09µs | 0.00% | | benchmark_abac_model | **2.6±0.10µs** | 2.7±0.04µs | **-3.70%** | | benchmark_basic_model | **4.4±0.11µs** | 4.5±0.05µs | **-2.22%** | | benchmark_key_match | **8.2±0.16µs** | 8.5±0.09µs | **-3.53%** | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | **7.3±0.11µs** | 7.5±0.63µs | **-2.67%** | | benchmark_rbac_model_medium | **871.9±14.73µs** | 881.6±6.36µs | **-1.10%** | | benchmark_rbac_model_with_domains | 7.2±0.21µs | 7.1±0.14µs | +1.41% | | benchmark_rbac_with_deny | 9.8±0.19µs | 9.9±0.19µs | -1.01% | | benchmark_rbac_with_resource_roles | **5.3±0.04µs** | 5.4±0.10µs | **-1.85%** | | benchmark_role_manager_large | 4.8±0.02ms | 4.8±0.02ms | 0.00% | | benchmark_role_manager_medium | 321.6±8.54µs | 324.7±5.11µs | -0.95% | | benchmark_role_manager_small | 31.1±0.64µs | 31.3±1.35µs | -0.64% |
github-actions[bot] commented 11 months ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 10.1±0.14ms | 10.1±0.15ms | 0.00% | | benchmark priority model | 5.0±0.18µs | 5.0±0.07µs | 0.00% | | benchmark_abac_model | 2.6±0.07µs | 2.6±0.10µs | 0.00% | | benchmark_basic_model | **4.3±0.07µs** | 4.6±0.04µs | **-6.52%** | | benchmark_key_match | 8.4±0.15µs | 8.3±0.19µs | +1.20% | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | **7.0±0.07µs** | 7.2±0.16µs | **-2.78%** | | benchmark_rbac_model_medium | 863.7±7.82µs | 865.2±12.99µs | -0.17% | | benchmark_rbac_model_with_domains | 7.2±0.13µs | 7.3±0.24µs | -1.37% | | benchmark_rbac_with_deny | **9.8±0.10µs** | 10.0±0.38µs | **-2.00%** | | benchmark_rbac_with_resource_roles | 5.4±0.08µs | 5.4±0.08µs | 0.00% | | benchmark_role_manager_large | 4.8±0.03ms | 4.8±0.02ms | 0.00% | | benchmark_role_manager_medium | **318.5±5.43µs** | 330.9±5.14µs | **-3.75%** | | benchmark_role_manager_small | 31.5±2.71µs | 31.5±0.27µs | 0.00% |
github-actions[bot] commented 11 months ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | **10.6±0.13ms** | 10.9±0.13ms | **-2.75%** | | benchmark priority model | **4.9±0.09µs** | 5.0±0.12µs | **-2.00%** | | benchmark_abac_model | 2.7±0.09µs | 2.7±0.10µs | 0.00% | | benchmark_basic_model | 4.5±0.36µs | **4.4±0.05µs** | **+2.27%** | | benchmark_key_match | 8.2±0.14µs | 8.2±0.71µs | 0.00% | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 7.3±0.12µs | 7.4±0.33µs | -1.35% | | benchmark_rbac_model_medium | **908.6±13.63µs** | 938.2±7.92µs | **-3.15%** | | benchmark_rbac_model_with_domains | 7.2±0.08µs | **7.1±0.15µs** | **+1.41%** | | benchmark_rbac_with_deny | 9.8±0.25µs | 9.8±0.08µs | 0.00% | | benchmark_rbac_with_resource_roles | **5.3±0.09µs** | 5.4±0.26µs | **-1.85%** | | benchmark_role_manager_large | 4.8±0.33ms | 4.8±0.02ms | 0.00% | | benchmark_role_manager_medium | 327.8±2.73µs | 325.7±5.07µs | +0.64% | | benchmark_role_manager_small | 30.9±0.59µs | **30.4±0.26µs** | **+1.64%** |