Newer
Older
<?php
// #######################################################
// Author: Martin Haase / DAASI International GmbH / TextGrid
// Creation date: 2010-09-23
// Modification date: 2010-09-03
// Version: 0.1
// #######################################################
include("../tglib/LDAP.class.php");
include("../tglib/RBAC.class.php");
include("../tglib/WebUtils.class.php");
$configfile = "../../../config_tgwebauth.xml";
$authZinstance = $_REQUEST["authZinstance"];
if ( !(isset($authZinstance)) || strlen($authZinstance) <= 0 ) {
$util->printAuthFailure("No TgAuth Instance provided",
"Please provide a valid string in the authZinstance variable.",
null,
null );
exit;
}
if (isset ($_REQUEST["loginname"]) && strlen($_REQUEST["loginname"]) > 0
&& isset ($_REQUEST["password"]) && strlen($_REQUEST["password"]) > 0) {
// now authenticating
$ldap = new LDAP ( $configfile );
$AuthNResult = $ldap->authenticate($_REQUEST["loginname"], $_REQUEST["password"]);
if (! $AuthNResult["success"]) {
$util->printAuthFailure("Failure authenticating at TextGrid Community Account Server",
$AuthNResult["detail"],
$_REQUEST["loginname"],
null );
exit;
}
// now creating session, activating roles, etc, in RBAC
$rbac = new RBAC ( $configfile, $authZinstance );
$CSResult = $rbac->createSession( $AuthNResult["TGID"], $AuthNResult["LDAPname"] );
if (! $CSResult["success"]) {
$util->printAuthFailure("Failure Creating Session in RBAC",
$CSResult["detail"],
$_REQUEST["loginname"],
array_merge( $CSResult["rbachash"],
array("identity_provider" => $AuthNResult["LDAPname"] )
)
);
exit;
}
$util->printAuthSuccess("Authentication Succeeded",
$_REQUEST["loginname"],
array_merge( $CSResult["rbachash"],array("identity_provider" => $AuthNResult["LDAPname"] ) ),
array("slcmode" => FALSE) // SLCs only via Shibboleth
);
} else if (isset ($_REQUEST["sid"]) && strlen($_REQUEST["sid"]) > 0 ) {
// displaySID or completeDetails
}
?>