rio*_*oki 4 python authentication google-app-engine
我正在编写一个使用GAE的小应用程序.我的应用程序部分仅供管理使用.我有两个login: admin选项在app.yaml或google.appengine.api.users.is_current_user_admin()python代码中使用选项.基本身份验证对我的情况就足够了.
哪种解决方案更好?
使用app.yaml的优点是python代码更清晰一点.此外,app.yaml可能会更高效,因为它可以在服务器中处理.(在最坏的情况下,它在性能方面是相同的.)唯一的缺点是我没有显示自定义页面,但我并不关心.
我不确定我的断言是否正确.
Dre*_*ars 13
我会说你的断言是正确的.假设您的app.yaml中包含以下内容:
- url: /admin/.*
script: admin.py
login: admin
Run Code Online (Sandbox Code Playgroud)
如果您希望将所有内容admin.py限制为管理员,则上述配置应该更具性能:您可以在未经授权的情况下使未经授权的请求失败admin.py.
Checking users.is_current_user_admin() is useful when you want to define more granular logic and behavior. Perhaps you have a handler that should be available whether the user is an admin, a non-admin, or not logged in, you just need to check their current state so you can return the appropriate HTML.
| 归档时间: |
|
| 查看次数: |
1606 次 |
| 最近记录: |