Managing user privileges, best practice.

Posted by Loïc N. on Pro Webmasters See other posts from Pro Webmasters or by Loïc N.
Published on 2013-06-28T10:27:36Z Indexed on 2013/06/28 10:29 UTC
Read the original article Hit count: 461

I'm am new to web development. I'm creating a website where different user can have different privileges, such as creating/editing/deleting a news, or adding/editing/deleting whatever kind of content on the website.

I started by creating a "user type" that would indicate the user's privileges (such as "user", "newser", "moderator", "admin", and so on), but i quickly started noticing issues that made me think that this might be a naive approach to this issue.

What if i want to give a regular user the right to edit a news (for whatever reason)? Then the user would be half "user", half "newser". But the system i use can only handle one user-type.

So what would be the best practice here?

I was thinking of removing the concept of roles (or "user-types" such as newser) and only have the concept of "privilege", where every user could have zero to many privileges. So, to re-use the above example, if i wanted a user to have the right to edit some news, i would only have to give him a "edit news" privilege.

Is this the way to go?

© Pro Webmasters or respective owner

Related posts about web-development

Related posts about best-practices