Jump to content

Extension:OATHAuth: Difference between revisions

From mediawiki.org
Content deleted Content added
m Reverted edits by 2806:2F0:1101:FAF7:75F3:47F0:CFCC:90F6 (talk) to last version by Wladek92
Tag: Rollback
m Reverted edits by Saual123 (talk) to last version by Clump
Tag: Rollback
 
(22 intermediate revisions by 9 users not shown)
Line 12: Line 12:
|version = <translate><!--T:1--> Continuous updates</translate>
|version = <translate><!--T:1--> Continuous updates</translate>
|compatibility policy = rel
|compatibility policy = rel
|mediawiki = 1.29+
|mediawiki =
|description = <translate><!--T:2--> Provides two-factor authentication for logging in</translate>
|description = <translate><!--T:2--> Provides two-factor authentication for logging in</translate>
|download = {{WikimediaDownload|OATHAuth|phab=EOAT}}
|download = {{WikimediaDownload|OATHAuth|phab=EOAT}}
Line 27: Line 27:
<translate><!--T:42--> The <tvar name=1>'''OathAuth'''</tvar> extension provides [[w:Two-factor authentication|two-factor authentication]] support.</translate>
<translate><!--T:42--> The <tvar name=1>'''OathAuth'''</tvar> extension provides [[w:Two-factor authentication|two-factor authentication]] support.</translate>
<translate><!--T:43--> By default, this includes a [[w:Time-based One-time Password Algorithm|time-based one-time password]] (TOTP) implementation that allows users to generate 2FA codes from their phone or desktop app.</translate>
<translate><!--T:43--> By default, this includes a [[w:Time-based One-time Password Algorithm|time-based one-time password]] (TOTP) implementation that allows users to generate 2FA codes from their phone or desktop app.</translate>
<translate><!--T:5--> Client support is available for most feature phones, smartphones and desktops.</translate>
<translate><!--T:5--> Client support is available for most feature phones, smartphones, and desktops.</translate>


{{Note|1=<translate><!--T:6--> This extension has nothing to do with [[w:OAuth|OAuth]], which is a totally different protocol.</translate>|2=reminder}}
{{Note|1=<translate><!--T:6--> This extension has nothing to do with [[w:OAuth|OAuth]], which is a totally different protocol.</translate>|2=reminder}}
Line 35: Line 35:
</translate>
</translate>
<translate><!--T:8--> The help page on [[<tvar name=1>m:Special:MyLanguage/Help:Two-factor authentication</tvar>|Two-factor authentication]] provides information for end users on how to use this extension.</translate>
<translate><!--T:8--> The help page on [[<tvar name=1>m:Special:MyLanguage/Help:Two-factor authentication</tvar>|Two-factor authentication]] provides information for end users on how to use this extension.</translate>
<translate><!--T:9--> However the special page used will also guide users.</translate>
<translate><!--T:9--> However, the special page will also guide users.</translate>


