[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[upki-fed:00615] Re: moodle の shibboleth 化



土屋です.

>> On Fri, 08 Feb 2013 20:50:48 +0900
>> xxxxxxxx@xxxxxx (TSUCHIYA Masatoshi) said as follows:

>moodle-1.9.9 を shibboleth 化しようとしてはまっています.
>auth/shibboleth/README.txt の指示にしたがって,各種設定を行いました.そ
>の結果,以下のような挙動を示すようになっています.まず,

>    https://moodle.example.net/auth/shibboleth/login.php

>にアクセスし「選択」ボタンを押すと,

>    https://moodle.example.net/auth/shibboleth/index.php

>に遷移します.

>その後で,この sampleuser は設定が完了していないと判定 user_not_fully_set_up($USER)
>されて,ユーザ情報の表示画面に飛ばされるのですが,user/edit.php は「ログ
>インが完了していない」と判断して,

>    https://moodle.example.net/auth/shibboleth/login.php

>に更にリダイレクトするため,何回やってもログイン画面に戻ってきてしまっ
>て,ログインできないという状態になっています.

という件について自己解決したので,報告します.

原因は2つありました.

第1に,本学で使っている shibboleth sp 2.3.1 の環境では,Shib-Session-ID
ではなく,Shib_Session_ID という環境変数を参照する必要がありました.その
ため,auth/shib_session_id/auth.php で定義されている user_login 関数を以
下のように修正しました.
--- auth/shibboleth/auth.php.orig
+++ auth/shibboleth/auth.php
@@ -57,9 +57,9 @@
         if (!empty($_SERVER[$this->config->user_attribute])) {
             // Associate Shibboleth session with user for SLO preparation
             $sessionkey = '';
-            if (isset($_SERVER['Shib-Session-ID'])){
+            if (isset($_SERVER['Shib_Session_ID'])){
                 // This is only available for Shibboleth 2.x SPs
-                $sessionkey = $_SERVER['Shib-Session-ID'];
+                $sessionkey = $_SERVER['Shib_Session_ID'];
             } else {
                 // Try to find out using the user's cookie
                 foreach ($_COOKIE as $name => $value){
第2に,本学では従来は ldap を使っていて,shibboleth に移行しようとしてい
ます.ところが,moodle は認証に使った手段を覚えていて,たとえサイト全体の
設定で shibboleth を許可しても,ldap で認証したユーザは ldap のみで認証し
ます.そのため,ldap 認証を一度でも行ったことがあるユーザに対しては,
shibboleth での認証が働きません.

これは困るので,ldap と shibboleth は相互にどちらで認証しても良いように,
lib/moodlelib.php の authenticate_user_login 関数を以下のように修正しまし
た.
--- /usr/share/moodle/lib/moodlelib.php.orig
+++ /usr/share/moodle/lib/moodlelib.php
@@ -3186,7 +3186,11 @@
             error_log('[client '.getremoteaddr()."]  $CFG->wwwroot  Disabled Login:  $username  ".$_SERVER['HTTP_USER_AGENT']);
             return false;
         }
-        $auths = array($auth);
+       if ($auth=='ldap' or $auth=='shibboleth') {
+           $auths = array('shibboleth', 'ldap');
+       } else {
+           $auths = array($auth);
+       }
 
     } else {
         // check if there's a deleted record (cheaply)
ここまでの修正で,とりあえず shibboleth で認証はできるようになりました.

ところが,ここで新たな問題に気付いたのですが,学内の他のウェブサイトで
Shibboleth 認証してから,moodle.example.net にアクセスしてみても,ページ
右上には「あなたはログインしていません」と表示されます.

Moodle の Shibboleth 認証のプログラム構造をよくよく考えてみると,

    https://moodle.example.net/auth/shibboleth/index.php

だけを shibboleth 認証の対象としていて,トップページでは何も shibboleth
について考慮されていないので,これは当たり前の挙動なのですが,SSO として
はまずい挙動です.本学では, moodle-2.x と moodle-1.x を並行運用する予定
なので,両者の moodle を行き来したときにログインリンクを辿り直さなければ
ならないというのは,ユーザから見ると混乱の元です.

さて,どうしたら良いでしょうか?

-- 
土屋 雅稔 ( TSUCHIYA Masatoshi )