]> git.mjollnir.org Git - moodle.git/commitdiff
Very early version of Shibboleth plugin, looking for feedback
authormoodler <moodler>
Mon, 8 Nov 2004 15:08:19 +0000 (15:08 +0000)
committermoodler <moodler>
Mon, 8 Nov 2004 15:08:19 +0000 (15:08 +0000)
auth/shibboleth/README.txt [new file with mode: 0644]
auth/shibboleth/config.html [new file with mode: 0755]
auth/shibboleth/lib.php [new file with mode: 0755]

diff --git a/auth/shibboleth/README.txt b/auth/shibboleth/README.txt
new file mode 100644 (file)
index 0000000..91d2ed7
--- /dev/null
@@ -0,0 +1 @@
+Under development
diff --git a/auth/shibboleth/config.html b/auth/shibboleth/config.html
new file mode 100755 (executable)
index 0000000..7292a57
--- /dev/null
@@ -0,0 +1,134 @@
+<?PHP
+?>
+<tr valign="top">
+    <TD ALIGN=RIGHT><P>Shibboleth WAYF url:</TD>
+    <TD>
+        <INPUT name=shib_wayf_url TYPE=text SIZE=30 VALUE="<?php echo $config->shib_wayf_url?>">
+    <?php  if (isset($err["shib_wayf_url"])) formerr($err["shib_wayf_url"]); ?>
+    </TD>
+    <TD>
+    </TD>
+</TR>
+<TR>
+    <TD ALIGN=RIGHT><P>Shibboleth logout url:</TD>
+    <TD>
+    <INPUT name="shib_logout_url" TYPE="text" SIZE="30" VALUE="<?php echo $config->shib_logout_url?>">
+    </TD>
+    <TD rowspan=12 VALIGN=CENTER>                                                                                                                                 </TD>
+</TR>  
+<TR>
+    <TD ALIGN=RIGHT><P><?php  print_string("username") ?>:</TD>
+    <TD>
+    <INPUT name="shib_user_attribute" TYPE="text" SIZE="30" VALUE="<?php echo $config->shib_user_attribute?>">
+    </TD>
+    <TD rowspan=12 VALIGN=CENTER>
+    </TD>
+</TR>
+
+<TR>
+    <TD ALIGN=RIGHT><P><?php  print_string("firstname") ?>:</TD>
+    <TD>
+    <INPUT name="auth_user_firstname" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_firstname?>">
+    </TD>
+    <TD rowspan=12 VALIGN=CENTER>
+    </TD>
+</TR>
+<TR VALIGN=TOP>
+    <TD ALIGN=RIGHT><P><?php  print_string("lastname") ?>:</TD>
+    <TD>
+    <INPUT name="auth_user_lastname" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_lastname?>">
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+    <TD ALIGN=RIGHT><P><?php  print_string("email") ?>:</TD>
+    <TD>
+    <INPUT name="auth_user_email" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_email?>">
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+    <TD ALIGN=RIGHT><P><?php  print_string("phone") ?> 1:</TD>
+    <TD>
+    <INPUT name="auth_user_phone1" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_phone1?>">
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+    <TD ALIGN=RIGHT><P><?php  print_string("phone") ?> 2:</TD>
+    <TD>
+    <INPUT name="auth_user_phone2" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_phone2?>">
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+    <TD ALIGN=RIGHT><P><?php  print_string("department") ?>:</TD>
+    <TD>
+    <INPUT name="auth_user_department" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_department?>">
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+    <TD ALIGN=RIGHT><P><?php  print_string("address") ?>:</TD>
+    <TD>
+    <INPUT name="auth_user_address" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_address?>">
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+    <TD ALIGN=RIGHT><P><?php  print_string("city") ?>:</TD>
+    <TD>
+    <INPUT name="auth_user_city" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_city?>">
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+    <TD ALIGN=RIGHT><P><?php  print_string("country") ?>:</TD>
+    <TD>
+    <INPUT name="auth_user_country" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_country?>">
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+    <TD ALIGN=RIGHT><P><?php  print_string("description") ?>:</TD>
+    <TD>
+    <INPUT name="auth_user_description" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_description?>">
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+    <TD ALIGN=RIGHT><P><?php  print_string("idnumber") ?>:</TD>
+    <TD>
+    <INPUT name="auth_user_idnumber" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_idnumber?>">
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+    <TD ALIGN=RIGHT><P><?php  print_string("language") ?>:</TD>
+    <TD>
+    <INPUT name="auth_user_lang" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_lang?>">
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+    <TD ALIGN=RIGHT><P><?php  print_string("guid") ?>:</TD>
+    <TD>
+    <INPUT name="auth_user_guid" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_guid?>">
+    </TD>
+</TR>
+
+
+<TR VALIGN=TOP>
+    <TD ALIGN=RIGHT><P><?php  print_string("instructions", "auth") ?>:</TD>
+    <TD>
+    <TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><?php  p($config->auth_instructions) ?></TEXTAREA> 
+    </TD>
+    <TD>
+    <?php  print_string("authinstructions","auth") ?>
+    <?php  helpbutton("text", get_string("helptext")) ?>
+    </TD>
+</TR>
+
+
+
+
diff --git a/auth/shibboleth/lib.php b/auth/shibboleth/lib.php
new file mode 100755 (executable)
index 0000000..4024a0d
--- /dev/null
@@ -0,0 +1,60 @@
+<?PHP  // $Id$
+//CHANGELOG:
+//28.10.2004 SHIBBOLETH Authentication functions v.0.1
+//Distributed under GPL (c)Markus Hagman 2004-
+
+function auth_user_login ($username, $password) {
+    global $CFG;
+       if($_SERVER[$CFG->shib_user_attribute] == $username) {
+        return true;
+    }
+    // Returns false if the username doesn't exist yet
+    // Returns true if the username and password work
+    if ($user = get_user_info_from_db("username", $username)) {
+               if($user->auth == "shibboleth") {
+            return false;
+            exit;
+        } else {
+            return ($user->password == md5($password));
+            exit;
+        }
+    }   
+
+    return false;
+}
+
+function auth_get_userinfo($username) {
+// reads user information from shibboleth attributes and return it in array()
+    global $CFG;
+
+    $config = (array)$CFG;
+    $attrmap = auth_shib_attributes();
+   
+    $result = array();
+    $search_attribs = array();
+  
+    foreach ($attrmap as $key=>$value) {
+        $result[$key]=$_SERVER[$value];
+    }
+    return $result;
+}
+
+function auth_shib_attributes (){
+//returns array containg attribute mappings between Moodle and shibboleth
+       global $CFG;
+
+    $config = (array)$CFG;
+    $fields = array("firstname", "lastname", "email", "phone1", "phone2", 
+                    "department", "address", "city", "country", "description", 
+                    "idnumber", "lang", "guid");
+
+    $moodleattributes = array();
+    foreach ($fields as $field) {
+        if ($config["auth_user_$field"]) {
+            $moodleattributes[$field] = $config["auth_user_$field"];
+        }
+    }
+    $moodleattributes['username']=$config["shib_user_attribute"];
+       return $moodleattributes;
+}
+?>