首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >flask peewee REST api身份验证以限制GET

flask peewee REST api身份验证以限制GET
EN

Stack Overflow用户
提问于 2012-06-04 08:04:59
回答 1查看 1.1K关注 0票数 2

我正在使用flask-peewee构建一个新项目。另外,我使用的是flask peewee中包含的REST接口。我遵循了这里的示例http://flask-peewee.readthedocs.org/en/latest/getting-started.html#exposing-content-using-a-rest-apihttp://flask-peewee.readthedocs.org/en/latest/rest-api.html#rest-api,所以我能够启动并运行Rest api,包括向rest添加Auth。

然而,我的问题是我不能保证GET请求的安全。到目前为止,我已经浏览了rest.py https://github.com/coleifer/flask-peewee/blob/master/flask_peewee/rest.py的源代码,但无法找到这是从哪里来的,尽管我确实找到了许多好东西,可以在以后使用。

默认情况下,REST API似乎只保护POST/PUT/DELETE,而不是GET。

我不想让使用flask url变得安全,我希望flask peewee有一些内置的方法。或者,如果这是一个已知的限制,那么处理这个问题的好方法是什么?

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-05 21:13:44

很抱歉,您在查找此信息时遇到问题。您可以指定在实例化auth类时需要进行身份验证的HTTP谓词列表:

代码语言:javascript
复制
# when instantiating your authentication
api_auth = UserAuth(auth, protected_methods=['GET', 'POST', 'PUT', 'DELETE'])
read_only_auth = UserAuth(auth) # default protected methods are POST/PUT/DELETE

以下是这些文档的链接:

http://flask-peewee.readthedocs.org/en/latest/api.html#authenticating-requests-to-the-api

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10874973

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档