项目作者: Digitalroot

项目描述 :
This extension links MediaWiki to phpBB's user table for authentication, and disallows the creation of new accounts in MediaWiki. Users must then log in to the wiki with their phpBB account.
高级语言: PHP
项目地址: git://github.com/Digitalroot/MediaWiki_PHPBB_Auth.git
创建时间: 2013-04-18T21:18:04Z
项目社区:https://github.com/Digitalroot/MediaWiki_PHPBB_Auth

开源协议:

下载


MediaWiki_PHPBB_Auth

This extension links MediaWiki to phpBB’s user table for authentication, and disallows the creation of new accounts in MediaWiki. Users must then log in to the wiki with their phpBB account.

MediaWiki Page: https://www.mediawiki.org/wiki/Extension:PHPBB_Auth

REQUIREMENTS

  • PHP 7.3 or later
  • MySQL 5 or later
  • MediaWiki 1.35 LTS or later (tested on 1.35 and 1.39)
  • phpBB 3.3 (tested on 3.3.3 and 3.3.7)
  • PluggableAuth extension

Version Compatibility Matrix

MediaWiki PluggableAuth MediaWiki_PHPBB_Auth
> 1.35 6.x or 7.x 4.2.0
1.35 5.7 4.0.0
< 1.35 n/a 3.x

INSTALL

Install the PluggableAuth MediaWiki extension.

Extract the package contents into an /extensions/Auth_phpBB directory.

Open LocalSettings.php. Put this at the bottom of the file and edit as needed.
The values in the $wgAuth_Config array below represent the defaults, except
for UseCanonicalCase which was false prior to June 2016, so you only need to
use and set values that differ for your system.

  1. // phpBB User Database Plugin. (Requires MySQL Database)
  2. $wgAuth_Config = [
  3. //=======================================================================
  4. // Required settings
  5. 'PathToPHPBB' => '../phpbb3/', // Path from this file to your phpBB install
  6. 'UserTB' => 'phpbb3_users', // Name of your phpBB user table
  7. 'GroupsTB' => 'phpbb3_groups', // Name of your phpBB groups table
  8. 'User_GroupTB' => 'phpbb3_user_group', // Name of your phpBB user_group table
  9. // Make MediaWiki usernames match the case of the phpBB usernames (except
  10. // with the first letter set to uppercase). Setting this to false causes
  11. // usernames to be all lowercase except for the first character.
  12. // NOTE: Before June 2016 this setting was always false, changing it to
  13. // true on an install where it previously was false will cause users with
  14. // uppercase characters to appear as separate users from their previous
  15. // all-lowercase account!
  16. 'UseCanonicalCase' => true,
  17. //=======================================================================
  18. // Optional settings
  19. // --------------------------------------
  20. // Wiki Group settings
  21. // By default, any valid phpBB user can log in. To require the user to be
  22. // a member of one or more phpBB groups, set this to true.
  23. 'UseWikiGroup' => false,
  24. // phpBB group(s) the plugin checks for membership in when using
  25. // UseWikiGroup = true. Additional groups can be specified by adding
  26. // to the array: ['Wiki', 'SecondGroup']. To log in, the user must be
  27. // a member of at least one of them.
  28. 'WikiGroupName' => ['Wiki'],
  29. // --------------------------------------
  30. // External database settings
  31. // Auth_phpBB assumes the phpBB tables are in the same database as the
  32. // MediaWiki tables. If phpBB is installed in a different MySQL database,
  33. // whether on the same or different host, set these parameters to have
  34. // the plugin connect to that database instead. See the config.php file
  35. // in your phpBB installation for the values.
  36. 'UseExtDatabase' => false,
  37. 'MySQL_Host' => 'localhost',
  38. 'MySQL_Port' => '',
  39. 'MySQL_Database' => '',
  40. 'MySQL_Username' => '',
  41. 'MySQL_Password' => '',
  42. // --------------------------------------
  43. // Alternative username mappings
  44. // Use a custom username profile field in phpBB to create the username for
  45. // the wiki. This is most helpful for phpBB users whose usernames are
  46. // incompatible with MediaWiki username restrictions.
  47. // See the Auth_phpBB README.md for more information on configuring this.
  48. 'UseWikiProfile' => false,
  49. // Name of your phpBB profile data table.
  50. 'ProfileDataTB' => 'phpbb3_profile_fields_data',
  51. // Name of your phpBB custom profile field.
  52. // phpBB prefixes 'pf_' to the custom field name you choose in the UI.
  53. // e.g., "wikiusername" becomes "pf_wikiusername"
  54. 'ProfileFieldName' => 'pf_wikiusername',
  55. // --------------------------------------
  56. // Error messages
  57. // Error message to display to users on a failed login attempt.
  58. // Message text is formatted using wiki markup. An example with a link:
  59. // 'Please register on the [https://some.domain.com/phpbb forums] to login.'
  60. 'LoginMessage' => 'Please register on the forums to login.',
  61. // Error message when a user is not a member of the required phpBB group
  62. 'NoWikiError' => 'You must be a member of the required forum group.',
  63. ];
  64. // load the authentication extensions
  65. wfLoadExtension( 'PluggableAuth' );
  66. wfLoadExtension( 'Auth_phpBB' );

