llaumgui / mw-auth-flarum
Allow to connect on MediaWiki from Flarum account.
Package info
github.com/llaumgui/mw-auth-flarum
Type:mediawiki-extension
pkg:composer/llaumgui/mw-auth-flarum
Requires
- php: >=8.4
Requires (Dev)
- guzzlehttp/guzzle: ^7.4
- mediawiki/mediawiki-codesniffer: 52.0.2
- mediawiki/mediawiki-phan-config: 0.20.0
- mediawiki/minus-x: 2.0.1
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpunit/phpunit: ^9.6
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Authenticates MediaWiki users against a Flarum account. It supports Flarum 1 and Flarum 2, optional account creation, a minimum post count for new accounts, and optional Flarum 2FA tokens.
Requirements
- MediaWiki 1.43 or newer
- PHP 8.4 or newer
- A reachable Flarum instance
- Flarum API access
Authentication data is provided by Flarum. Password changes and property changes must be performed in Flarum rather than MediaWiki.
Installation
From Git
Clone the extension into MediaWiki's extensions directory:
cd extensions
git clone https://github.com/llaumgui/mw-auth-flarum.git AuthFlarum
Then load the extension from LocalSettings.php:
wfLoadExtension( 'AuthFlarum' );
Configuration
$wgAuthFlarumUri
The base URI of the Flarum instance.
$wgAuthFlarumUri = 'https://forum.example.org';
$wgAuthFlarumAutoCreate
Controls whether a successful Flarum login automatically creates the corresponding MediaWiki account. The default is true.
To allow account creation while preventing users from creating MediaWiki accounts through the normal registration flow:
$wgGroupPermissions['*']['autocreateaccount'] = true; $wgGroupPermissions['*']['createaccount'] = false; $wgGroupPermissions['sysop']['createaccount'] = false; $wgAuthFlarumAutoCreate = true;
$wgAuthFlarumAutoCreateMinPost
Sets the minimum number of Flarum comments required before MediaWiki can create an account. The default is 100.
$wgAuthFlarumAutoCreateMinPost = 100;
Set this to 0 to allow account creation without a minimum comment count.
$wgAuthFlarumEnable2FA
Adds an optional two-factor authentication field to the login form.
$wgAuthFlarumEnable2FA = true;
Enable this setting only when 2FA is configured on the Flarum instance. When enabled, users with 2FA configured must enter their Flarum 2FA token during login.
Example configuration
wfLoadExtension( 'AuthFlarum' ); $wgAuthFlarumUri = 'https://forum.example.org'; $wgAuthFlarumAutoCreate = true; $wgAuthFlarumAutoCreateMinPost = 50; $wgAuthFlarumEnable2FA = true; $wgGroupPermissions['*']['autocreateaccount'] = true; $wgGroupPermissions['*']['createaccount'] = false; $wgGroupPermissions['sysop']['createaccount'] = false;
Development
Install development dependencies and run the project checks:
composer install
composer test
composer phpunit
composer phan
composer phpunit displays the code coverage summary and generates the HTML
report in coverage/index.html.
License
AuthFlarum is licensed under the GNU General Public License v2.0 or later.