r103467 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103466‎ | r103467 | r103468 >
Date:15:16, 17 November 2011
Author:mah
Status:reverted (Comments)
Tags:core 
Comment:
Adapt and re-apply Michael Newton's patch from Bug 24464 - Execute
LoginAuthenticateAudit hook more often.

Also updated release notes.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -1212,8 +1212,10 @@
12131213 - wrap String Wrap the message in html (usually something like "<div ...>$1</div>").
12141214 - flags Integer display flags (NO_ACTION_LINK,NO_EXTRA_USER_LINKS)
12151215
1216 -'LoginAuthenticateAudit': a login attempt for a valid user account either
1217 -succeeded or failed. No return data is accepted; this hook is for auditing only.
 1216+'LoginAuthenticateAudit': a login attempt either succeeded or
 1217+failed. This may be called before the User object is populated, so a
 1218+user object equivalent to an anonymous user. No return data is
 1219+accepted; this hook is for auditing only.
12181220 $user: the User object being authenticated against
12191221 $password: the password being submitted and found wanting
12201222 $retval: a LoginForm class constant with authenticateUserData() return
Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -11,6 +11,9 @@
1212 production.
1313
1414 === Configuration changes in 1.19 ===
 15+* Changed LoginAuthenticateAudit hook so that it may be called before a
 16+ valid user is available. In those cases, an anonymouse user object
 17+ will be supplied
1518 * Removed SkinTemplateSetupPageCss hook; use BeforePageDisplay instead.
1619 * (bug 27132) movefile right granted by default to registered users.
1720 * Default cookie lifetime ($wgCookieExpiration) is increased to 180 days.
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -475,6 +475,7 @@
476476 $this->load();
477477
478478 if ( $this->mUsername == '' ) {
 479+ wfRunHooks( 'LoginAuthenticateAudit', array( new User, $this->mPassword, self::NO_NAME ) );
479480 return self::NO_NAME;
480481 }
481482
@@ -486,20 +487,24 @@
487488 // If the user doesn't have a login token yet, set one.
488489 if ( !self::getLoginToken() ) {
489490 self::setLoginToken();
 491+ wfRunHooks( 'LoginAuthenticateAudit', array( new User, $this->mPassword, self::NEED_TOKEN ) );
490492 return self::NEED_TOKEN;
491493 }
492494 // If the user didn't pass a login token, tell them we need one
493495 if ( !$this->mToken ) {
 496+ wfRunHooks( 'LoginAuthenticateAudit', array( new User, $this->mPassword, self::NEED_TOKEN ) );
494497 return self::NEED_TOKEN;
495498 }
496499
497500 $throttleCount = self::incLoginThrottle( $this->mUsername );
498501 if ( $throttleCount === true ) {
 502+ wfRunHooks( 'LoginAuthenticateAudit', array( new User, $this->mPassword, self::THROTTLED ) );
499503 return self::THROTTLED;
500504 }
501505
502506 // Validate the login token
503507 if ( $this->mToken !== self::getLoginToken() ) {
 508+ wfRunHooks( 'LoginAuthenticateAudit', array( new User, $this->mPassword, self::WRONG_TOKEN ) );
504509 return self::WRONG_TOKEN;
505510 }
506511
@@ -520,6 +525,7 @@
521526 # user choose a different wiki name.
522527 $u = User::newFromName( $this->mUsername );
523528 if( !( $u instanceof User ) || !User::isUsableName( $u->getName() ) ) {
 529+ wfRunHooks( 'LoginAuthenticateAudit', array( $u, $this->mPassword, self::ILLEGAL ) );
524530 return self::ILLEGAL;
525531 }
526532
@@ -527,6 +533,7 @@
528534 if ( 0 == $u->getID() ) {
529535 $status = $this->attemptAutoCreate( $u );
530536 if ( $status !== self::SUCCESS ) {
 537+ wfRunHooks( 'LoginAuthenticateAudit', array( $u, $this->mPassword, $status ) );
531538 return $status;
532539 } else {
533540 $isAutoCreated = true;
@@ -547,6 +554,7 @@
548555 // Give general extensions, such as a captcha, a chance to abort logins
549556 $abort = self::ABORTED;
550557 if( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword, &$abort, &$this->mAbortLoginErrorMsg ) ) ) {
 558+ wfRunHooks( 'LoginAuthenticateAudit', array( $u, $this->mPassword, $abort ) );
551559 return $abort;
552560 }
553561

Follow-up revisions

RevisionCommit summaryAuthorDate
r106446followup r103467 - Make sure we pass a user object when we call LoginAuthenti...mah17:19, 16 December 2011
r110797Revert r103467, r106446 (bug 24464: calling LoginAuthenticateAudit hook more ...demon22:44, 6 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103396Applying Michael Newton's patch from Bug 24464 - Execute...mah22:24, 16 November 2011

Comments

#Comment by Reach Out to the Truth (talk | contribs)   19:49, 17 November 2011

"anonymouse"?

#Comment by Krinkle (talk | contribs)   22:53, 18 November 2011

*peep* :P

#Comment by 😂 (talk | contribs)   20:22, 18 November 2011

Rather than passing a useless anonymous object, how about just passing null?

#Comment by Platonides (talk | contribs)   21:00, 18 November 2011

That new user seems a bug source. If you have to provide a user, why not the context, unauthenticated, one?

#Comment by 😂 (talk | contribs)   22:51, 18 November 2011

That makes sense too.

#Comment by MarkAHershberger (talk | contribs)   21:39, 18 November 2011

My thinking was that passing a null would cause bugs with hook users that were depending on an object being passed in. By passing an anonymous user, they get an object that they expect and can treat like a user.

#Comment by Nikerabbit (talk | contribs)   09:52, 15 December 2011
+wfRunHooks( 'LoginAuthenticateAudit', array( $u, $this->mPassword, self::ILLEGAL ) );

$u is not necessarily an user object here.

#Comment by MarkAHershberger (talk | contribs)   17:13, 16 December 2011

good catch. Thanks!

#Comment by Aaron Schulz (talk | contribs)   00:54, 21 January 2012

FIXME'd per chad.

#Comment by MarkAHershberger (talk | contribs)   18:45, 24 January 2012

If I'm not mistaken, I already fixed that issue in r103467

#Comment by Aaron Schulz (talk | contribs)   00:33, 2 February 2012

No, it is still passing "new User".

Status & tagging log