ruby on rails - Access level / security roles design choice: individual roles or inheritance -
please consider scenario: web app has 4 levels of access: admin > manager > representative > customer > no role (public access pages)
with current app setup can allow access in 2 ways:
i can write code, assume role precedence, i.e. if user a manager - app automatically assume he/she has right access areas customer & representative can, not admin.
i can assign each role individually in table. instance user have 3 roles assigned them. app not assume role precedence / inheritance. can either let admin assign users roles, or right code automatically assign roles user if higher access level granted.
which of 2 approaches better standpoint of maintainability?
p.s.
i don't think matters i'm using rails 3 cancan & devise. setup relationship between roles , users following:
role <=> (habtm) <=> user
i have similar role requirement , i've chosen approach 1. it's natural assume higher role hierarchy go, more access have. so, saying manager has access resources representative has ok.
also, since you're using cancan, fall through set up. start role least access @ top of initialize block , work way down.
Comments
Post a Comment