Logs a 'login' event for logins via Special:UserLogin
and API action=login. Does not log for implicit login after
account creation and for autologin (e.g. based on an active
CentralAuth global login).
Logs an 'accountcreation' event for account creation via
Special:UserLogin/signup and API action=createaccount. Does not
log for autocreation.
Both successful and unsuccessful attempts are logged, except for
failures that throw exceptions (internal errors + some permission
errors).
Bug: T91701
Change-Id: I101b11d05400b073065da10f1e537412309d9102
+use MediaWiki\Logger\LoggerFactory;
/**
* Unit to authenticate account registration attempts to the current wiki.
/**
* Unit to authenticate account registration attempts to the current wiki.
$loginForm->load();
$status = $loginForm->addNewaccountInternal();
$loginForm->load();
$status = $loginForm->addNewaccountInternal();
+ LoggerFactory::getInstance( 'authmanager' )->info( 'Account creation attempt via API', array(
+ 'event' => 'accountcreation',
+ 'status' => $status,
+ ) );
$result = array();
if ( $status->isGood() ) {
// Success!
$result = array();
if ( $status->isGood() ) {
// Success!
+use MediaWiki\Logger\LoggerFactory;
/**
* Unit to authenticate log-in attempts to the current wiki.
/**
* Unit to authenticate log-in attempts to the current wiki.
}
$this->getResult()->addValue( null, 'login', $result );
}
$this->getResult()->addValue( null, 'login', $result );
+
+ LoggerFactory::getInstance( 'authmanager' )->info( 'Login attempt', array(
+ 'event' => 'login',
+ 'successful' => $authRes === LoginForm::SUCCESS,
+ 'status' => $authRes,
+ ) );
}
public function mustBePosted() {
}
public function mustBePosted() {
* @file
* @ingroup SpecialPage
*/
* @file
* @ingroup SpecialPage
*/
+use MediaWiki\Logger\LoggerFactory;
/**
* Implements Special:UserLogin
/**
* Implements Special:UserLogin
}
$status = $this->addNewAccountInternal();
}
$status = $this->addNewAccountInternal();
+ LoggerFactory::getInstance( 'authmanager' )->info( 'Account creation attempt with mailed password', array(
+ 'event' => 'accountcreation',
+ 'status' => $status,
+ ) );
if ( !$status->isGood() ) {
$error = $status->getMessage();
$this->mainLoginForm( $error->toString() );
if ( !$status->isGood() ) {
$error = $status->getMessage();
$this->mainLoginForm( $error->toString() );
# Create the account and abort if there's a problem doing so
$status = $this->addNewAccountInternal();
# Create the account and abort if there's a problem doing so
$status = $this->addNewAccountInternal();
+ LoggerFactory::getInstance( 'authmanager' )->info( 'Account creation attempt', array(
+ 'event' => 'accountcreation',
+ 'status' => $status,
+ ) );
+
if ( !$status->isGood() ) {
$error = $status->getMessage();
$this->mainLoginForm( $error->toString() );
if ( !$status->isGood() ) {
$error = $status->getMessage();
$this->mainLoginForm( $error->toString() );
global $wgMemc, $wgLang, $wgSecureLogin, $wgPasswordAttemptThrottle,
$wgInvalidPasswordReset;
global $wgMemc, $wgLang, $wgSecureLogin, $wgPasswordAttemptThrottle,
$wgInvalidPasswordReset;
- switch ( $this->authenticateUserData() ) {
+ $status = $this->authenticateUserData();
+ switch ( $status ) {
case self::SUCCESS:
# We've verified now, update the real record
$user = $this->getUser();
case self::SUCCESS:
# We've verified now, update the real record
$user = $this->getUser();
default:
throw new MWException( 'Unhandled case value' );
}
default:
throw new MWException( 'Unhandled case value' );
}
+
+ LoggerFactory::getInstance( 'authmanager' )->info( 'Login attempt', array(
+ 'event' => 'login',
+ 'successful' => $status === self::SUCCESS,
+ 'status' => $status,
+ ) );