mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Very early version of Shibboleth plugin, looking for feedback
This commit is contained in:
parent
1bb6ad15cf
commit
624dc86a4d
1
auth/shibboleth/README.txt
Normal file
1
auth/shibboleth/README.txt
Normal file
@ -0,0 +1 @@
|
||||
Under development
|
134
auth/shibboleth/config.html
Executable file
134
auth/shibboleth/config.html
Executable file
@ -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>
|
||||
|
||||
|
||||
|
||||
|
60
auth/shibboleth/lib.php
Executable file
60
auth/shibboleth/lib.php
Executable file
@ -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;
|
||||
}
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user