How to handle massive storage of records in database for user authorization purposes?

后端 未结 7 1837
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 09:30

I am using Ruby on Rails 3.2.2 and MySQL. I would like to know if it is \"advisable\" / \"desirable\" to store in a database table related to a class all records related to

7条回答
  •  清歌不尽
    2021-01-05 10:08

    You don't have to re-invent the wheel. ACL(Access Control List) frameworks deals with same kind of problem for ages now, and most efficiently if you ask me. You have resources (Article) or even better resource groups (Article Category/Tag/Etc).On the other hand you have users (User) and User Groups. Then you would have a relatively small table which maps Resource Groups to User Groups. And you would have another relatively small table which holds exceptions to this general mapping. Alternatively you can have rule sets to satify for accessing an article.You can even have dynamic groups like : authors_friends depending on your user-user relation.

    Just take a look at any decent ACL framework and you would have an idea how to handle this kind of problem.

提交回复
热议问题