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

Use petgraph inside DefaultRoleManager to model relations #293

Closed kbalt closed 2 years ago

kbalt commented 2 years ago

This relation model is built after the Go implementation, but uses edges inside the graph to model relations instead of having each role store pointers in maps.

Edges with the EdgeVariant::Link are relations which in Go are modeled by the roles and users map. Edges with the EdgeVariant::Match are relations which is Go are modeled by the matched and matchedBy map.

This change brings significant speedups in benchmarks when compared against the master branch.

casbin-bot commented 2 years ago

@smrpn @hackerchai @PsiACE @GopherJ please review

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

hsluoyz commented 2 years ago

@kbalt fix:

image

hsluoyz commented 2 years ago

@PsiACE

codecov[bot] commented 2 years ago

Codecov Report

Merging #293 (c111b47) into master (41db260) will increase coverage by 0.49%. The diff coverage is 93.72%.

@@            Coverage Diff             @@
##           master     #293      +/-   ##
==========================================
+ Coverage   81.02%   81.52%   +0.49%     
==========================================
  Files          23       23              
  Lines        3342     3480     +138     
==========================================
+ Hits         2708     2837     +129     
- Misses        634      643       +9     
Impacted Files Coverage Δ
src/adapter/file_adapter.rs 61.45% <0.00%> (+0.63%) :arrow_up:
src/rbac/default_role_manager.rs 96.29% <95.23%> (-1.83%) :arrow_down:
src/rbac_api.rs 89.37% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 41db260...c111b47. Read the comment docs.

PsiACE commented 2 years ago

Great, thank you very much for your contribution! I will check it tomorrow, can you let ci pass first?

kbalt commented 2 years ago

@PsiACE Any updates on this?

PsiACE commented 2 years ago

@PsiACE Any updates on this?

I apologise for some changes in my role that caused me to forget to give feedback earlier.

The PR looks great and I will be approving it. But before we merge, I'd like @hackerchai to help review it again.

greenhandatsjtu commented 2 years ago

LGTM