如何从 Drupal 对 Django 进行身份验证? [英] How to authenticate against Django from Drupal?

查看:22
本文介绍了如何从 Drupal 对 Django 进行身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个中等规模的 Drupal 6 站点正在运行(每月大约有 500 万次页面浏览和超过 3 万注册用户),我需要将 OSQA(一个 Django 应用程序)与它集成.我的 Drupal 数据库中已经有很多用户、角色和权限,我想让 Django 应用程序使用我在 Drupal 中已有的注册和登录页面,以便为我的用户提供一个入口.

I have a medium sized Drupal 6 site running (around 5 million page views per month and more than 30K registered users) and I need to integrate OSQA, a Django application, with it. I already have many users, roles and permissions in my Drupal database and I'd like to point the Django app to use the sign up and login pages I already have in Drupal to give my users a single point on entrance.

我想保留 Django 身份验证部分,因为我认为 OSQA 会更好地工作.我还考虑了性能方面的原因,Drupal 站点已经获得了大量流量并且数据库非常繁忙,我认为为 Django 使用单独的数据库会有所帮助.

I want to keep the Django authentication part because I think OSQA would work better. I also have performance reasons in mind, the Drupal site already gets a lot of traffic and has a very busy database and I think that using a separate database for Django would help.

经过一些研究,我想我可以让 Drupal 注册和登录页面在后台调用 Django 来注册或登录到 Django 应用程序.我计划在 Django 中编写几个视图,一个用于注册,另一个用于登录,Drupal 会将用户名和密码发布到这些视图中.当然,我需要在 Django 中为这些视图禁用 CSRF,并且可能还会发布一些只有我的 Drupal 和 Django 应用程序知道的密钥,以避免外部站点尝试使用这种不受保护"的 Django 视图.

After some research I think I could make the Drupal sign up and login pages call Django in the background to sign up or login to the Django app. I plan to do this writing a couple of views in Django, one for sign up and another for login, and Drupal would post the username and password to those views. Of course I'd need to disable CSRF in Django for those views and probably also post some secret key that only my Drupal and Django applications know about to avoid external sites trying to use this "unprotected" Django views.

我知道我的 Django 应用程序在某些时候可能需要来自 Drupal 的一些用户数据,我打算为此使用 Drupal 服务模块.

I know that my Django application may need some user data from Drupal at some points and I'm planning on using the Drupal services module for that.

这是一个好方法吗?有什么建议吗?

Would this be a good approach? Any suggestions?

非常感谢!

推荐答案

如果你可以发帖到 Django 表单,你或许可以使用 drupal_http_request 来处理对 Django 的调用.在使用 ldap_integration 模块一段时间后,我开发了一个自定义身份验证模块,该模块使用 drupal_http_request 调用基于 Java 的 REST 身份验证 API.如果您对代码感兴趣,请告诉我.

If you can post to the Django form, you may be able to use drupal_http_request to handle the call to Django. After using the ldap_integration module for a while, I worked on a custom authentication module that calls a Java-based REST authentication API using drupal_http_request. If you're interested in the code, let me know.

这篇关于如何从 Drupal 对 Django 进行身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