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

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

    I've done it both ways. But I don't use bit masks much anymore. A separate table would be fine that you can use as a cross reference, given a user id or a group id as a foreign key.

    UserID | Permission
    ===================
    1      | 1              1 representing manage users
    1      | 2              2 being manger products
    2      | 3 
    

    This way would be easier to maintain and add on to later on.

    I'd also use a separate table to manage what the permissions are.

    PermissionID | Description
    ==========================
    1            | Manage Users
    2            | Manager Products
    

提交回复
热议问题