向用户公开 django admin。有害?

发布于 2024-11-09 07:30:39 字数 393 浏览 0 评论 0原文

我正在开发一个有点像 Django 的电子商务项目,简单来说,我有一个客户模型和一个商家模型。 Merchant 模型与 MerchantStore 模型相关联,该模型在某种程度上“复杂”,与各种模型具有大量的 M2M 和外键关系。

按照此帖子中的解决方案进行操作,但没有足够的“时间”为了进行自定义实现,我决定让每个商家成为“stuff member”,并通过管理界面自定义他的商店。当然,我创建了一个具有适当权限的新组。

然而,出现了一些问题:

1)这被认为有害吗?是否存在任何相关的安全威胁?

2)如果你没有足够的时间,这不是最好的方法吗?

I am working on a Django somewhat e-commerce project, where, briefly, I have both a Customer and a Merchant model. The Merchant model is associated with a MerchantStore model which is somehow "complicated", having a plethora of m2m and foreign key relationships to various models.

Following the solution in this post and having not enough "time" to make a custom implementation, I decided to let each Merchant be a "stuff member" and customize his store through the admin interface. Of cource I created a new group with the appropriate permissions.

However, some questions arise:

1) Is this considered harmful? Are there any security threats associated?

2) Isn't this the best way to do it if you have not enough time anyway?

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

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

发布评论

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

评论(2

久而酒知 2024-11-16 07:30:39

不,我不认为这有害。

Apress 的 djangobook 中描述的“管理之禅”似乎暗示了将信任假设作为管理员“哲学”的一部分,并与经常重复的“管理不是你的应用程序”建议相结合,一开始我也很害怕,认为 Django 文档可以指出预期的、可行的用例。

请参阅我几乎相同的问题面向最终用户的Django AdminSite/ModelAdmin?

来自乔丹的回答(我给了他赏金):

没有什么本质上特别的
关于管理员。它的行为就像任何
其他观点。所以如果它正在使用
确定访问的权限(对于
例如,如果您设置用户的 .is_staff
True 但只允许他们访问
特定权限)那么它将是
对您可能的任何视图同样安全
创建使用权限
确定访问权限。

...

写的人
django.contrib.admin 没有写
假设任何人
is_staff = True 可以被信任为
就像超级用户一样,或者很愚蠢
足以永远不看一眼
网页的源代码。虽然
鼓励写下自己的观点,
它仍然是一个强大的界面。

另请注意 Django 相对最新的安全更新 http://www.djangoproject.com/weblog /2010/dec/22/安全/
关于对象列表中的查询字符串参数。

这样的更新(引用:“有权访问管理员的攻击者[...]”)清楚地表明管理员对权限系统的实施正在受到不断的审查。

No, I would not consider this harmful.

The "Zen of Admin" as described in Apress's djangobook seemed to imply an assumption of trust as part of the admin's "philosophy", and paired with the often-repeated "admin is not your app" advice, I too was scared at first and think the Django documentation could point out intended, viable use cases.

Please see my almost identical question Django AdminSite/ModelAdmin for end users?

From Jordan's answer (who I gave the bounty):

There is nothing inherently special
about admin. It behaves just like any
other view. So if it is using
permissions to determine access (for
example, if you set a user's .is_staff
to True but give them access only to
specific permissions) then it will be
equally secure to any view you might
create that uses permissions to
determine access.

...

The people who wrote
django.contrib.admin did not write it
with the assumption that anyone with
an is_staff = True could be trusted as
much as a superuser, or was stupid
enough to never take a look at the
source code of a web page. Although
writing your own views is encouraged,
it is still a robust interface.

Also note Django's relatively recent security update http://www.djangoproject.com/weblog/2010/dec/22/security/
regarding querystring parameters in object lists.

Such an update (quote: "an attacker with access to the admin [...]") is a clear indication that the admin's implementation of the permission system is being constantly scrutinized.

坠似风落 2024-11-16 07:30:39

是的,这被认为是“有害的”,主要是由于 Django 开发人员的设计考虑。管理围绕“受信任的用户”的概念。换句话说,如果某人是工作人员(从而可以访问管理员),他们可能有足够的信任,不必担心安全漏洞。事实上,你可以阻止它们进入不应该干扰的部分(就像你所做的那样),但重点是 Django 在这方面不做任何保证。实际上,您可能不会遇到任何问题,但您可以

讽刺的是,我认为我一生中花在自定义 Django 管理上的时间比我从头开始构建它所花费的时间还要多。有趣的是,事情是这样进行的。无论如何,我将其比作在 Ruby on Rails 中使用脚手架。这是让某些东西上线的快速方法,但目标是尽快替换它。

Yes, this is considered "harmful", mostly due to the design considerations of the Django developers. The admin revolves around a concept of "trusted users". In other words, if someone is a staff member (thereby having access to the admin), they presumably have enough of your trust to not be worried about security breaches. Now in truth, you could block them from portions they're not supposed to mess with (as you've done), but the point is that Django makes no guarantees in this area. You probably won't have any problems, in all actuality, but you could.

Ironically, I think I've spent more time in my life customizing the Django admin than it would have taken me to build it from scratch. Funny how that goes. Regardless, I'd liken it to using scaffolding in Ruby on Rails. It's a quick way to get something live, but the goal is to replace it as soon as possible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文