Drupal 中外部身份验证后的透明用户注册

发布于 2024-09-07 03:46:13 字数 1191 浏览 0 评论 0原文

我正在开发 Drupal 6 模块来提供基于 OAuth 的用户身份验证和注册。我已经使用 OAuth 模块进行身份验证,如 http://oauth.net/core 上所述/1.0a/#anchor9。下一步是使用服务提供商的自定义 API 进行身份验证后提供的信息创建用户帐户。

根据 http://drupal.org/node/497612#comment-3047302,我不应该使用 user_external_login_register() 但请参阅OpenID 模块了解如何正确登录外部用户。

研究完 OpenID 模块后,我计划执行以下操作:

这是正确的方法吗?除了 OpenID 之外,还有其他模块值得研究如何正确执行此操作吗?

I'm working on a Drupal 6 module to provide OAuth-based user authentication and registration. I'm already using the OAuth module to authenticate as described on http://oauth.net/core/1.0a/#anchor9. The next step is to create the user account using information provided after authentication using an custom API of the Service Provider.

According to http://drupal.org/node/497612#comment-3047302, I should not use user_external_login_register() but see the OpenID module for how to properly login an external user.

After studying the OpenID module, here is what I plan to do:

  • Try to load an existing user for a authname build from the custom API result using user_external_load().
  • If a user exists, use user_external_login() to log the user in.
  • If not, pretend the registration form has been submitted (like openid_authentication() does) to create a new user account. And redirect to a pre-filled form if any additional information is needed in order for the user to register.

Is this the right way to do it ? Is there another module worth looking at for how to this properly in addition to OpenID ?

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

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

发布评论

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

评论(1

暮倦 2024-09-14 03:46:14

您可以查看以前的 Drupal 模块。该模块做了两件完全不同的事情(架构万岁:))。
* 它将信息发布到中央“谁运行 Drupal”目录。 (并提供了一个页面来自己显示这样的目录!)
* 它允许使用其他 Drupal 站点的凭据登录。

后者就是您正在寻找的。请注意,该模块已停止使用,并不是因为登录方法错误,而是因为 DrupalID 机制本身存在缺陷。它已被 openID 和 oauth 取代。

http://drupalcode.org/ viewvc/drupal/drupal/modules/drupal/drupal.module?hideattic=0&view=markup

您要查找的挂钩和方法(按顺序)是:

  • drupal_form_alter -- 将验证回调添加到登录表单s
  • drupal_form_user_login_alter -- 在登录表单上添加有关备用登录的信息。
  • drupal_distributed_validate -- 验证回调:调用 drupal_auth 来查看用户是否有效。如果是这样,则调用 user_external_login_register
  • drupal_auth -- Helper 进行验证回调:确定凭据是否有效。

所有其他功能要么是这些功能的辅助功能,要么提供该目录功能,要么允许远程站点根据我们的数据库进行身份验证。您将不会使用其中任何一个。

You could have a look at the former Drupal module. That module did two entirely different things (hooray for the architecture :)).
* It puplished information to a central "who runs Drupal" directory. (and offered a page to show such a directory yourself!)
* It allowed login with credentials from other Drupal-sites.

The latter is what you are looking for. Note that the module was discontinued, not because the method for logging in was done wrong, but because the DrupalID mechanism itself is flawed. It has been replaced with openID and oauth.

http://drupalcode.org/viewvc/drupal/drupal/modules/drupal/drupal.module?hideattic=0&view=markup

The hooks and methods you would be looking for (in that order) are:

  • drupal_form_alter -- Adds validate-callback to the login forms.
  • drupal_form_user_login_alter -- Adds information about alternative login on login form.
  • drupal_distributed_validate -- Validation callback: calls drupal_auth to see if the user is valid. If so, calls user_external_login_register
  • drupal_auth -- Helper for validation callback: determines if the credentials are valid.

All other functions are either helper functions for these, or provide that directory-feature, or allow remote sites to authenticate against our database. Neither of which you will be using.

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