summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Marx <mad@madness.at>2005-05-16 09:11:00 +0200
committerAlexander Marx <mad@madness.at>2005-05-16 09:11:00 +0200
commitd48c0af2c067f9b5a5bf956b255b70f5358a350f (patch)
tree04fc355f6bf4775d8c9b48ddc87c962c3c1d9d6a
parentae26694662df53d7960288c3e2e8e40b98a927d2 (diff)
downloadrpg-d48c0af2c067f9b5a5bf956b255b70f5358a350f.tar.gz
rpg-d48c0af2c067f9b5a5bf956b255b70f5358a350f.tar.bz2
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
-rw-r--r--inc/auth_pgsql.php46
1 files changed, 34 insertions, 12 deletions
diff --git a/inc/auth_pgsql.php b/inc/auth_pgsql.php
index e9c36eb58..b063f405e 100644
--- a/inc/auth_pgsql.php
+++ b/inc/auth_pgsql.php
@@ -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 :
+