如何在不询问用户 OpenID URL 的情况下使用 OpenID?

发布于 2024-12-27 20:33:21 字数 296 浏览 3 评论 0原文

我正在使用 DotNetOpenAuth 设置 OpenID 提供程序,但我陷入了困境。

看起来 OpenID 要求用户首先提供他的 OpenID URL,然后消费者将他重定向到提供者,并将 URL 作为参数(checkid_setup 模式)。

但对于谷歌和其他一些提供商来说,它的工作方式有所不同。您只会被重定向到一个通用页面,您可以在其中登录或选择您已登录的帐户之一。或者,如果您使用单个帐户登录,则只需重定向回来。

这是否与 checkid_immediate 模式有关?如果是这样,请给我一个解释其工作原理的文章的链接。

I'm setting up an OpenID provider using DotNetOpenAuth and I'm stuck.

It seems that OpenID requires that the user provides his OpenID URL first, and then the consumer would redirect him to the provider, giving the URL as a parameter (checkid_setup mode).

But with google, and some other providers, it works differently. You are just redirected to a generic page where you would either sign in, or select one of the accounts you're already logged in with. Or just redirected back if you're logged in with a single account.

Is this somehow related to the checkid_immediate mode? If so, please give me a link to an article explaining how that works.

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

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

发布评论

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

评论(1

情话已封尘 2025-01-03 20:33:21

您看到的行为差异与您注意到的 checkid_setup 与 checkid_immediate 模式正交。

如果用户输入自己的 OpenID,则称为“声明标识符”。如果用户只是点击(或输入)他的提供商(例如您示例中的 Google),则称为OP 标识符

例如,如果您在 OpenID 框中输入 https://www.google.com/accounts/o8/id,您将看到您所描述的行为,Google 将协助您登录您网站的用户,无论该用户是谁。

因此,此时您有几个选择:

  1. 如果您的站点基于 ASP.NET Web 表单,则可以使用 OpenIdButton 控件,输入 https://www .google.com/accounts/o8/id 标识符添加到相应的属性中,然后用户可以单击该按钮以使用其 Google 帐户轻松登录。

  2. 如果您使用 MVC(或使用网络表单,但希望以编程方式执行此操作),您可以调用 OpenIdRelyingParty.CreateRequest("https://www.google.com/accounts/o8/id")< /code> 并将用户与结果重定向到 Google。

无论哪种方式,如果用户已经登录 Google,他们就不需要登录 Google。如果用户已经告诉 Google 他们批准登录您的网站,那么他们在此登录过程中根本不会看到 Google。

The difference in behavior you're seeing is orthogonal to the checkid_setup vs. checkid_immediate modes that you're noticing.

If the user types in his own OpenID, that's called a Claimed Identifier. If instead the user just clicks (or types) his provider (e.g. Google in your example), that's called an OP Identifier.

For instance, if you type in https://www.google.com/accounts/o8/id into the OpenID box, you'll see the behavior you're describing, in that Google will assist the user in logging into your web site, whoever that user is.

So at this point you have a few options:

  1. If your site is based on ASP.NET web forms, you can use the OpenIdButton control, typing in the https://www.google.com/accounts/o8/id identifier into the appropriate property, and the user can then click that button to simply log in using their Google account.

  2. If you're using MVC (or using web forms but want to do this programmatically) you can call OpenIdRelyingParty.CreateRequest("https://www.google.com/accounts/o8/id") and redirect the user with the result to Google.

Either way, if the user is already logged into Google, they won't need to log into Google. And if the user has already told Google that they approve logging into your web site, then they won't see Google at all during this login process.

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