多个Django站点上的单点登录

2024-10-02 22:33:49 发布

您现在位置:Python中文网/ 问答频道 /正文


我在一个django开发中使用3个站点siteA、siteB、siteC),每个站点都有自己的域和数据库。由于不同的数据库,我对每个网站都有不同的用户。

我的问题是:是否有可能为这3个站点创建一个单一登录?? 如果用户注册在siteAsiteB但不在siteC中,在这种情况下,如果用户登录到站点a将自动登录到站点b(因为它同时在这两个站点中注册),而不是在站点C。(就像stackexchange.com网站)

如有任何建议和帮助,我们将不胜感激!
谢谢您!在


Tags: django用户com数据库站点网站情况建议
1条回答
网友
1楼 · 发布于 2024-10-02 22:33:49

最终的解决方案是:OAuth

但是,如果您喜欢捷径,同时将OAuth集成到所有这些Django站点中,您可以:

Site A: Ken, John

Site B: Ken, Joh

Site C: John

我们有两个网站,主要网站使用一些资源从网站B,但它必须是一个用户在网站B。但这两个网站不同步用户。因为OAuth是一个痛苦的整合,我们正在这样做:

1. Ken login through Site A.
2. As soon as he hits "login", he's redirected to login to Site B and C through iframe login (submit the auth login requests through HTTPS).

3. The iframe login will return cookies of the site trying to login
     - site B
     - site C
4. Since Ken is not a user of Site C, there is no cookies return from Site C.
5. After two iframe logins, you are back to Site A and at this moment, as authenticated user of Site A, ken has at most two cookies:
    - site A
    - site B

这是一条捷径,但非常不安全。当我说iframe登录时,我并不是说您将看到一个带有登录表单的iframe。请求通过请求发出。在

这是不安全的,因为用户必须使用相同的加密密码:/并且传递cookies很容易受到攻击。在

相关问题 更多 >