Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

multiple policies, effects, matchers support #122

Open
GopherJ opened this issue Apr 19, 2020 · 4 comments
Open

multiple policies, effects, matchers support #122

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

Comments

@GopherJ
Copy link
Member

GopherJ commented Apr 19, 2020

No description provided.

@GopherJ GopherJ 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?

@GopherJ
Copy link
Member Author

GopherJ 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;
}

@GopherJ
Copy link
Member Author

GopherJ 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...

@GopherJ
Copy link
Member Author

GopherJ commented Apr 19, 2020

A first version will be in #123

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

No branches or pull requests

2 participants