Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| RegistrationCallback | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| onRegistration | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | declare( strict_types=1 ); |
| 3 | /* |
| 4 | * @license GPL-2.0-or-later |
| 5 | * @file |
| 6 | */ |
| 7 | |
| 8 | namespace MediaWiki\Extension\OATHAuth\Hook; |
| 9 | |
| 10 | class RegistrationCallback { |
| 11 | |
| 12 | public static function onRegistration(): void { |
| 13 | global $wgOATHAuthEnforce2FAForAll, $wgRestrictedGroups; |
| 14 | |
| 15 | // Following the pattern in TorBlock, this is a string |
| 16 | define( 'APCOND_OATH_HAS2FA', 'oath.has_2fa' ); |
| 17 | |
| 18 | if ( $wgOATHAuthEnforce2FAForAll ) { |
| 19 | // If 2FA is enforced for all users, require 2FA for the 'user' group |
| 20 | if ( isset( $wgRestrictedGroups['user']['memberConditions'] ) ) { |
| 21 | $wgRestrictedGroups['user']['memberConditions'] = [ |
| 22 | '&', |
| 23 | APCOND_OATH_HAS2FA, |
| 24 | $wgRestrictedGroups['user']['memberConditions'] |
| 25 | ]; |
| 26 | } else { |
| 27 | $wgRestrictedGroups['user']['memberConditions'] = [ APCOND_OATH_HAS2FA ]; |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | } |