Update of /cvsroot/phpslash/phpslash-dev/include/modules/auth/authtypes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2479/phpslash-dev/include/modules/auth/authtypes
Added Files:
slashAuthEGW.class
Log Message:
add eGroupware authentication
--- NEW FILE: slashAuthEGW.class ---
<?php
/* $Id: slashAuthEGW.class,v 1.1 2004/09/22 21:01:31 joestewart Exp $
*
* eGroupware authentication
*/
class slashAuth extends slashAuth_base {
// eGw authentication
function psl_validate($username, $passwd, $response='', $user_info='') {
$is_user = false;
if ($this->egw_authenticate($username, $passwd)) {
if($user_info) {
// user exists in psl already
return true;
} elseif ($this->psl['auth.autoadd']) {
// if config allows for us to add external users
$is_user = $this->psl_add_egwuser($username);
}
}
return $is_user;
}
function egw_authenticate($username, $passwd) {
$passwd_type = 'text';
if($GLOBALS['phpgw']->auth->authenticate($username, $passwd, $passwd_type)) {
return true;
}
return false;
}
// automatically login psl if logged into eGw
function auth_preauth() {
$uid = false;
if(is_array($GLOBALS['phpgw_info']['user'])) {
$username = $GLOBALS['phpgw_info']['user']['account_lid'];
$user_info = $this->get_psluser_info($username);
if ($user_info == false) {
// egw user not a psl user yet
if($this->psl['auth.autoadd']) {
// but we can add them
$is_user = $this->psl_add_egwuser($username);
if($is_user) {
$user_info = $this->get_psluser_info($username);
}
}
}
if ($user_info) {
// preauth successful
// debug("preauth", "successful");
$this->auth["uname"] = $user_info["uname"];
$this->auth["dname"] = $user_info["dname"];
$this->auth["url"] = $user_info["url"];
// $this->auth["uid"] = $user_info["uid"];
$uid = $user_info["author_id"];
$this->auth["perm"] = $this->get_userperms($uid);
}
// expire cache for this session
if(function_exists('jpcache_gc')) {
jpcache_gc('string', "-slashSess-" . $sess->id, "100");
}
// success is signalled by returning the user's id.
return $uid;
} else if ($this->nobody) {
// not logged into eGw
// if public access allowed apply the data for user named 'nobody'
$arg_ary['author_name'] = 'nobody';
$author_ary = $this->load_user_info($arg_ary);
$this->auth['preferences'] = '';
// get rid of session variables and use the db author record.
$this->clear_session_vars();
// expire cache for this session
if(function_exists('jpcache_gc')) {
jpcache_gc('string', "-slashSess-" . $sess->id, "100");
}
// return the id for user 'nobody'
return $author_ary['author_id'];
} else {
// preauth failed
// debug("preauth", "failed");
return false;
}
}
function psl_add_egwuser($username) {
$ary['author_name'] = $username;
if($GLOBALS['phpgw_info']['user']['account_lid'] == $username) {
$ary['author_realname'] = $GLOBALS['phpgw_info']['user']['fullname'];
$ary['email'] = $GLOBALS['phpgw_info']['user']['email'];
}
$perm_ary['nobody'] = 20;
$perm_ary['user'] = 21;
$perm_ary['bloggers'] = 28;
if (isset($GLOBALS['phpgw_info']['user']['apps']['admin']) &&
is_array($GLOBALS['phpgw_info']['user']['apps']['admin'])) {
$perm_ary['root'] = 24;
}
$ary["permission"] = $perm_ary;
if($is_user = $this->psl_register_authed($ary)) {
return $is_user;
}
return false;
}
}
?>
|