DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:authpdo

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
plugin:authpdo [2018-04-29 19:42] Aleksandrplugin:authpdo [2018-05-03 19:07] Aleksandr
Line 22: Line 22:
  
 This plugin allows to configure your wiki to authenticate against an existing database using PHP's PDO extension. Typical use cases are integrating DokuWiki with a web forum, blog or bug tracker. This plugin allows to configure your wiki to authenticate against an existing database using PHP's PDO extension. Typical use cases are integrating DokuWiki with a web forum, blog or bug tracker.
 +
  
 ===== Real World Examples ===== ===== Real World Examples =====
Line 27: Line 28:
 Before you go forward to [[#Configuration]] section, let's see quickly how many and what kind of real world configurations of PDO Authentication exist. The variation reflects the flexibility PDO is offering.  Before you go forward to [[#Configuration]] section, let's see quickly how many and what kind of real world configurations of PDO Authentication exist. The variation reflects the flexibility PDO is offering. 
  
-  * [[plugin:authpdo:moodle|Moodle]] -- an e-learning system [[http://moodle.org]] +  * [[plugin:authpdo:moodle|Moodle]] -- an e-learning system [[https://moodle.org/|moodle.org]] 
-  * [[plugin:authpdo:phpbb3|phpBB3]] -- an open-source bulletin-board system [[http://phpbb.com]] +  * [[plugin:authpdo:phpbb3|phpBB3]] -- an open-source bulletin-board system [[https://www.phpbb.com/|phpbb.com]] 
-  * [[plugin:authpdo:Nextcloud|Nextcloud]] -- a private cloud system [[http://nextcloud.com]] +  * [[plugin:authpdo:Nextcloud|Nextcloud]] -- a private cloud system [[https://nextcloud.com/|nextcloud.com]] 
-  * [[plugin:authpdo:Questions2Answers|Questions2Answers]] -- Q&A Forum [[http://www.question2answer.org/]]+  * [[plugin:authpdo:Questions2Answers|Questions2Answers]] -- Q&A Forum [[http://www.question2answer.org/|question2answer.org]]
    
 +
 ===== Configuration ===== ===== Configuration =====
  
 To configure this plugin, some experience with database queries and the SQL query language is required. Sample configurations for popular systems will soon be provided by the community. To configure this plugin, some experience with database queries and the SQL query language is required. Sample configurations for popular systems will soon be provided by the community.
  
-The configuration consists mostly of SQL statements to access your database. The plugin itself is completely database agnostic. You can use it to access any database supported by PDO - refer to [[http://php.net/manual/en/pdo.drivers.php|PDO Drivers]] to learn more.+The configuration consists mostly of SQL statements to access your database. The plugin itself is completely database agnostic. You can use it to access any database supported by PDO -- refer to [[http://php.net/manual/en/pdo.drivers.php|PDO Drivers]] to learn more.
  
 In most of the statements named PDO placeholders are used (colon prefixed alphanumeric). These represent the actual data that will be inserted into the statement. The PDO driver takes care of proper escaping - you do not have to worry about it. In most of the statements named PDO placeholders are used (colon prefixed alphanumeric). These represent the actual data that will be inserted into the statement. The PDO driver takes care of proper escaping - you do not have to worry about it.
Line 43: Line 45:
  
 Each option below comes with an example that shows how the statement would look for a fictive [[#example database]] given at the end of this page. Each option below comes with an example that shows how the statement would look for a fictive [[#example database]] given at the end of this page.
 +
  
 ==== General Settings ==== ==== General Settings ====
 +
  
 === Option 'debug' === === Option 'debug' ===
  
 This setting will output detailed error messages whenever something goes wrong. You most probably want to enable this during the initial configuration of the plugin. Once everything works you should definitely disable this again as it may leak important information to possible attackers. This setting will output detailed error messages whenever something goes wrong. You most probably want to enable this during the initial configuration of the plugin. Once everything works you should definitely disable this again as it may leak important information to possible attackers.
 +
  
 === Option 'dsn' === === Option 'dsn' ===
Line 66: Line 71:
   * [[http://php.net/manual/en/ref.pdo-pgsql.connection.php|PDO_PGSQL DSN]]   * [[http://php.net/manual/en/ref.pdo-pgsql.connection.php|PDO_PGSQL DSN]]
   * [[http://php.net/manual/en/ref.pdo-sqlite.connection.php|PDO_SQLITE DSN]]   * [[http://php.net/manual/en/ref.pdo-sqlite.connection.php|PDO_SQLITE DSN]]
 +
  
 === Option 'user' === === Option 'user' ===
  
 This option configures the user to use to connect to the database. You can leave it empty for sqlite databases. This option configures the user to use to connect to the database. You can leave it empty for sqlite databases.
 +
  
 === Option 'pass' === === Option 'pass' ===
  
 This is the password for above user. You can leave it empty for sqlite databases. This is the password for above user. You can leave it empty for sqlite databases.
 +
  
 ==== Related Core Settings ==== ==== Related Core Settings ====
Line 79: Line 87:
 There are a couple of settings you most probably want to tune when enabling authpdo: There are a couple of settings you most probably want to tune when enabling authpdo:
  
-  * [[config:authtype|Configuration Setting: authtype]] - enable the plugin here +  * [[config:authtype|Configuration Setting: authtype]] -- enable the plugin here 
-  * [[config:superuser|Configuration Setting: superuser]] - all users are read from your database when enabling authpdo, your super user probably is named differently than your initial local wiki admin +  * [[config:superuser|Configuration Setting: superuser]] -- all users are read from your database when enabling authpdo, your super user probably is named differently than your initial local wiki admin 
-  * [[config:passcrypt|Configuration Setting: passcrypt]] - this setting defines how new passwords are saved in the database, it should match your database's application +  * [[config:passcrypt|Configuration Setting: passcrypt]] -- this setting defines how new passwords are saved in the database, it should match your database's application 
-  * [[config:defaultgroup|Configuration Setting: defaultgroup]] - This group is added by default to all users regardless of the groups that might be pulled from the database. Make sure that you don’t grant more rights than necessary to this group.+  * [[config:defaultgroup|Configuration Setting: defaultgroup]] -- This group is added by default to all users regardless of the groups that might be pulled from the database. Make sure that you don’t grant more rights than necessary to this group.
  
  
Line 88: Line 96:
  
 This plugin gains more capabilities the more of the configuration you fill in. You can leave out configuration at the expense of functionality. However a few statements are required to have minimal login functionality: This plugin gains more capabilities the more of the configuration you fill in. You can leave out configuration at the expense of functionality. However a few statements are required to have minimal login functionality:
 +
  
 === Option 'select-user' === === Option 'select-user' ===
Line 113: Line 122:
  WHERE "login" = :user  WHERE "login" = :user
 </code> </code>
 +
  
 === Option 'select-user-groups' === === Option 'select-user-groups' ===
Line 133: Line 143:
    AND m."uid" = :uid    AND m."uid" = :uid
 </code> </code>
 +
  
 === Option 'check-pass' === === Option 'check-pass' ===
Line 152: Line 163:
  
 Example: Example:
-<code sql>+<code tsql>
 SELECT uid SELECT uid
   FROM user   FROM user
Line 158: Line 169:
    AND pass = MD5(CONCAT(MD5(user), MD5(:clear)))    AND pass = MD5(CONCAT(MD5(user), MD5(:clear)))
 </code> </code>
 +
 +
 ==== Additional SQL Setup ==== ==== Additional SQL Setup ====
  
Line 222: Line 235:
      VALUES (:user, :hash, :name, :mail)      VALUES (:user, :hash, :name, :mail)
 </code> </code>
 +
  
 === Option 'delete-user' === === Option 'delete-user' ===
Line 236: Line 250:
 DELETE FROM "user" WHERE "id" = :uid DELETE FROM "user" WHERE "id" = :uid
 </code> </code>
 +
  
 === Option 'list-users' === === Option 'list-users' ===
Line 243: Line 258:
 ^ Guaranteed Placeholders ^^ ^ Guaranteed Placeholders ^^
 | '':user''    | A ''%'' wrapped search string to search in logins | | '':user''    | A ''%'' wrapped search string to search in logins |
-| '':group''    | A ''%'' wrapped search string to search in group names  |+| '':group''   | A ''%'' wrapped search string to search in group names  |
 | '':name''    | A ''%'' wrapped search string to search in user full names | | '':name''    | A ''%'' wrapped search string to search in user full names |
 | '':mail''    | A ''%'' wrapped search string to search in email addresses   | | '':mail''    | A ''%'' wrapped search string to search in email addresses   |
-| '':start''    | The start offset to limit the results +| '':start''   | The start offset to limit the results 
-| '':limit''    | The wanted number of results +| '':limit''   | The wanted number of results 
-| '':end''    | The end offset of wanted results (start+limit) |+| '':end''     | The end offset of wanted results (start+limit) |
 ^ Mandatory fields to return ^^ ^ Mandatory fields to return ^^
 | ''user''     | The login name | | ''user''     | The login name |
Line 267: Line 282:
    LIMIT :start,:limit    LIMIT :start,:limit
 </code> </code>
 +
  
 === Option 'count-users' === === Option 'count-users' ===
Line 274: Line 290:
 ^ Guaranteed Placeholders ^^ ^ Guaranteed Placeholders ^^
 | '':user''    | A ''%'' wrapped search string to search in logins | | '':user''    | A ''%'' wrapped search string to search in logins |
-| '':group''    | A ''%'' wrapped search string to search in group names  |+| '':group''   | A ''%'' wrapped search string to search in group names  |
 | '':name''    | A ''%'' wrapped search string to search in user full names | | '':name''    | A ''%'' wrapped search string to search in user full names |
 | '':mail''    | A ''%'' wrapped search string to search in email addresses   | | '':mail''    | A ''%'' wrapped search string to search in email addresses   |
 ^ Mandatory fields to return ^^ ^ Mandatory fields to return ^^
-| ''count''     | Number of users | +| ''count''    | Number of users |
  
 <code tsql> <code tsql>
Line 293: Line 308:
    AND U."mail"  LIKE :mail    AND U."mail"  LIKE :mail
 </code> </code>
 +
  
 === Option 'update-user-login' === === Option 'update-user-login' ===
Line 310: Line 326:
  WHERE "id"    = :uid  WHERE "id"    = :uid
 </code> </code>
 +
  
 === Option 'update-user-info' === === Option 'update-user-info' ===
Line 331: Line 348:
  WHERE "id"   = :uid  WHERE "id"   = :uid
 </code> </code>
 +
  
 === Option 'update-user-pass' === === Option 'update-user-pass' ===
Line 350: Line 368:
  WHERE "id"   = :uid  WHERE "id"   = :uid
 </code> </code>
 +
  
 === Option 'insert-group' === === Option 'insert-group' ===
Line 362: Line 381:
      VALUES (:group)      VALUES (:group)
 </code> </code>
 +
  
 === Option 'join-group' === === Option 'join-group' ===
Line 378: Line 398:
      VALUES (:uid, :gid)      VALUES (:uid, :gid)
 </code> </code>
 +
  
 === Option 'leave-group' === === Option 'leave-group' ===
Line 394: Line 415:
         AND "gid" = :gid         AND "gid" = :gid
 </code> </code>
 +
  
 ===== Example Database ===== ===== Example Database =====
Line 401: Line 423:
 {{ :plugin:authpdo-example.png?280}} {{ :plugin:authpdo-example.png?280}}
  
-<code sql>+<code tsql>
 CREATE TABLE user ( CREATE TABLE user (
     "id" INTEGER PRIMARY KEY AUTOINCREMENT,     "id" INTEGER PRIMARY KEY AUTOINCREMENT,
Line 419: Line 441:
 ); );
 </code> </code>
 +
  
 ===== A Warning on MySQL MyISAM ===== ===== A Warning on MySQL MyISAM =====
plugin/authpdo.txt · Last modified: 2020-10-31 18:31 by webtist_hanschur

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki