Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

multiple policies, effects, matchers support #122

Open
0x8f701 opened this issue Apr 19, 2020 · 4 comments
Open

multiple policies, effects, matchers support #122

0x8f701 opened this issue Apr 19, 2020 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@0x8f701
Copy link
Member

0x8f701 commented Apr 19, 2020

No description provided.

@0x8f701 0x8f701 changed the title multiple matches support multiple matchers support Apr 19, 2020
@hsluoyz
Copy link
Member

hsluoyz commented Apr 19, 2020

How to enforce for multiple matchers?

@0x8f701
Copy link
Member Author

0x8f701 commented Apr 19, 2020

@hsluoyz My idea is to use regexp to extrat pn from matcher.

regexp

// compile only once
 static ref EXR_P: Regex = Regex::new(r"\b(?P<ptype>p\d*)_").unwrap();

extract function

pub fn extract_ptype_from_matcher(m: &str) -> Option<String> {
    let mut ptype: Option<String> = None;

    for caps in EXR_P.captures_iter(m) {
        if ptype.is_none() {
            ptype = Some(caps["ptype"].to_string());
            continue;
        } else if Some(&caps["ptype"]) == ptype.as_deref() {
            continue;
        } else {
            panic!("one matcher can only contain one type of policy. eg. p, p2, p3...");
        }
    }

    return ptype;
}

@0x8f701
Copy link
Member Author

0x8f701 commented Apr 19, 2020

once ptype is extracted, we can then know which policy to use (p1, p2, p3, p...n), then we will be able to calculate the value for m1, m2, m3`...

The key thing here is to use something like IndexMap instead of HashMap which will keep order, otherwise maybe it'll first calculate the value of m2 but m2 relies on m, m1...

@0x8f701
Copy link
Member Author

0x8f701 commented Apr 19, 2020

A first version will be in #123

@0x8f701 0x8f701 added this to the v1.0.0 milestone May 9, 2020
@0x8f701 0x8f701 added the enhancement New feature or request label May 9, 2020
@0x8f701 0x8f701 changed the title multiple matchers support multiple matchers support, re-design casbin model conf format May 10, 2020
@0x8f701 0x8f701 changed the title multiple matchers support, re-design casbin model conf format multiple policies, effects, matchers support May 10, 2020
@0x8f701 0x8f701 modified the milestones: v1.0.0, v2.0.0 Jun 1, 2020
@0x8f701 0x8f701 modified the milestones: v2.0.0, v1.0.0 Jul 19, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants