Go to the documentation of this file.
38 parent::__construct(
'OATH',
'oathauth-enable',
false );
40 $this->OATHRepository = $repository;
56 $form->
getOutput()->setPageTitle( $this->
msg(
'oathauth-enable' ) );
57 $form->
getOutput()->addModules(
'ext.oath.showqrcode' );
58 $form->
getOutput()->addModuleStyles(
'ext.oath.showqrcode.styles' );
83 parent::checkExecutePermissions(
$user );
92 $key = $this->
getRequest()->getSessionData(
'oathauth_key' );
94 if ( $key ===
null ) {
96 $this->
getRequest()->setSessionData(
'oathauth_key', $key );
99 $secret = $key->getSecret();
100 $label =
"{$this->OATHUser->getIssuer()}:{$this->OATHUser->getAccount()}";
101 $qrcodeUrl =
"otpauth://totp/"
102 . rawurlencode( $label )
104 . rawurlencode( $secret )
108 $qrcodeElement = Html::element(
'div', [
109 'data-mw-qrcode-url' => $qrcodeUrl,
110 'class' =>
'mw-display-qrcode',
113 'style' =>
'width: 256px; height: 256px;'
119 'default' => $this->
msg(
'oathauth-step1-test' )->escaped(),
121 'section' =>
'step1',
125 'default' => $qrcodeElement,
127 'section' =>
'step2',
131 'label-message' =>
'oathauth-step2alt',
133 '<strong>' . $this->
msg(
'oathauth-account' )->escaped() .
'</strong><br/>'
135 .
'<strong>' . $this->
msg(
'oathauth-secret' )->escaped() .
'</strong><br/>'
138 'section' =>
'step2',
143 $this->
msg(
'oathauth-scratchtokens' )
146 'section' =>
'step3',
151 'label-message' =>
'oathauth-entertoken',
153 'section' =>
'step4',
157 'default' => $this->
getRequest()->getVal(
'returnto' ),
158 'name' =>
'returnto',
162 'default' => $this->
getRequest()->getVal(
'returntoquery' ),
163 'name' =>
'returntoquery',
175 $key = $this->
getRequest()->getSessionData(
'oathauth_key' );
177 if ( $key->isScratchToken( $formData[
'token'] ) ) {
180 'OATHAuth {user} attempted to enable 2FA using a scratch token from {clientip}', [
185 return [
'oathauth-noscratchforvalidation' ];
187 if ( !$key->verifyToken( $formData[
'token'], $this->OATHUser ) ) {
189 'OATHAuth {user} failed to provide a correct token while enabling 2FA from {clientip}', [
194 return [
'oathauth-failedtovalidateoath' ];
197 $this->
getRequest()->setSessionData(
'oathauth_key',
null );
205 $this->
getOutput()->addWikiMsg(
'oathauth-validatedoath' );
215 foreach ( $resources
as $resource ) {
216 $resourceList .= Html::rawElement(
'li', [], Html::rawElement(
'kbd', [], $resource ) );
218 return Html::rawElement(
'ul', [], $resourceList );
242 return array_map( [ $this,
'tokenFormatterFunction' ], $key->
getScratchTokens() );
252 return implode(
' ', str_split( $token, 4 ) );
checkExecutePermissions(User $user)
Require users to be logged in.
return true to allow those checks to and false if checking is done & $user
msg( $key)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
alterForm(HTMLForm $form)
Set the page title and add JavaScript RL modules.
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
Special page which uses an HTMLForm to handle processing.
createResourceList( $resources)
OATHUserRepository $OATHRepository
getName()
Get the name of this Special Page.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Class representing a two-factor key.
onSubmit(array $formData)
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
getUser()
Shortcut to get the User executing this instance.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
requireLogin( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin')
If the user is not logged in, throws UserNotLoggedIn error.
getRequest()
Get the WebRequest being used for this instance.
getSecretForDisplay(OATHAuthKey $key)
Retrieve the current secret for display purposes.
__construct(OATHUserRepository $repository, OATHUser $user)
Initialize the OATH user based on the current local User object in the context.
tokenFormatterFunction( $token)
Formats a key or scratch token by creating groups of 4 separated by space characters.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getScratchTokensForDisplay(OATHAuthKey $key)
Retrieve current scratch tokens for display purposes.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
setKey(OATHAuthKey $key=null)
Set the key associated with this user.
doesWrites()
Indicates whether this special page may perform database writes.
static newFromRandom()
Make a new key from random values.