带有 Google 身份验证的 Appengine ACL
我想使用 Google 身份验证来实施 ACL。需要一些关于相同可能性的指示。
使用案例:
页面 X 只能由[电子邮件受保护]<访问/p>
属于 Y 组的所有人都可以访问 Y 页。注册后,主持人会将用户添加/拒绝到 Y 组。
如果用户不属于上述两者之一,则无法访问页面。即使用户认证成功,也禁止未经授权的查看。
我计划在我的项目中使用 Django,Django 提供的任何支持都会很有用。
提前致谢。
I would like to implement ACL with Google Authentication. Need some pointer regarding the possibility of the same.
Use case:
Page X accessible only to [email protected]
Page Y accessible for all belong to a group Y. After registration a moderator will add/reject the user to the group Y.
Pages are not accessible if user does not belong to any one of the above two. Unauthorized view is prohibited even though the user is authenticated successfully.
I am planning to use Django for my project, any support provided by Django would be useful.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要自己执行此操作:使用由用户的
user_id
键控的数据存储模型实现 ACL,并在每个请求时获取并检查它。 Users API 不提供类似这样的内置功能。You'll need to do this yourself: Implement the ACL with a datastore model keyed by the user's
user_id
, and fetch and check it on each request. The Users API doesn't provide anything like this built-in.以下仅是对管理部分的回答,以及有关如何执行问题其他部分的可能建议:
对于仅限管理员访问,我将以下几行放入
app.yaml
中:以上内容将限制 < code>admin 和
super-restricted-area
基本 URL 仅适用于网站管理员。您可以将多个网址限制为管理员。浏览 Python 应用程序配置文档后,我找不到配置级别的任何分组限制。对于以下内容,我假设您对 Django 非常熟悉,可以在视图中使用中间件和装饰器,否则可能需要花费很多篇幅来详细解释这两个主题。假设无法在配置级别完成分组限制,您可以尝试将授权代码放入 django 中间件(如果应用程序引擎支持,则应用程序引擎上的 django 受到限制)或装饰器中的视图。
在您的中间件或装饰器中,可以从以下内容开始:
这是 的参考上面。
Here's an answer to the admin part only and possible suggestions on how to do the other part of your question:
For admin only access, I put the following lines in
app.yaml
:The above will restrict the
admin
andsuper-restricted-area
base urls to the administrator of the site only. You can have multiple urls restricted to the admin. After glancing through Python Application Configuration doc, I couldn't find any grouping restriction at the configuration level.For the following, I will assume you are very comfortable with Django, using middleware and decorators in view, otherwise it might take pages to explain those two topics in details. Assuming grouping restrictions cannot be done at the configuration level, you can try putting the authorisaton code in a django middleware(if app engine supports it, django on app engine is limited) or in a decorator to your views.
In your middleware or decorator, here's something to start with:
Here's the reference for the above.