Skip to content
Snippets Groups Projects
Commit d48c0af2 authored by Alexander Marx's avatar Alexander Marx
Browse files

auth_pgsql update for auth_cryptPassword

added support for the new auth_cryptPassword() and the corresponding
verify functions

   - $conf['auth']['pgsql']['userinfo'] is now used to verify passwords;
     therefore it also needs to return the crypted passwords which in
     turn makes $conf['auth']['pgsql']['passcheck'] obsolete
   - changed the pass collumn in the users table from varchar(32)
     to varchar(255); just to be on the safe side.

added support for an optional pgsql "port" option
($conf['auth']['pgsql']['port'])

added basic support for adding new users
this needs the $conf['auth']['pgsql']['createuser'] option including
a corresponding sql function

darcs-hash:20050516071100-c516d-8573af3850f5c4aa4f1ddc71be062a0e93fdacd4.gz
parent ae266946
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,11 @@ function auth_pgsql_runsql($sql_string) {
global $conf;
$cnf = $conf['auth']['pgsql'];
$dsn="host=".$cnf['server']." port=5432 dbname=".$cnf['database']." user=".$cnf['user']." password=".$cnf['password'];
if($cnf['port']) {
$port=" port=".$cnf['port'];
}
$dsn="host=".$cnf['server']." dbname=".$cnf['database'].$port." user=".$cnf['user']." password=".$cnf['password'];
$link = pg_connect($dsn);
if(!$link){
msg('PgSQL: Connection to database failed!',-1);
......@@ -59,10 +63,14 @@ function auth_checkPass($user,$pass){
global $conf;
$cnf = $conf['auth']['pgsql'];
$sql = str_replace('%u',addslashes($user),$cnf['passcheck']);
$sql = str_replace('%p',addslashes($pass),$sql);
$sql = str_replace('%u',addslashes($user),$cnf['userinfo']);
$result = auth_pgsql_runsql($sql);
return(count($result));
if(count($result)>0) {
$info=$result[0];
return auth_verifyPassword($pass, $info['pass']);
} else {
return false;
}
}
/**
......@@ -98,16 +106,30 @@ function auth_getUserData($user){
/**
* Create a new User [required auth function]
*
* Not implemented
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function auth_createUser($user,$pass,$name,$mail){
msg("Sorry. Creating users is not supported by the PgSQL backend, yet",-1);
return null;
}
function auth_createUser($user,$pass,$name,$mail) {
global $conf;
$cnf = $conf['auth']['pgsql'];
if($cnf['createuser']) {
$sql = str_replace('%u',addslashes($user),$cnf['userinfo']);
$result = auth_pgsql_runsql($sql);
if(count($result)>0) return false;
$sql = str_replace('%u',addslashes($user),$cnf['createuser']);
$sql = str_replace('%p',auth_cryptPassword($pass),$sql);
$sql = str_replace('%f',addslashes($name),$sql);
$sql = str_replace('%e',addslashes($mail),$sql);
$sql = str_replace('%g',addslashes($conf['defaultgroup']),$sql);
$result=auth_pgsql_runsql($sql);
if(count($result))
return $pass;
} else {
msg("Sorry. Your PgSQL backend is not configured to create new users.",-1);
}
return null;
}
//Setup VIM: ex: et ts=2 enc=utf-8 :
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment