2012-03-14 158 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。使用您的正常策略來獲得產品之間同步的其他字段。