Add user right for enabling two-factor auth

Make new right oathauth-enable that the user must have to enable two
factor authentication (disabling and logging in, of course, are still
allowed).

Bug: T100376
Change-Id: I18d43f8b2cf2c2ce9c2309a43961686498b5c999
This commit is contained in:
Tyler Romeo 2015-05-26 02:08:47 +02:00 committed by csteipp
parent 5ffdd6078b
commit 4e9ad22469
5 changed files with 19 additions and 3 deletions

View file

@ -142,6 +142,10 @@ class OATHAuthHooks {
* @return bool
*/
public static function manageOATH( User $user, array &$preferences ) {
if ( !$user->isAllowed( 'oathauth-enable' ) ) {
return true;
}
$oathUser = self::getOATHUserRepository()->findByUser( $user );
$title = SpecialPage::getTitleFor( 'OATH' );

View file

@ -69,5 +69,13 @@
"SpecialPages": {
"OATH": "SpecialOATH"
},
"AvailableRights": [
"oathauth-enable"
],
"GroupPermissions": {
"*": {
"oathauth-enable": true
}
},
"manifest_version": 1
}

View file

@ -42,5 +42,7 @@
"oathauth-step2alt": "Or enter the secret manually:",
"oathauth-step3": "Step 3: Write down the scratch codes",
"oathauth-step4": "Step 4: Verification",
"oathauth-entertoken": "Enter a code from your mobile app to verify:"
"oathauth-entertoken": "Enter a code from your mobile app to verify:",
"right-oathauth-enable": "Enable two-factor authentication",
"action-oathauth-enable": "enable two-factor authentication"
}

View file

@ -46,5 +46,7 @@
"oathauth-step2alt": "Label for information on how to manually do step 2 on Special:OATH",
"oathauth-step3": "Label for step 3 information on Special:OATH",
"oathauth-step4": "Label for step 4 information on Special:OATH",
"oathauth-entertoken": "Label on input field on Special:OATH asking user to enter token"
"oathauth-entertoken": "Label on input field on Special:OATH asking user to enter token",
"right-oathauth-enable": "{{doc-right|oathauth-enable}}",
"action-oathauth-enable": "{{doc-action|oathauth-enable}}"
}

View file

@ -20,7 +20,7 @@ class SpecialOATHEnable extends FormSpecialPage {
* @param OATHUser $user
*/
public function __construct( OATHUserRepository $repository, OATHUser $user ) {
parent::__construct( 'OATH', '', false );
parent::__construct( 'OATH', 'oathauth-enable', false );
$this->OATHRepository = $repository;
$this->OATHUser = $user;