在Django项目中验证用户

编程入门 行业动态 更新时间:2024-10-07 23:20:53
在Django项目中验证用户 - 从哪里开始?(Authenticate users across Django projects - where to begin?)

我正在为同一个客户端构建几个基于Django的Web应用程序。 我想要做的是设置一个身份验证服务器,以便可以在django项目之间共享用户凭据,例如Jan Doe为App-A创建帐户,并且可以使用相同的un和pw登录到App-B。

Django软件包只是有点帮助,因为我无法从软件包描述中看出软件包是否可以帮助我做我想做的事情。

我在这方面非常缺乏经验,所以我甚至不知道我的问题是否合适,但是这里有:

我应该看看django套餐吗? 寻找基于python的auth服务器会更合适吗? 我应该从哪里开始解决这个问题?

I'm in the process of building several Django based web applications for the same client. What I would like to do is set up an authentication server so that user credentials can be shared among django projects e.g. Jan Doe creates account for App-A and can use the same un and pw to log in to App-B.

Django packages is only somewhat helpful as I can't tell from the package descriptions if the package will help me do what I want to do or not.

I'm very inexperienced in this area so I don't even know if my questions are appropriate, but here goes:

Should I even be looking at django packages? Would looking for a python based auth server be more appropriate? Where should I start to solve this problem?

最满意答案

不,您不需要单独的包裹。 只需使用Django的内置多数据库处理。 查看: https : //docs.djangoproject.com/en/dev/topics/db/multi-db/ 。

实质上,您将一个数据库指定为将存储用户数据的数据库,并确保将数据库添加到其他每个项目中。 然后设置一个路由器,检查app_label=='auth'并路由到那些实例的“user”数据库。 文档中有一个例子。

No, you don't need a separate package. Just use Django's built-in multi-database handling. Check out: https://docs.djangoproject.com/en/dev/topics/db/multi-db/.

Essentially, you designate one of your databases as the one that's going to store the user data and make sure that database is added to each of your other projects. Then set up a router that checks for app_label=='auth' and route to the "user" database for those instances. There's an example in the docs.

更多推荐

本文发布于:2023-08-07 16:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465271.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   用户   Django

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!