auth:xmpp
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
auth:xmpp [2008-12-09 19:41] – 70.103.232.219 | auth:xmpp [2010-02-19 19:32] – 74.93.99.97 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== XMPP/Jabber authentication | ||
+ | ===== Incompatibility with the current version of DokuWiki ===== | ||
+ | |||
+ | * Tried to use both variants on DokuWiki version 2009-12-25c " | ||
+ | |||
+ | ===== What does it do? ===== | ||
+ | |||
+ | It authenticates users by logging into an XMPP server. This was originally conceived in order to have a website authenticate against email accounts set up on Gmail for a whole domain. It's really incomplete and " | ||
+ | |||
+ | ===== Requirements ===== | ||
+ | |||
+ | * XMPPHP (http:// | ||
+ | |||
+ | ===== Installation ===== | ||
+ | |||
+ | Paste the code into " | ||
+ | |||
+ | $conf[' | ||
+ | |||
+ | And remember to alter " | ||
+ | |||
+ | ===== Code ===== | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | /** | ||
+ | * XMPP/Jabber authentication backend | ||
+ | * | ||
+ | * http:// | ||
+ | * | ||
+ | * XMPPHP from http:// | ||
+ | * for this to work at all. | ||
+ | * | ||
+ | * @license | ||
+ | * @author | ||
+ | */ | ||
+ | |||
+ | include ' | ||
+ | |||
+ | $server = ' | ||
+ | $port = 5222; | ||
+ | $domain = ' | ||
+ | |||
+ | // we only accept page ids for auth_plain | ||
+ | if(isset($_REQUEST[' | ||
+ | $_REQUEST[' | ||
+ | |||
+ | /** | ||
+ | * Check user+password [required auth function] | ||
+ | * | ||
+ | * Checks if the given user exists and the given | ||
+ | * plaintext password is correct by trying to | ||
+ | * connect to and authenticate against an xmpp | ||
+ | * server. | ||
+ | * | ||
+ | * @author | ||
+ | * @return | ||
+ | */ | ||
+ | function auth_checkPass($user, | ||
+ | global $server; | ||
+ | global $port; | ||
+ | global $domain; | ||
+ | |||
+ | $conn = new XMPPHP_XMPP($server, | ||
+ | |||
+ | try { | ||
+ | $conn-> | ||
+ | $conn-> | ||
+ | $conn-> | ||
+ | return true; | ||
+ | } catch(XMPPHP_Exception $e) { | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Return user info [required auth function] | ||
+ | * | ||
+ | * Returns info about the given user needs to contain | ||
+ | * at least these fields: | ||
+ | * | ||
+ | * name string | ||
+ | * mail string | ||
+ | * grps array list of groups the user is in | ||
+ | * | ||
+ | * No group support yet. | ||
+ | * | ||
+ | * @author | ||
+ | */ | ||
+ | function auth_getUserData($user){ | ||
+ | $userinfo = array (" | ||
+ | return $userinfo; | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Create a new User [required auth function] | ||
+ | * | ||
+ | * Returns false if the user already exists, null when an error | ||
+ | * occurred and the cleartext password of the new user if | ||
+ | * everything went well. | ||
+ | * | ||
+ | * This obviously always returns null, since sane admins | ||
+ | * have account creation disabled on XMPP servers. | ||
+ | * | ||
+ | * @author | ||
+ | */ | ||
+ | function auth_createUser($user, | ||
+ | msg(' | ||
+ | return null; | ||
+ | } | ||
+ | |||
+ | //Setup VIM: ex: et ts=2 enc=utf-8 : | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Alternate Code ===== | ||
+ | |||
+ | The above doesn' | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | /** | ||
+ | * XMPP/Jabber authentication backend | ||
+ | * | ||
+ | * http:// | ||
+ | * | ||
+ | * XMPPHP from http:// | ||
+ | * for this to work at all. | ||
+ | * | ||
+ | * @license | ||
+ | * @author | ||
+ | * @author | ||
+ | * @author | ||
+ | * @author | ||
+ | */ | ||
+ | |||
+ | define(' | ||
+ | require_once(DOKU_AUTH.'/ | ||
+ | |||
+ | require_once("/ | ||
+ | |||
+ | class auth_xmpp extends auth_basic { | ||
+ | |||
+ | var $server = " | ||
+ | var $port = 5222; | ||
+ | var $domain = " | ||
+ | |||
+ | /** | ||
+ | * Constructor | ||
+ | * | ||
+ | * checks if the MySQL interface is available, otherwise it will | ||
+ | * set the variable $success of the basis class to false | ||
+ | * | ||
+ | * @author Matthias Grimm < | ||
+ | * @author Paul Thomas < | ||
+ | */ | ||
+ | function auth_xmpp() { | ||
+ | global $conf; | ||
+ | if (method_exists($this, | ||
+ | parent:: | ||
+ | |||
+ | } | ||
+ | /** | ||
+ | * Checks if the given user exists and the given plaintext password | ||
+ | * is correct. Further on, it might be checked whether the user is | ||
+ | * member of the right group | ||
+ | * | ||
+ | * Depending on which SQL string is defined in the config, password | ||
+ | * checking is done here (getpass) or by the database (passcheck) | ||
+ | * | ||
+ | * @param | ||
+ | * @param | ||
+ | * @return bool | ||
+ | * | ||
+ | * @author | ||
+ | * @author | ||
+ | * @author | ||
+ | */ | ||
+ | function checkPass($user, | ||
+ | $conn = new XMPPHP_XMPP($this-> | ||
+ | |||
+ | try { | ||
+ | $conn-> | ||
+ | $conn-> | ||
+ | $conn-> | ||
+ | $this-> | ||
+ | return true; | ||
+ | } | ||
+ | catch (XMPPHP_Exception $e) { | ||
+ | $this-> | ||
+ | return false; | ||
+ | } | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | function getUserData($user){ | ||
+ | $userinfo = array (" | ||
+ | return $userinfo; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ |