Permission Management Algorithm

Posted by Emerald214 on Programmers See other posts from Programmers or by Emerald214
Published on 2013-11-05T04:53:29Z Indexed on 2013/11/05 10:11 UTC
Read the original article Hit count: 282

Filed under:
|

I have 3 levels of permission to see the product:

  • Brand -> Allow/Deny

  • Category -> Allow/Deny

  • Product -> Allow/Deny

For example, product A has:

  • Category: Allow
  • Product: Deny

=> product A cannot be seen because product A isn't allowed in Product level.

if(allowForCategory == true) {
    if(allowForProduct == false) return false;
    if(allowForProduct == true) return true;
} else {
    ...
}

This is not a good choice because it will become more complex if we add brand level.

if() {
    if() {
        if() {}
    }
}

So is there any general algorithm to deal with the permission problem just like 777 solution in Linux?

© Programmers or respective owner

Related posts about algorithms

Related posts about permissions