Flask-auth,负责人和Flask安全 [英] Flask-auth, Principal and Flask Security

查看:95
本文介绍了Flask-auth,负责人和Flask安全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能说出这3个扩展名之间是否有根本区别,还是他们都做类似的事情?我一直在阅读文档,并且似乎有很多交叉.我猜有些只是提供更多功能.

Can anyone tell if there's a fundamental difference between these 3 extensions or do they all do similar things? I've been reading the docs and there seems to be quite a lot of crossover. I'm guessing some just offer more features.

我想将用户角色添加到我的应用中,以便某些用户具有某些权限.也就是说,级别1的用户可以创建5个资源,级别2的用户可以创建10个资源,等等.我正在按照这个 http://flask.pocoo.org/snippets/98/此解决方案是否存在任何安全问题?我已经在使用Flask-login,因此可以将其与之集成.

I'm wanting to add user roles to my app so certain users have certain permissions. i.e. level1 user can create 5 resources, level2 user can create 10 etc. I've been looking at rolling my own, it doesn't seem too tricky. I'm looking at using a decorator along the lines of this http://flask.pocoo.org/snippets/98/ would there be any security issues with this solution? I'm already using Flask-login so I would integrate it with this.

推荐答案

Flask-Auth是一种用于身份验证和权限的单一解决方案,但是我没有看到它使用/引用过多.

Flask-Auth is a single solution to both authentication and permissions, but I haven't seen it used/referenced much.

Flask-Principal会做您想要的,但是这很简单.自己动手不会做更多的工作.

Flask-Principal will do what you want, but it's pretty bare-bones; rolling your own would not be much more work.

Flask-Security将Flask-Login,-Principal和其他一些扩展汇总为一个更连贯的整体,并将它们安装为依赖项.尽可能使用它提供的方法,而不要使用各个扩展中的方法.我没用过,但似乎要花很多时间.

Flask-Security rolls up Flask-Login, -Principal, and some other extensions into a more coherent whole, installing them as dependencies. Use the methods it provides rather than the ones from the individual extensions when possible. I haven't used it but it seems like it would take a lot of the manual labor out of this.

对于只需要添加用户角色的特定用例,我建议坚持使用Flask-Principal.它运作良好,可维护且具有足够的通用性,可以与您的任何需求集成.

For your specific use case of just needing to add user roles, I would recommend with sticking with Flask-Principal. It works well, is maintained, and is general enough to integrate with whatever requirements you have.

这篇关于Flask-auth,负责人和Flask安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