Optional Features

Require phpBB group membership

To restrict wiki login to certain phpBB users, create a group in phpBB, for
instance “Wiki”, and assign users to it. Then update the following two
configuration settings:

  1. $wgAuth_Config['UseWikiGroup'] = true; // Require group membership to login
  2. $wgAuth_Config['WikiGroupName'] = ['Wiki']; // Name of your phpBB group

Custom phpBB-to-MediaWiki username translation

Auth_phpBB will use the phpBB username to create the MediaWiki username.
If UseCanonicalCase is true, the MediaWiki username will match the
case of the phpBB username with the first letter capitalized.

  1. someUserName => SomeUserName

If UseCanonicalCase is false, the MediaWiki username will be set to
the lowercased phpBB username with the first letter capitalized.

  1. someUserName => Someusername

This is unlikely to work for all phpBB users as MediaWiki is more
restrictive on the characters within a username, such as underscores and other
special characters.

To address this, Auth_phpBB can use the value of a custom profile field in
phpBB for the MediaWiki username. Forum administrators can set the value of
the custom profile field to a form that is valid in MediaWiki. Users can use
either their phpBB or the custom profile field value to log in to the wiki.

If this feature is enabled with UseWikiProfile, Auth_phpBB will use the
custom profile field for the MediaWiki username if it is set, otherwise it will
fall back to using the phpBB username as described above.

To create this field, use phpBB ACP to create a custom profile field:

  1. Log into the ACP
  2. Select Users and Groups
  3. Select Custom profile fields
  4. Create a Single text field custom profile field
    1. Name it “wikiusername”
    2. Set “Publicly display profile field” = no
    3. Uncheck all visibility options, except check “Hide profile field”
    4. Set “Field name/title presented to the user” = “Wiki Username”
    5. Set “Field description” = “Forum username translated for wiki username restrictions”
    6. Set “Length of input box” = 20
    7. Set “Maximum number of characters” = 255
    8. Set “Field validation” to “Any character”
    9. Set Language definitions fields to same as field name/title/description above.

Warning: The custom profile field must be hidden to all but the admins because users
could otherwise hijack wiki accounts by entering any username they wish.

Update LocalSettings.php and set the following values:

  1. $wgAuth_Config['UseWikiProfile'] = true;
  2. // Name of your phpBB profile data table.
  3. $wgAuth_Config['ProfileDataTB'] = 'phpbb3_profile_fields_data';
  4. // Name of your phpBB custom profile field.
  5. // phpBB prefixes 'pf_' to the custom field name you choose in the UI.
  6. // e.g., "wikiusername" becomes "pf_wikiusername"
  7. $wgAuth_Config['ProfileFieldName'] = 'pf_wikiusername';

Forum admins can now populate the custom profile field for a user to set their
wikiusername. For example, enter “Under Score” for a user with the name
“Under_Score” because underscores are not allowed in MediaWiki usernames.
Users with phpBB usernames which are also valid MediaWiki usernames do not
need this field set.

Troubleshooting

To debug configuration and authentication issues, enable the debug log group
for the Auth_phpBB component by adding this to your LocalSettings.php:

  1. $wgDebugLogGroups = [
  2. "Auth_phpBB" => "/some/path/mw-debug-Auth_phpBB.log",
  3. ];

Any plugin configuration issues that result in an Exception should output an
error message to the file.

When users login the log will contain the progress of the authentication.
Here’s an example of a successful login using UseWikiProfile and UseWikiGroup:

  1. 2022-01-27 17:09:04: authenticate: looking up phpBB account & WikiProfile for 'TestUser'
  2. 2022-01-27 17:09:04: lookupPhpBBUser: no phpBB username matched 'TestUser'
  3. 2022-01-27 17:09:04: lookupWikiProfile: found WikiProfile 'TestUser' with user_id 862
  4. 2022-01-27 17:09:04: getWikiProfileName: user_id 862 has a WikiProfile of 'TestUser'
  5. 2022-01-27 17:09:04: authenticate: attempting login for 'TestUser' as wiki user 'TestUser'
  6. 2022-01-27 17:09:05: isMemberOfWikiGroup: user_id 862 is a member of 'Wiki'
  7. 2022-01-27 17:09:05: authenticate: user 'TestUser' logged in as wiki user 'TestUser'

If that fails to write out to an error log due to some permission settings
(seen in some hosted configurations) you can enable full MediaWiki debug
messages and disable caching with:

  1. $wgShowExceptionDetails = true;
  2. $wgShowDBErrorBacktrace = true;
  3. $wgEnableParserCache = false;
  4. $wgCachePages = false;

:warning: Remember to disable all debugging options after you are done! :warning: