上下文中的用户和角色

发布于 2024-07-24 00:41:09 字数 819 浏览 3 评论 0原文

我试图了解如何为我正在编写的应用程序实现用户/角色关系。 持久层是 Google App Engine 的数据存储,它对可以执行的操作设置了一些有趣的(但通常是有益的)限制。 任何想法表示赞赏。

让事情变得非常具体可能会有所帮助。 我希望有组织、用户、测试内容和测试管理(已进行的测试的记录)。 用户可以具有参与者(考生)、测试材料贡献者或两者的角色。 用户也可以是零个或多个组织的成员。 作为参与者,用户可以查看他或她之前参加的测试。 如果另一个参与者已向用户授权,则该用户还可以查看该参与者的测试管理。 用户可以查看已公开的测试材料,并且在该用户已获得组织授权的测试的特定管理期间,他或她可以作为参与者查看受限内容。 作为组织的成员,用户可以以贡献者的角色查看受限内容,并且他或她可能也可能无法编辑该内容。 每个组织都应该有一个或多个管理员,可以确定成员是否可以查看和编辑内容并确定谁拥有管理员权限。 还应该有一个或多个应用程序范围的超级用户可以排除故障并解决问题。 组织成员可以看到相关参与者授权他们查看的测试管理,如果没有授权,他们可以看到匿名数据。 在任何其他情况下,用户都无法看到其他用户的测试结果。

由于 App Engine 数据存储区中没有联接,因此可能需要对典型 SQL 数据库进行比平常更少的规范化,以确保检查权限的查询速度很快(例如,确定是否要链接的查询)。显示)。

我的问题是:

  1. 我该如何继续推进? 我应该预先花费大量时间来获得正确的模型,还是可以迭代多次并逐渐增加额外的复杂性?
  2. 在这种情况下,有人对如何分解事物有一些一般性的想法吗?
  3. 是否有任何 GAE 库能够以与这种安排兼容的方式处理角色?

I'm trying to get a sense of how to implement the user/role relationships for an application I'm writing. The persistence layer is Google App Engine's datastore, which places some interesting (but generally beneficial) constraints on what can be done. Any thoughts are appreciated.

It might be helpful to keep things very concrete. I would like there to be organizations, users, test content and test administrations (records of tests that have been taken). A user can have the role of participant (test-taker), contributor of test material or both. A user can also be a member of zero or more organizations. In the role of participant, the user can see the previous administrations of tests he or she has taken. The user can also see a test administration of another participant if that participant has given the user authorization. The user can see test material that has been made public, and he or she can see restricted content as a participant during a specific administration of a test for which that user has been authorized by an organization. As a member of an organization, the user can see restricted content in the role of contributor, and he or she might or might not also be able to edit the content. Each organization should have one or more administrators that can determine whether a member can see and edit content and determine who has admin privileges. There should also be one or more application-wide superusers that can troubleshoot and solve problems. Members of organizations can see the administrations of tests that the participants concerned have authorized them to see, and they can see anonymous data if no authorization has been given. A user cannot see the test results of another user in any other circumstances.

Since there are no joins in the App Engine datastore, it might be necessary to have things less normalized than usual for the typical SQL database in order to ensure that queries that check permissions are fast (e.g., ones that determine whether a link is to be displayed).

My questions are:

  1. How do I move forward on this? Should I spend a lot of time up front in order to get the model right, or can I iterate several times and gradually roll in additional complexity?
  2. Does anyone have some general ideas about how to break things up in this instance?
  3. Are there any GAE libraries that handle roles in a way that is compatible with this arrangement?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

睡美人的小仙女 2024-07-31 00:41:09

我不太确定我是否正确理解你的问题,但我会尽力回答:

  1. 我总是发现迭代编程更容易测试和编写,所以这是我的建议。
  2. 我认为您已经正确划分了必要的实体,但我认为您需要一个额外的实体:Permission,它定义每个角色可以做什么,每个角色有零个或多个Permission > 链接。 请记住,对于 GAE 中的每个多对多关系,您需要定义一个键列表,或者一个单独的实体作为中介。
  3. 据我所知,情况并非如此,但您可能想研究基于 Django 的角色系统并尝试采用基于 Django 的解决方案(因为 Django 已经存在了更长时间)。 您可以使用 App Engine 补丁 很好地将 Django 破解到 GAE 上。

I'm not quite sure I'm understanding your questions correctly, but I'll try my best to answer:

  1. I always find iterative programming easier to test and write, so that's my recommendation.
  2. I think you have the necessary entities already divided correctly, but I think you need an additional entity: Permission, that defines what each role can do, each Role having zero or more Permission links. Just remember that for each many-to-many relationship in GAE you need to either define a list of keys, or a separate entity to be the intermediary.
  3. Not that I know of, but you may want to investigate Django-based role systems and try to adapt a Django-based solution (since Django's been around longer). You can hack Django onto GAE rather nicely with App Engine Patch.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文