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

前端 未结 9 730
感动是毒
感动是毒 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:37

    You could use Active Directory or another LDAP implementation if you're in a managed environment. That way the security groups, which determine permissions can be managed by first line support, using a technology they're most likely already familiar with.

    If your app is shrink wrapped then +1 for Levi Rosol's suggestion of normalising the database so that you can have an extensible data model in your app.

    0 讨论(0)
  • 2020-12-22 19:41

    how about creating a Permission table, then a UserPermission table to store the relationships?

    You'll never have to modify the structure again, and you have the ability to add as many permissionss as you wish.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题