Django 应用程序的 Google Apps OpenID 登录

发布于 2024-12-19 04:00:12 字数 575 浏览 0 评论 0原文

我有一个为组织构建的 Django 应用程序。但是,所有用户都在组织的 Google 应用程序中拥有帐户。我们一直为他们保留两个独立的用户帐户(Google 应用程序和 django 应用程序),这不是很整洁。他们的 django 用户名与其 google apps 用户名相同(@domain.com 之前的部分)。

我想简单地更改 django 应用程序的登录页面,以便重定向到 google 应用程序进行身份验证(即 openid 类型登录)。此外,当他们登录时,我希望它返回具有相同用户名的用户,这样现有用户就可以登录到他们的原始帐户(因为他们在这些帐户下保存了内容)。新用户只会拥有一个使用该用户名创建的新 django 帐户。

不确定是否有人熟悉 googleappsauth。它是一个 Django 模块,允许 openid 登录 google apps 域。这对我来说似乎很完美。但是,它告诉我我需要定义一个 openid 端点。文档似乎没有表明这是必需的,但我对 OpenID 不太熟悉,所以我有点卡住了?

I have a django application built for an organization. But, all the users have accounts in the organization's google apps. We have been keeping two separate user accounts for them (google apps and the django app), which is not very neat. Their django username is the same as their google apps username (the part before @domain.com).

I want to simply change the login page of my django app so that redirects to google apps for authentication (ie, openid type login). Additionally, when they are logged in I would like it to return the User with the same username, so that way existing users are logged into their original accounts (since they have stuff saved under those accounts). And new users will just have a new django account created with that username.

Not sure if anyone is familiar with googleappsauth. Its a django module to allow openid login to a google apps domain. This seems perfect for me. But, its telling me I need an openid endpoint defined. The documentation does not seem to indicate that that is required, but I'm not very familiar with OpenID so I'm kind of stuck??

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

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

发布评论

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

评论(2

樱娆 2024-12-26 04:00:12

GOOGLE_OPENID_ENDPOINT = 'https://www.google.com/accounts/o8/ud'

GOOGLE_OPENID_ENDPOINT = 'https://www.google.com/accounts/o8/ud'

余厌 2024-12-26 04:00:12

要获取 Google OpenID 端点,请通过向 https://www.google.com/accounts/o8/id 发送 GET 或 HEAD HTTP 请求来执行发现。 使用 GET 时,我们建议将 Accept 标头设置为 application/xrds+xml。 Google 返回包含 OpenID 提供商端点 URL 的 XRDS 文档。端点地址注释为:

<Service priority="0">
<Type>http://specs.openid.net/auth/2.0/server</Type>
<URI>{Google's login endpoint URI}</URI>
</Service>

from: code.google.com

您还可以使用:

https://google.com/accounts/o8/site-xrds?hd=<domain>

但是,请注意,如果您使用 python-openid,这会导致一些问题。补丁可用

To get the Google OpenID endpoint, perform discovery by sending either a GET or HEAD HTTP request to https://www.google.com/accounts/o8/id. When using a GET, we recommend setting the Accept header to application/xrds+xml. Google returns an XRDS document containing an OpenID provider endpoint URL.The endpoint address is annotated as:

<Service priority="0">
<Type>http://specs.openid.net/auth/2.0/server</Type>
<URI>{Google's login endpoint URI}</URI>
</Service>

from: code.google.com

You can also use:

https://google.com/accounts/o8/site-xrds?hd=<domain>

However, be aware that this causes some problems if you use python-openid. Patches are available.

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