DokuWiki

It's better when it's simple

User Tools

Site Tools


auth:punbb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
auth:punbb [2011-01-03 11:31]
82.127.2.80 [Source and Installation - FluxBB 1.4]
auth:punbb [2017-02-07 09:41] (current)
130.112.1.3 old revision restored (2013-06-09 23:58)
Line 13: Line 13:
 The backend reuses your PunBB configuration. You just need to enable it and set is the ''​PUN_ROOT''​ define pointing to the installation dir of your PunBB forum. Just add it to your ''​conf/​local.protected.php'':​ The backend reuses your PunBB configuration. You just need to enable it and set is the ''​PUN_ROOT''​ define pointing to the installation dir of your PunBB forum. Just add it to your ''​conf/​local.protected.php'':​
  
-<code php>+<​code ​php local.protected.php> 
 +<?php
   $conf['​useacl'​] ​ =1;   $conf['​useacl'​] ​ =1;
   $conf['​authtype'​]='​punbb';​   $conf['​authtype'​]='​punbb';​
Line 417: Line 418:
   * Add the line bellow in ''​conf/​local.protected.php''​ (after the definition of PUN_ROOT variable) :<​file>​include PUN_ROOT.'​include/​common.php';</​file>​   * Add the line bellow in ''​conf/​local.protected.php''​ (after the definition of PUN_ROOT variable) :<​file>​include PUN_ROOT.'​include/​common.php';</​file>​
   * Remove the line in ''​inc/​auth/​punbb.class.php''​ :<​file>​require_once PUN_ROOT.'​include/​common.php';</​file>​   * Remove the line in ''​inc/​auth/​punbb.class.php''​ :<​file>​require_once PUN_ROOT.'​include/​common.php';</​file>​
 +
 +=== PunBB CSRF & Ajax problem ===
 +
 +If you want to make ajax-quicksearch work, You should define the constant FORUM_SKIP_CSRF_CONFIRM before including any PunBB code 
 +so, the code above should be like below : <​file>​define("​FORUM_SKIP_CSRF_CONFIRM",​ 1); 
 +include PUN_ROOT.'​include/​common.php';</​file>​
 +
 +==== Dokuwiki 2013-05-10 "​Weatherwax"​ ====
 +
 +FIXME **CREATE authplugin for in the repository.**
 +
 +  * Configure the auth plugin in conf/​local.protected.php :
 +    * define('​PUN_ROOT','/​var/​www/​pathtotheforum/'​);​
 +    * require_once PUN_ROOT.'​include/​common.php';​
 +    * $conf['​authtype'​] = '​authfluxbb';​
 +  * Create the auth plugin :
 +    * **Method 1** (crapy) Adapt from an existing source
 +      * Copy the code of [[http://​fluxbb.org/​forums/​viewtopic.php?​pid=27043#​p27043|this post]] to lib/​plugins/​authfluxbb/​auth.php (authfluxbb/​ directory should be created)
 +      * Modify some code
 +        * Remove <​file>​require_once DOKU_INC.'​inc/​auth/​mysql.class.php';</​file>​
 +        * Class : <​file>​class auth_fluxbb_v1_4 extends auth_mysql {</​file>​ become <​file>​class auth_plugin_authfluxbb extends DokuWiki_Auth_Plugin {</​file>​
 +        * constructor <​file> ​ function auth_fluxbb_v1_4(){</​file>​ become <​file> ​ public function __construct() {
 +        parent::​__construct();</​file>​
 +    * **Method 2** Put this code in lib/​plugins/​authfluxbb/​auth.php <file php lib/​plugins/​authfluxbb/​auth.php>​
 +<?php
 +/**
 + * DokuWiki Plugin authfluxbb (Auth Component)
 + *
 + * @license GPL 2 http://​www.gnu.org/​licenses/​gpl-2.0.html
 + * @author ​ Id2ndR
 + */
 +
 +// must be run within Dokuwiki
 +if(!defined('​DOKU_INC'​)) die();
 +
 +class auth_plugin_authfluxbb extends DokuWiki_Auth_Plugin {
 +
 +
 +    /**
 +     * Constructor.
 +     */
 +    public function __construct() {
 +        parent::​__construct();​ // for compatibility
 +
 +        // Set capabilities accordingly
 +        $this->​cando['​addUser'​] ​    = false; // can Users be created?
 +        $this->​cando['​delUser'​] ​    = false; // can Users be deleted?
 +        $this->​cando['​modLogin'​] ​   = false; // can login names be changed?
 +        $this->​cando['​modPass'​] ​    = false; // can passwords be changed?
 +        $this->​cando['​modName'​] ​    = false; // can real names be changed?
 +        $this->​cando['​modMail'​] ​    = false; // can emails be changed?
 +        $this->​cando['​modGroups'​] ​  = false; // can groups be changed?
 +        $this->​cando['​getUsers'​] ​   = false; // can a (filtered) list of users be retrieved?
 +        $this->​cando['​getUserCount'​]= false; // can the number of users be retrieved?
 +        $this->​cando['​getGroups'​] ​  = false; // can a list of available groups be retrieved?
 +        $this->​cando['​external'​] ​   = true; // does the module do external auth checking?
 +        $this->​cando['​logout'​] ​     = false; // can the user logout again? (eg. not possible with HTTP auth)
 +
 +
 +        // FIXME intialize your auth system and set success to true, if successful
 +        $this->​success = true;
 +    }
 +
 +
 +    /**
 +     * Log off the current user [ OPTIONAL ]
 +     */
 +    //public function logOff() {
 +    //}
 +
 +    /**
 +     * Do all authentication [ OPTIONAL ]
 +     *
 +     * @param ​  ​string ​ $user    Username
 +     * @param ​  ​string ​ $pass    Cleartext Password
 +     * @param ​  ​bool ​   $sticky ​ Cookie should not expire
 +     * @return ​ bool             true on successful auth
 +     */
 +    function trustExternal($user,​$pass,​$sticky=false){
 +        global $USERINFO;
 +        global $conf;
 +        global $lang;
 +        global $pun_user;
 +        global $pun_config;​
 +        global $cookie_name;​
 +        $sticky ? $sticky = true : $sticky = false; //sanity check
 +
 +        if(isset($pun_user) && !$pun_user['​is_guest'​]){
 +              // okay we're logged in - set the globals
 +              $USERINFO['​pass'​] = $pun_user['​password'​];​
 +              $USERINFO['​name'​] = utf8_encode($pun_user['​realname'​]);​
 +              $USERINFO['​mail'​] = $pun_user['​email'​];​
 +              $USERINFO['​grps'​] = array($pun_user['​g_title'​]);​
 +              if ($pun_user['​is_admmod'​])
 +                $USERINFO['​grps'​][] = '​admin';​
 +
 +              $_SERVER['​REMOTE_USER'​] = utf8_decode($pun_user['​username'​]);​
 +              $_SESSION[DOKU_COOKIE]['​auth'​]['​user'​] = $pun_user['​username'​];​
 +              $_SESSION[DOKU_COOKIE]['​auth'​]['​info'​] = $USERINFO;
 +              return true;
 +        }
 +
 +        // to be sure
 +        auth_logoff();​
 +
 +        $USERINFO['​grps'​] = array();
 +        return false;
 +
 +    }
 +
 +    /**
 +     * Check user+password
 +     *
 +     * May be ommited if trustExternal is used.
 +     *
 +     * @param ​  ​string $user the user name
 +     * @param ​  ​string $pass the clear text password
 +     * @return ​ bool
 +     */
 +    public function checkPass($user,​ $pass) {
 +        // FIXME implement password check
 +        return false; // return true if okay
 +    }
 +
 +    /**
 +     * Return user info
 +     *
 +     * Returns info about the given user needs to contain
 +     * at least these fields:
 +     *
 +     * name string ​ full name of the user
 +     * mail string ​ email addres of the user
 +     * grps array   list of groups the user is in
 +     *
 +     * @param ​  ​string $user the user name
 +     * @return ​ array containing user data or false
 +     */
 +    public function getUserData($user) {
 +        // FIXME implement
 +        return false;
 +    }
 +
 +    /**
 +     * Create a new User [implement only where required/​possible]
 +     *
 +     * Returns false if the user already exists, null when an error
 +     * occurred and true if everything went well.
 +     *
 +     * The new user HAS TO be added to the default group by this
 +     * function!
 +     *
 +     * Set addUser capability when implemented
 +     *
 +     * @param ​ string ​    $user
 +     * @param ​ string ​    $pass
 +     * @param ​ string ​    $name
 +     * @param ​ string ​    $mail
 +     * @param ​ null|array $grps
 +     * @return bool|null
 +     */
 +    //public function createUser($user,​ $pass, $name, $mail, $grps = null) {
 +        // FIXME implement
 +    //    return null;
 +    //}
 +
 +    /**
 +     * Modify user data [implement only where required/​possible]
 +     *
 +     * Set the mod* capabilities according to the implemented features
 +     *
 +     * @param ​  ​string $user    nick of the user to be changed
 +     * @param ​  ​array ​ $changes array of field/value pairs to be changed (password will be clear text)
 +     * @return ​ bool
 +     */
 +    //public function modifyUser($user,​ $changes) {
 +        // FIXME implement
 +    //    return false;
 +    //}
 +
 +    /**
 +     * Delete one or more users [implement only where required/​possible]
 +     *
 +     * Set delUser capability when implemented
 +     *
 +     * @param ​  ​array ​ $users
 +     * @return ​ int    number of users deleted
 +     */
 +    //public function deleteUsers($users) {
 +        // FIXME implement
 +    //    return false;
 +    //}
 +
 +    /**
 +     * Bulk retrieval of user data [implement only where required/​possible]
 +     *
 +     * Set getUsers capability when implemented
 +     *
 +     * @param ​  ​int ​  ​$start ​    index of first user to be returned
 +     * @param ​  ​int ​  ​$limit ​    max number of users to be returned
 +     * @param ​  array $filter ​   array of field/​pattern pairs, null for no filter
 +     * @return ​ array list of userinfo (refer getUserData for internal userinfo details)
 +     */
 +    //public function retrieveUsers($start = 0, $limit = -1, $filter = null) {
 +        // FIXME implement
 +    //    return array();
 +    //}
 +
 +    /**
 +     * Return a count of the number of user which meet $filter criteria
 +     * [should be implemented whenever retrieveUsers is implemented]
 +     *
 +     * Set getUserCount capability when implemented
 +     *
 +     * @param ​ array $filter array of field/​pattern pairs, empty array for no filter
 +     * @return int
 +     */
 +    //public function getUserCount($filter = array()) {
 +        // FIXME implement
 +    //    return 0;
 +    //}
 +
 +    /**
 +     * Define a group [implement only where required/​possible]
 +     *
 +     * Set addGroup capability when implemented
 +     *
 +     * @param ​  ​string $group
 +     * @return ​ bool
 +     */
 +    //public function addGroup($group) {
 +        // FIXME implement
 +    //    return false;
 +    //}
 +
 +    /**
 +     * Retrieve groups [implement only where required/​possible]
 +     *
 +     * Set getGroups capability when implemented
 +     *
 +     * @param ​  int $start
 +     * @param ​  int $limit
 +     * @return ​ array
 +     */
 +    //public function retrieveGroups($start = 0, $limit = 0) {
 +        // FIXME implement
 +    //    return array();
 +    //}
 +
 +    /**
 +     * Return case sensitivity of the backend
 +     *
 +     * When your backend is caseinsensitive (eg. you can login with USER and
 +     * user) then you need to overwrite this method and return false
 +     *
 +     * @return bool
 +     */
 +    public function isCaseSensitive() {
 +        return true;
 +    }
 +
 +    /**
 +     * Sanitize a given username
 +     *
 +     * This function is applied to any user name that is given to
 +     * the backend and should also be applied to any user name within
 +     * the backend before returning it somewhere.
 +     *
 +     * This should be used to enforce username restrictions.
 +     *
 +     * @param string $user username
 +     * @return string the cleaned username
 +     */
 +    public function cleanUser($user) {
 +        return $user;
 +    }
 +
 +    /**
 +     * Sanitize a given groupname
 +     *
 +     * This function is applied to any groupname that is given to
 +     * the backend and should also be applied to any groupname within
 +     * the backend before returning it somewhere.
 +     *
 +     * This should be used to enforce groupname restrictions.
 +     *
 +     * Groupnames are to be passed without a leading '​@'​ here.
 +     *
 +     * @param ​ string $group groupname
 +     * @return string the cleaned groupname
 +     */
 +    public function cleanGroup($group) {
 +        return $group;
 +    }
 +
 +    /**
 +     * Check Session Cache validity [implement only where required/​possible]
 +     *
 +     * DokuWiki caches user info in the user's session for the timespan defined
 +     * in $conf['​auth_security_timeout'​].
 +     *
 +     * This makes sure slow authentication backends do not slow down DokuWiki.
 +     * This also means that changes to the user database will not be reflected
 +     * on currently logged in users.
 +     *
 +     * To accommodate for this, the user manager plugin will touch a reference
 +     * file whenever a change is submitted. This function compares the filetime
 +     * of this reference file with the time stored in the session.
 +     *
 +     * This reference file mechanism does not reflect changes done directly in
 +     * the backend'​s database through other means than the user manager plugin.
 +     *
 +     * Fast backends might want to return always false, to force rechecks on
 +     * each page load. Others might want to use their own checking here. If
 +     * unsure, do not override.
 +     *
 +     * @param ​ string $user - The username
 +     * @return bool
 +     */
 +    //public function useSessionCache($user) {
 +      // FIXME implement
 +    //}
 +}
 +
 +// vim:​ts=4:​sw=4:​et:​
 +</​file>​
 +
  
 ===== Discussion ===== ===== Discussion =====
Line 459: Line 786:
     * yann: edit the file conf/​acl.auth.php,​ add there the group members (duplicate the line with "​user",​ and replace "​user"​ by "​members"​.     * yann: edit the file conf/​acl.auth.php,​ add there the group members (duplicate the line with "​user",​ and replace "​user"​ by "​members"​.
     * Better yet, use the group Members as is defined in the table groups in the PunBB MySQL database.     * Better yet, use the group Members as is defined in the table groups in the PunBB MySQL database.
 +
 +  * With Dokuwiki 2012-10-13 Adora Belle, the auth stoped working with following error:<​file>​PHP Fatal error: ​ Call to undefined method auth_punbb::​auth_mysql() in [...]/​inc/​auth/​punbb.class.php on line 102, referer: [...]</​file>​
 +  * To fix it, you need to change the line 102 from //​$this->​auth_mysql();//​ to //​$this->​**__construct()**;//​.
auth/punbb.1294050707.txt.gz · Last modified: 2011-01-03 11:31 by 82.127.2.80