mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/OATHAuth
synced 2024-11-28 02:00:06 +00:00
Declare issuer name in QR code when setting up 2FA
The issuer name is an optional but important feature that allows the user to differentiate between different accounts used in the same authenticator app. While we currently use a prefix in the user account name, declaring an issuer makes it easier for the user to differentiate. Bug: T150596 Change-Id: I741dd671e79e0326dfe97bdaaf63b3997960d115
This commit is contained in:
parent
e317bf4610
commit
0b460de458
14
OATHUser.php
14
OATHUser.php
|
@ -31,13 +31,19 @@ class OATHUser {
|
||||||
/**
|
/**
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public function getAccount() {
|
public function getIssuer() {
|
||||||
global $wgSitename, $wgOATHAuthAccountPrefix;
|
global $wgSitename, $wgOATHAuthAccountPrefix;
|
||||||
|
|
||||||
if ( $wgOATHAuthAccountPrefix !== false ) {
|
if ( $wgOATHAuthAccountPrefix !== false ) {
|
||||||
return "$wgOATHAuthAccountPrefix:{$this->user->getName()}";
|
return $wgOATHAuthAccountPrefix;
|
||||||
}
|
}
|
||||||
return "$wgSitename:{$this->user->getName()}";
|
return $wgSitename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public function getAccount() {
|
||||||
|
return $this->user->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -80,10 +80,13 @@ class SpecialOATHEnable extends FormSpecialPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
$secret = $key->getSecret();
|
$secret = $key->getSecret();
|
||||||
|
$label = "{$this->OATHUser->getIssuer()}:{$this->OATHUser->getAccount()}";
|
||||||
$qrcodeUrl = "otpauth://totp/"
|
$qrcodeUrl = "otpauth://totp/"
|
||||||
. rawurlencode( $this->OATHUser->getAccount() )
|
. rawurlencode( $label )
|
||||||
. "?secret="
|
. "?secret="
|
||||||
. rawurlencode( $secret );
|
. rawurlencode( $secret )
|
||||||
|
. "&issuer="
|
||||||
|
. rawurlencode( $this->OATHUser->getIssuer() );
|
||||||
|
|
||||||
$qrcodeElement = Html::element( 'div', [
|
$qrcodeElement = Html::element( 'div', [
|
||||||
'data-mw-qrcode-url' => $qrcodeUrl,
|
'data-mw-qrcode-url' => $qrcodeUrl,
|
||||||
|
|
Loading…
Reference in a new issue