Advice for Moodle enrolment code needed for TYPO3 SSO

Advice for Moodle enrolment code needed for TYPO3 SSO

Jens Gammelgaard -
回帖数:6
Translators的头像

Hello,

There might be a good chance that we are few code line from a good single-sign on solution between TYPO3 CMF/S and Moodle:

This SSO system consists of 3 parts where the last part regards the Moodle enrolment procedure. http://www.single-signon.com/ , so a TPA (adapter for Third Party Application) need to be coded regarding to Moodle.

I hope that some of you who are really in to the hart of the Moodle enrolment code could advice about how to change the code from the TPA example below from the phpBB TPA to a coming Moodle TPA. I will test your advice and share the results with you. The code is:

<?

/*

* Signature-Based Single Sign-On Framework

* TPA Adapter for

* phpBB (http://www.phpBB.com )

*

* Version : 0.1

* Last update : 19.05.2004

*

* (c) net&works GmbH, Hannover, Germany

* http://www.single-signon.com

*/

/**

* function which is called after including this file in the SSO-Agent.

*

* @param

* User_Name string Username the Session will be created for

* remote_addr string Remoteaddress of the users system

* agent string Browser

* sso_url string Url where the user will be redirected after establishing a session for him

*

* @return string return the session data

*

* Leave stubs if you dont need all four params.

*/

 

function sso($User_Name,$ip,$agent,$sso_url) {

global $db, $board_config;

global $phpbb_root_path,$phpEx,$client_ip;

global $exec;

global $HTTP_SERVER_VARS;

define('IN_PHPBB', true);

// load some phpBB-libs etc.

$phpbb_root_path = dirname($exec)."/";

include($phpbb_root_path . "extension.inc");

include($phpbb_root_path . "common.".$phpEx);

// reformat $User_Name

// taken from phpBB's login.php

// not sure what this is for of if it's really neccessary

$username = $User_Name;

$username = substr(str_replace("\'", "'", $username), 0, 25);

$username = str_replace("'", "\'", $username);

// check if the given $User_Name is valid

$sql = "SELECT user_id, username, user_password, user_active, user_level

FROM " . USERS_TABLE . "

WHERE username = '" . str_replace("\'", "''", $username) . "'";

$result = $db->sql_query($sql);

$row = $db->sql_fetchrow($result);

if( !$row || !$row['user_active']) {

//no valid user found; return error

$error = array("Error" => "No account for this user");

return $error;

}

else {

//create the session

$user_ip=encode_ip($client_ip);

$session_id = session_begin($row['user_id'], $user_ip, PAGE_INDEX, FALSE, $autologin);

// prepare sessiondata return-values

// Sessiondata is stored in this Format :

// Array(

// [redirecturl] => $redirecturl

// [0] => Array(

// "CookieName" => $cookiename

// "CookieValue" => $cookievalue

// "CookieExpires" => $expires

// )

// [1] => Array(

// "Cookiename" => $cookiename

// ... and so on

// )

// [1] if you need to pass more than one cookie

//

$return_val[0] = array();

$return_val += array( "redirecturl" => $sso_url."?sid=".$session_id['session_id']);

// pass session data to the SSO-Agent

return $return_val;

}

}

?>

回复Jens Gammelgaard

Re: Advice for Moodle enrolment code needed for TYPO3 SSO

Jens Gammelgaard -
Translators的头像
回复Jens Gammelgaard

Re: Advice for Moodle enrolment code needed for TYPO3 SSO

Martin Dougiamas -
Core developers的头像 Documentation writers的头像 Moodle HQ的头像 Particularly helpful Moodlers的头像 Plugin developers的头像 Testers的头像
What about the reverse? Could Typo 3 support external authentication from Moodle's database?
回复Martin Dougiamas

Re: Advice for Moodle enrolment code needed for TYPO3 SSO

Jens Gammelgaard -
Translators的头像
回复Jens Gammelgaard

Re: Advice for Moodle enrolment code needed for TYPO3 SSO

Chardelle Busch -
Core developers的头像
It might be nice, though, to have Moodle integrated using this SSO, rather than just authenticating Typo3 from Moodle, since there are several other plugins also available that could all be authenticated from Typo with this single-signon (like the OWL document management system, a bugtracker Martinsmile, a ticket system). I've never used these programs, but it looks like this might be an easy way to create an all-integrated site with the ability to just plugin anything you might need.

You can vote for an adapter for Moodle as a third-party addon here: (Claroline is Moodle's only current "competitor" so let's beat 'em)
http://www.single-signon.com/SSO_Adapters_for_Third_Party_A.119.0.html

回复Chardelle Busch

Re: Advice for Moodle enrolment code needed for TYPO3 SSO

Martin Dougiamas -
Core developers的头像 Documentation writers的头像 Moodle HQ的头像 Particularly helpful Moodlers的头像 Plugin developers的头像 Testers的头像
Sure, nice to have options both ways. For most Moodle users it would be easier to add Typo than go the other way around.