2012-03-14 47 views
0

我的所有用户都存储在我的drupal 7用户表中。Drupal 7单点登录(w/Moodle,wiki等)

我也有一些外部网站,如维基和Moodle的。

我使用单个符号上有Drupal-6和Moodle的。 Moodle支持其他系统的用户。

密码是不一样的,当我散列Moodle的密码与Drupal 7的功能user_hash_password。每次都有一个新的散列。

有什么别的东西我需要在Drupal 7的用户表中的密码怎么办?

回答

0

用菜单钩子创建一个Drupal 7模块。菜单钩子应该接受用户名和密码作为$ _POST变量,然后遵循user_login()的认证轨道。

所以基本上你最终用:

function my_module_authentication_menu_hook() { 
    // Note anywhere below that I put return FALSE you should return a failed auth response. 
    // Where there is a return TRUE you should return a successful auth response. 
    // The formatting of the auth response is up to you with how your Moodle call will react. 
    if (!isset($_POST['username']) || !isset($_POST['password'])) { 
    return FALSE; 
    } 

    $username = $_POST['username']; 
    $password = $_POST['password']; 

    // Functionality from user_login_name_validate(). 
    if (user_is_blocked($username)) { 
    return FALSE; 
    } 

    // Functionality from user_login_authenticate_validate(). 
    // You should add flood handling in here as well, but it can not be IP based, unless you 
    // supply the IP of the user through your Moodle functionality. 
    if (user_authenticate($username, $password) === FALSE) { 
    return FALSE; 
    } 

    // See user_login_final_validate() and implement failed login functionality before success. 
    return TRUE; 
} 

另一种选择,我不能在好良心建议,就是如果你不通过Drupal的希望的路线和希望直接查询数据库。你将不得不伴随着它的重现user_check_password(的代码)相关代码_password_crypt(),_password_get_count_log2(),_password_base64_encode()等,你还需要复制的功能,以确定用户是否堵塞或未经验证。您还需要验证是否允许用户使用user_login_default_validators()功能的复制进行登录。然后,如果任何代码在Drupal核心中更新,则需要再次更新。出于维护原因,我确实建议通过Drupal进行路由。

+0

作为一个说明,这将完成共享登录,这是不一样的单一登录。您的帖子标有单点登录,但您的问题与共享登录有关。 如果你想完成一个真正的单一登录,还有很多需要的东西,比如共享cookie,配置会话超时以及一些非常特定于你的环境的并发症。 – 2012-03-14 19:50:25

0

你可能会考虑使用一个模块,如CAS模块驱动密码输入到一个单一的网站。 Moodle和一些维基支持这个IIRC。使用您的正常策略来获得产品之间同步的其他字段。