diff options
author | Andreas Gohr <gohr@cosmocode.de> | 2006-01-10 10:29:03 +0100 |
---|---|---|
committer | Andreas Gohr <gohr@cosmocode.de> | 2006-01-10 10:29:03 +0100 |
commit | f5cb575df722c05fc0a6ba960bd2a79d5ed5621c (patch) | |
tree | 3638e9a835a860e94a86c52e745880fcc4c6810f /inc/auth/punbb.class.php | |
parent | 96331712eb165972845b097644336ca87a81dfcd (diff) | |
download | rpg-f5cb575df722c05fc0a6ba960bd2a79d5ed5621c.tar.gz rpg-f5cb575df722c05fc0a6ba960bd2a79d5ed5621c.tar.bz2 |
external authentication
This patch adds the functionality to override the usual auth_mechanism
completely and replace it with your own. This can be used to authenticate
against Apache auth mechanisms or third party software cookies. A very
basic example for using PunBB's $pun_user variable is included.
darcs-hash:20060110092903-6e07b-7c7750da4eb4e9116ddc28c77015488ea500c07d.gz
Diffstat (limited to 'inc/auth/punbb.class.php')
-rw-r--r-- | inc/auth/punbb.class.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/inc/auth/punbb.class.php b/inc/auth/punbb.class.php new file mode 100644 index 000000000..e4e7bca42 --- /dev/null +++ b/inc/auth/punbb.class.php @@ -0,0 +1,55 @@ +<?php +/** + * PunBB auth backend + * + * Uses external Trust mechanism to check against PunBB's + * user cookie. PunBB's PUN_ROOT must be defined correctly. + * + * It inherits from the MySQL module, so you may set up + * the correct SQL strings for user modification if you like. + * + * @todo This is far from perfect yet. SQL Strings should be + * predefined. Logging in should be handled correctly. + * @author Andreas Gohr <andi@splitbrain.org> + */ + +if(!defined('PUN_ROOT')) define('PUN_ROOT', DOKU_INC.'../forum/'); +require_once PUN_ROOT.'include/common.php'; +require_once DOKU_INC.'inc/auth/mysql.class.php'; + +class auth_punbb extends auth_mysql { + + /** + * Just checks against the $pun_user variable + */ + function trustExternal($user,$pass,$sticky=false){ + global $USERINFO; + global $conf; + global $pun_user; + $sticky ? $sticky = true : $sticky = false; //sanity check + + // someone used the login form + if(isset($user)){ + msg('Please login at the forum',-1); + //FIXME a redirect to PunBBs login would be nice here + auth_logoff(); + return false; + } + + if(isset($pun_user) && !$pun_user['is_guest']){ + // okay we're logged in - set the globals + $USERINFO['name'] = $pun_user['username']; + $USERINFO['mail'] = $pun_user['email']; + $USERINFO['grps'] = array($pun_user['g_title']); + + $_SERVER['REMOTE_USER'] = $pun_user['username']; + $_SESSION[$conf['title']]['auth']['user'] = $pun_user['username']; + $_SESSION[$conf['title']]['auth']['info'] = $USERINFO; + return true; + } + + // to be sure + auth_logoff(); + return false; + } +} |