如何在博客系统中实现权限?
我正在推出自己的博客系统,我想知道如何确定权限并在博客系统中实现它们?
评论者、博主和管理员应该有什么权限?
实施它们的最佳方法是什么?
I am rolling my own blogging system and I am wondering how to determine permissions and implement them in a blogging system?
What should be the permissions for a commenter, a blogger and an admin?
What is the best way to implement them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您没有提到您正在使用什么语言/框架。 Django 包含一组非常有用且完整的权限,您可以使用它们来启动和运行。我假设还有许多其他网络框架可以做同样的事情。
因此,我的建议是找到一个你喜欢并且认为有趣的 Web 框架(这听起来像是一个个人项目)来为你处理这些事情。
You didn't mention what language/framework you're using. Django includes a very useful and complete set of permissions that you can get up and running with. I'd assume that there are a number of other web frameworks that do the same.
Therefore, my advice is to find a web framework that you like and think is fun (this sounds like a personal project after all) that will handle these kinds of things for you.
我会使用解耦身份验证组件的组合,您可以询问当前用户是否具有角色 X,如果是,则允许他们执行该操作。这样您就可以将组和过期时间等细节留给身份验证组件。
您可以将其与博客引擎的一些专门身份验证结合起来,例如。在博客对象中有一个发帖者列表,并始终允许这些人发帖。
I'd go with a combination of a decoupled authentication component, that you can ask if the current user has the role X, and if so allow them to do the thing. That way you can leave the specifics of groups and expiry etcetera to the authentication component.
You could combine this with some specialized authentication for your blogging engine, eg. having a list of posters in the blog object, and always allowing those persons to make posts.
为每个用户提供一个“权限”值并将其存储在数据库的用户表中。
例如:
使用服务器端会话和 cookie 的组合用于登录。
对于“高级”用户权限,请使用位掩码并创建组。
位掩码:例如,使用以前的值,用户级别 3 (2+1) 将同时具有编写者和主持人权限。
Give each user a "privilege" value and store it in the users table in the database.
for example:
Use a combination of serverside sessions and cookies for logins.
For "advanced" user privileges, use bitmasks and create groups.
Bitmasking: for example, using previous values, user level 3 (2+1) would have both writer and moderator privileges.