auth:cafu_phpbb3
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
auth:cafu_phpbb3 [2011-03-17 20:51] – Aleksandr | auth:cafu_phpbb3 [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== phpBB3 ====== | ||
- | This backend authenticates against the user database of a phpBB3 forum. | ||
- | |||
- | The code is deliberatively split into two files that are independent of each other. | ||
- | As such, the second file that handles the phpBB3 part of the authentication is easily replaced and generalized to other purposes. | ||
- | |||
- | :!: This code doesn' | ||
- | |||
- | ===== Code ===== | ||
- | |||
- | <file php cafu_phpbb3.class.php> | ||
- | <?php | ||
- | /** | ||
- | * A very simple authentication backend that authenticates against (e.g.) a phpBB3 system. | ||
- | * | ||
- | * Writing a phpBB3 integration is difficult because the two most self-suggesting | ||
- | * approaches are both somewhat twisted: | ||
- | * | ||
- | | ||
- | * of their special password hashing algorithm. I've only done a very quick check, but it | ||
- | * seems that the best way to check if a phpBB3 password is valid is to use phpBB3 code. | ||
- | * | ||
- | | ||
- | * module not with via mysql.class.php, | ||
- | * suffers not only from plenty of name clashes (again, see [1]), but in fact seems | ||
- | * impossible since DokuWiki release 2010-11-07 " | ||
- | * does not function any more after the merge of the requireall branch on 2010-03-12." | ||
- | * | ||
- | * To overcome these problems, our approach is to call a separate, " | ||
- | * with the username and password as parameters, then parse the returned output, which is | ||
- | * the string " | ||
- | * valid, or an HTTP 401 error response otherwise. | ||
- | * | ||
- | * The big advantage is that this cleanly separates and never mixes DokuWiki and phpBB3 code: | ||
- | * In the external script, we use phpBB3 code to check the phpBB3 password, while in this | ||
- | * file we have DokuWiki include files only. Advantages and features (also compared to [1]): | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | * | ||
- | * [1] http:// | ||
- | * | ||
- | * @license | ||
- | * @author | ||
- | * @see http:// | ||
- | */ | ||
- | |||
- | class auth_cafu_phpbb3 extends auth_basic | ||
- | { | ||
- | var $u2p_cache = array(); | ||
- | |||
- | /** | ||
- | * Constructor | ||
- | * Carry out sanity checks to ensure the object is able to operate. Set capabilities. | ||
- | */ | ||
- | function auth_cafu_phpbb3() | ||
- | { | ||
- | // Just use the base class defaults, which are false for everything but logoff. | ||
- | // $this-> | ||
- | // $this-> | ||
- | |||
- | $this-> | ||
- | } | ||
- | |||
- | /** | ||
- | * Checks if the given user exists and the given plaintext password is correct. | ||
- | * @return | ||
- | */ | ||
- | function checkPass($user, | ||
- | { | ||
- | $http = new DokuHTTPClient(); | ||
- | $output = explode(" | ||
- | |||
- | if ($output[0]==" | ||
- | $this-> | ||
- | |||
- | return $output[0]==" | ||
- | } | ||
- | |||
- | /** | ||
- | * Return user info | ||
- | * 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 | ||
- | */ | ||
- | function getUserData($user) | ||
- | { | ||
- | $pass = $this-> | ||
- | $http = new DokuHTTPClient(); | ||
- | $output = explode(" | ||
- | |||
- | if ($output[0]!=" | ||
- | |||
- | // msg(" | ||
- | return array(' | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | <file php auth_dokuwiki.php> | ||
- | <?php | ||
- | /** | ||
- | * | ||
- | * Quellen: | ||
- | * [1] http:// | ||
- | * [2] http:// | ||
- | * [3] http:// | ||
- | * | ||
- | * HTTP-Authentifizierung geht bei 1und1 leider nicht (PHP läuft als CGI, nicht als Apache Modul): | ||
- | * [4] http:// | ||
- | * | ||
- | */ | ||
- | |||
- | define(' | ||
- | $phpbb_root_path = ' | ||
- | $phpEx = substr(strrchr(__FILE__, | ||
- | |||
- | include($phpbb_root_path . ' | ||
- | |||
- | |||
- | # Verwende request_var() statt $_GET, siehe [1] und < | ||
- | $username=request_var(' | ||
- | $password=request_var(' | ||
- | |||
- | # Besser mit " | ||
- | $sql | ||
- | " WHERE username_clean='" | ||
- | $result=$db-> | ||
- | $row | ||
- | |||
- | if (phpbb_check_hash($password, | ||
- | { | ||
- | // Sende die Antwort in der vom Empfänger erwarteten Form. | ||
- | echo " | ||
- | echo $row[' | ||
- | } | ||
- | else | ||
- | { | ||
- | header(' | ||
- | echo " | ||
- | echo " | ||
- | } | ||
- | |||
- | ?> | ||
- | </ | ||
- | |||
- | |||
- | ===== Live Demo ====== | ||
- | |||
- | If you want to see this auth plugin in live action, we're running it at our [[http:// | ||
- | [[http:// | ||
- | |||
- | |||
- | ===== Discussion ===== | ||
- | |||
- | ==== Plaintext password? ==== | ||
- | |||
- | It looks like the function '' | ||
- | |||
- | ==== Files location ==== | ||
- | |||
- | >Where do we put these files ? | ||
- | > | ||
- | >> cafu_phpbb3.class.php -> %%http:// | ||
- | >> | ||
- | >> auth_dokuwiki.php -> %%http:// | ||
- | >> | ||
- | >> --- [[user> |
auth/cafu_phpbb3.1300391488.txt.gz · Last modified: 2011-03-17 20:51 by Aleksandr