<translate>
<translate>
== Installation == <!--T:10-->
== Installation == <!--T:10-->
</translate>
</translate>
{{warning|There is a bug with this extension where it does not update properly from the web (mw-config) updater and must instead use the [[manual:update.php|update.php]] command line update script ([[phab:T371849]])}}
{{ExtensionInstall
{{ExtensionInstall
|db-update=1
|db-update=1
Line 45: Line 46:
|registration=required
|registration=required
|custom-steps=* [[#Configuration|<translate><!--T:11--> Configure as required.</translate>]]
|custom-steps=* [[#Configuration|<translate><!--T:11--> Configure as required.</translate>]]
* <translate><!--T:49--> It is strongly recommended to setup {{<tvar name=1>ll|object cache</tvar>|caching}} when using OATHAuth.</translate> <translate><!--T:45--> This will improve performance, but also the security of your wiki if you're using OATHAuth.</translate> <translate><!--T:46--> If you are only running one application/web server and have php-apcu installed, and no specific cache configured, MediaWiki will likely fallback to using APCu.</translate> <translate><!--T:47--> If you are using multiple application/web server it is advised to setup {{<tvar name=1>ll|Object cache#Local cluster</tvar>|local cluster}} caching that can be used by all hosts.</translate> <translate><!--T:48--> Examples include <tvar name=1>{{ll|Manual:Memcached|Memcached}}</tvar>.</translate>
* <translate><!--T:49--> It is strongly recommended to setup {{<tvar name=1>ll|object cache</tvar>|caching}} when using OATHAuth.</translate> <translate><!--T:45--> This will improve performance, but also the security of your wiki if you're using OATHAuth.</translate> <translate><!--T:46--> If you are only running one application/web server and have php-apcu installed, and no specific cache configured, MediaWiki will likely fallback to using APCu.</translate> <translate><!--T:47--> If you are using multiple application/web server it is advised to set up {{<tvar name=1>ll|Object cache#Local cluster</tvar>|local cluster}} caching that all hosts can use.</translate> <translate><!--T:48--> Examples include <tvar name=1>{{ll|Manual:Memcached|Memcached}}</tvar>.</translate>
}}
}}


Line 63: Line 64:
<translate><!--T:18--> This tells OATH to accept tokens for a range of effectively <tvar name=1><code>((1 + 2 * $wgOATHAuthWindowRadius) * 30)</code></tvar> seconds.</translate>
<translate><!--T:18--> This tells OATH to accept tokens for a range of effectively <tvar name=1><code>((1 + 2 * $wgOATHAuthWindowRadius) * 30)</code></tvar> seconds.</translate>
<translate><!--T:19--> This range of valid windows is centered around the current time.</translate>
<translate><!--T:19--> This range of valid windows is centered around the current time.</translate>
<translate><!--T:20--> The purpose of this configuration variable is to account for differences between the user's clock and the server's clock.</translate>
<translate><!--T:20--> The purpose of this configuration variable is to account for differences between the user's and server's clock.</translate>
<translate><!--T:21--> However, it is recommended to keep it as low as possible.</translate>
<translate><!--T:21--> However, keeping it as low as possible is recommended.</translate>
|-
|-
| {{phpi|$wgOATHAuthDatabase}}
| {{phpi|$wgOATHAuthDatabase}}
| {{phpi|false}}
| {{phpi|false}}
| <translate><!--T:22--> The database domain.</translate> <translate><!--T:23--> Only used in a multi-database environment.</translate>
| {{deprecated-inline}} <translate><!--T:22--> The database domain.</translate> <translate><!--T:23--> Only used in a multi-database environment.</translate> <translate><!--T:53--> After MediaWiki 1.42, you should use <tvar name=1>{{ll|Manual:$wgVirtualDomainsMapping|$wgVirtualDomainsMapping['virtual-oathauth']}}</tvar> instead of this option.</translate>
|-
|-
| {{phpi|$wgOATHAuthSecret}}
| {{phpi|$wgOATHAuthSecret}}
Line 82: Line 83:
| {{phpi|$wgOATHExclusiveRights}}
| {{phpi|$wgOATHExclusiveRights}}
| <code>[]</code>
| <code>[]</code>
| <translate><!--T:37--> Set of permissions that are revoked from users who did not log in using [[w:Two-factor authentication|two-factor authentication]].</translate>
| <translate><!--T:37--> Set of permissions that are revoked from users who did not login using [[w:Two-factor authentication|two-factor authentication]].</translate>
|-
|-
| {{phpi|$wgOATHRequiredForGroups}}
| {{phpi|$wgOATHRequiredForGroups}}
| <code>[]</code>
| <code>[]</code>
| <translate><!--T:44--> Sets a list of user groups that are required to have [[w:Two-factor authentication|two-factor authentication]] enabled. Use 'user' if you want all logged in users to be required to have two-factor authentication enabled.</translate>
| <translate><!--T:44--> Sets a list of user groups that are required to have [[w:Two-factor authentication|two-factor authentication]] enabled. Use 'user' if you want all logged-in users required to enable two-factor authentication.</translate>
|}
|}


Line 128: Line 129:


<!--T:34-->
<!--T:34-->
In the event that a user both loses their token generator ''and'' the recovery tokens, two-factor authentication may be removed from the user by running the <tvar name=1><code>disableOATHAuthForUser</code></tvar> maintenance script:
If a user loses both their token generator ''and'' the recovery tokens, two-factor authentication may be removed from the user by running the <tvar name=1><code>disableOATHAuthForUser</code></tvar> maintenance script:
</translate>
</translate>


Line 142: Line 143:
<!--T:50-->
<!--T:50-->
Where <tvar name=1>{{tag|user|open}}</tvar> is the name of the user to have 2FA disabled.
Where <tvar name=1>{{tag|user|open}}</tvar> is the name of the user to have 2FA disabled.

== Shared database tables == <!--T:52-->
</translate>
Some Wikis may want to share the 2FA data amongst multiple Wikis.{{ll|Manual:$wgSharedTables|Shared database tables}}, the previous method for doing so is deprecated in MediaWiki 1.42 and later.
<translate><!--T:54--> For new wiki-farm installations where you want users to share their 2FA token amongst multiple wikis, please use <tvar name=1>{{ll|Manual:$wgVirtualDomainsMapping|$wgVirtualDomainsMapping}}</tvar> and the extensions will automatically make its tables use the specified database name.</translate>

<syntaxhighlight lang=php>
$wgVirtualDomainsMapping['virtual-oathauth'] = [ 'db' => 'sharedbname' ]
</syntaxhighlight>

When using shared database tables, i.e., the same set of users for different wikis, add <code>oathauth_devices</code> and <code>oathauth_types</code> to <code>$wgSharedTables</code>.

<syntaxhighlight lang=php>
$wgSharedTables[] = 'oathauth_devices';
$wgSharedTables[] = 'oathauth_types';
</syntaxhighlight>

<translate>


== See also == <!--T:36-->
== See also == <!--T:36-->
Line 149: Line 168:
* {{ll|Extension:WebAuthn}}
* {{ll|Extension:WebAuthn}}
* <translate><!--T:51--> [[:en:Initiative for Open Authentication|Initiative for Open Authentication (OATH)]]</translate>
* <translate><!--T:51--> [[:en:Initiative for Open Authentication|Initiative for Open Authentication (OATH)]]</translate>



{{OnWikimedia}}
{{OnWikimedia}}

Latest revision as of 18:14, 21 September 2024

Not to be confused with Extension:OAuth.
This extension comes with MediaWiki 1.31 and above. Thus you do not have to download it again. However, you still need to follow the other instructions provided.
MediaWiki extensions manual
OATHAuth
Release status: stable
Implementation User rights , Special page , Page action
Description Provides two-factor authentication for logging in
Author(s) Ryan Lane
Latest version Continuous updates
Compatibility policy Snapshots releases along with MediaWiki. Master is not backward compatible.
Database changes Yes
Tables oathauth_users
License GPL-2.0-or-later AND GPL-3.0-or-later
Download
  • $wgOATHAuthWindowRadius
  • $wgOATHRequiredForGroups
  • $wgOATHAuthAccountPrefix
  • $wgOATHExclusiveRights

  • oathauth-enable
  • oathauth-api-all
  • oathauth-disable-for-user
  • oathauth-view-log
  • oathauth-verify-user
Quarterly downloads 75 (Ranked 68th)
Public wikis using 1,459 (Ranked 205th)
Translate the OATHAuth extension if it is available at translatewiki.net
Issues Open tasks · Report a bug

The OathAuth extension provides two-factor authentication support. By default, this includes a time-based one-time password (TOTP) implementation that allows users to generate 2FA codes from their phone or desktop app. Client support is available for most feature phones, smartphones, and desktops.

This extension has nothing to do with OAuth, which is a totally different protocol.

Usage

[edit]

The help page on Two-factor authentication provides information for end users on how to use this extension. However, the special page will also guide users.

Installation

[edit]
Warning Warning: There is a bug with this extension where it does not update properly from the web (mw-config) updater and must instead use the update.php command line update script (phab:T371849)
  • Download and move the extracted OATHAuth folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/OATHAuth
  • Only when installing from Git, run Composer to install PHP dependencies, by issuing composer install --no-dev in the extension directory. (See task T173141 for potential complications.)
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'OATHAuth' );
    
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  • Configure as required.
  • It is strongly recommended to setup caching when using OATHAuth. This will improve performance, but also the security of your wiki if you're using OATHAuth. If you are only running one application/web server and have php-apcu installed, and no specific cache configured, MediaWiki will likely fallback to using APCu. If you are using multiple application/web server it is advised to set up local cluster caching that all hosts can use. Examples include Memcached .
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration

[edit]

Parameters

[edit]
Configuration Flag Default Value Description
$wgOATHAuthWindowRadius 4 The number of token windows in each direction that should be valid.

This tells OATH to accept tokens for a range of effectively ((1 + 2 * $wgOATHAuthWindowRadius) * 30) seconds. This range of valid windows is centered around the current time. The purpose of this configuration variable is to account for differences between the user's and server's clock. However, keeping it as low as possible is recommended.

$wgOATHAuthDatabase false (deprecated) The database domain. Only used in a multi-database environment. After MediaWiki 1.42, you should use $wgVirtualDomainsMapping['virtual-oathauth'] instead of this option.
$wgOATHAuthSecret false The base OATHAuth secret for this wiki from which all encryption keys are derived.

If false, the value of $wgSecretKey is used.

$wgOATHAuthAccountPrefix false The prefix used for the OATHAuth user account name and the issuer used for the account.

If false, the value of $wgSitename is used.

$wgOATHExclusiveRights [] Set of permissions that are revoked from users who did not login using two-factor authentication.
$wgOATHRequiredForGroups [] Sets a list of user groups that are required to have two-factor authentication enabled. Use 'user' if you want all logged-in users required to enable two-factor authentication.

OATHAuth also adds a key to the $wgRateLimits array to define rate limits for authentication attempts:

		'badoath' => [
			'&can-bypass' => false,
			'user' => [ 10, 60 ],
			'user-global' => [ 10, 60 ],
		]

Note that the user-global key is available only since 1.35. Earlier version have to rely on user and perhaps ip-all. See the documentation of $wgRateLimits for details.

User permission

[edit]
Granting access to enable OATHAuth

Users should be given access to the oathauth-enable user right so that they can enable it at Special:OATHAuth (a link to which appears at Special:Preferences).

$wgGroupPermissions['user']['oathauth-enable'] = true;

The above will grant all registered users access to enable OATHAuth.

Administration

[edit]

Resetting a user token

[edit]

If a user loses both their token generator and the recovery tokens, two-factor authentication may be removed from the user by running the disableOATHAuthForUser maintenance script:

MediaWiki version:
1.40
$ ./maintenance/run OATHAuth:disableOATHAuthForUser <user>
MediaWiki version:
1.39
$ php ./extensions/OATHAuth/maintenance/disableOATHAuthForUser.php <user>

Where ‎<user> is the name of the user to have 2FA disabled.

Shared database tables

[edit]

Some Wikis may want to share the 2FA data amongst multiple Wikis.Shared database tables , the previous method for doing so is deprecated in MediaWiki 1.42 and later. For new wiki-farm installations where you want users to share their 2FA token amongst multiple wikis, please use $wgVirtualDomainsMapping and the extensions will automatically make its tables use the specified database name.

$wgVirtualDomainsMapping['virtual-oathauth'] = [ 'db' => 'sharedbname' ]

When using shared database tables, i.e., the same set of users for different wikis, add oathauth_devices and oathauth_types to $wgSharedTables.

$wgSharedTables[] = 'oathauth_devices';
$wgSharedTables[] = 'oathauth_types';


See also

[edit]