What is the best way to manage permissions for a web application - bitmask or database table?

前端 未结 9 774
感动是毒
感动是毒 2020-12-22 19:06

I\'m considering the best way to design a permissions system for an \"admin\" web application. The application is likely to have many users, each of whom could be assigned a

9条回答
  •  不思量自难忘°
    2020-12-22 19:43

    I've seen a number of somewhat limited permissions systems similar to what you're suggesting -- as well as some truly terrible systems. In some simple situations they can be acceptable, as long as the application doesn't get more complex. However, in so many cases, they do get more complicated, and the systems have to be rewritten to accommodate the required functionality.

    If you think you might someday need the expressiveness, I'd go with a full ACL (access control list) system with users and groups (or roles). That is, each thing governed by permissions (e.g. "manage users", "manage products") has an ACL, which is a list of all users and groups that have access to it. Then users are either added directly to the relevant ACLs, or added to a group that's already a member of an ACL.

    Although ACL suggests a list implementation, you'd be better off with a table; this answer is a good way.

提交回复
热议问题