Commit graph

1177 commits

Author SHA1 Message Date
Aaron Schulz
d02b98b8f3 Updated key WANObjectCache::delete() callers to avoid races
* They now issue the delete() write before COMMIT of
  the relevant DB (or immediately if no trx is active)
* This can avoid some stale write race conditions
* Updated the WAN cache delete() docs

Change-Id: Id54887976051120b76528070d5f2ceb357d57897
2015-09-26 18:02:00 +00:00
Skizzerz
8e8826b768 Fix PHP notice when logging the result of a DNS blacklist check.
When the array syntax is used for the DNS blacklist, PHP throws a notice about array to string
conversion. This change ensures that the correct string name is used regardless of what type of
blacklist entry is used.

Change-Id: I2511a8320474a02d8f321d04f005bb9d18fb15b3
2015-09-23 13:28:01 +00:00
Kunal Mehta
bdf3f3e2d7 Add the performer to the UserRightsChanged hook
This allows extensions (e.g. Echo) to detect who made the change without
relying upon $wgUser. It also allows for differentiation between
autopromotion entries which will pass in `false` as the performer.

Change-Id: Idebd78b54dcea1bdc84c83f402e87b240ab4ade1
2015-09-22 10:58:20 -07:00
jenkins-bot
e491904eef Merge "Add new authentication-related hooks (and remove one) replacing some AuthPlugin methods" 2015-09-22 07:32:03 +00:00
Brad Jorsch
37062a0c0d Add new authentication-related hooks (and remove one) replacing some AuthPlugin methods
* LocalUserCreated: Replaces AuthPlugin::initUser()
* UserGroupsChanged: Replaces AuthPlugin::updateExternalDBGroups()
** The similar UserRights hook is deprecated, mainly to get rid of the
   passing of $user by reference.
* UserIsHidden: Replaces AuthPluginUser::isHidden()
* UserIsLocked: Replaces AuthPluginUser::isLocked()
* UserLoggedIn: Replaces AuthPlugin::updateUser()

Also, AuthPlugin::updateExternalDB() is deprecated in favor of the
existing UserSaveSettings hook.

Also, 'ResetSessionID' has been removed. Nothing uses it, I don't know
why I even added it in the first place.

Also, replacing the User object passed to AuthPlugin::initUser() and
AuthPlugin::updateUser() will now raise a warning.

Change-Id: If7474cfb26a29b11c2e78147069419ca3b1cba95
2015-09-18 10:46:13 -04:00
jenkins-bot
b60dded47b Merge "Use User::equals() where applicable in the class" 2015-09-18 09:08:27 +00:00
Michał Roszka
5668f2347a Use User::equals() where applicable in the class
It is a minor cleanup operation. I replaced a comparison of user 'mId'
with a corresponding 'User::equals()' call.

Change-Id: I89dea55789f343e794429c38934c263168ef608d
2015-09-18 08:54:28 +00:00
Aaron Schulz
d30ada2ad1 Removed clearSharedCache() hack in User.php
* WAN cache key salting/tombstones makes this overkill now

Change-Id: I078daacc5d2987858d720677f11e9828d71021e2
2015-09-08 17:02:39 -07:00
jenkins-bot
04ebf62661 Merge "Default the "watchlisttoken" value to a derived HMAC value" 2015-09-08 13:41:17 +00:00
Aaron Schulz
7389dd7676 Avoid some unused parameter IDEA errors in User.php
Change-Id: I75e56ab02af6aee5dbed1735ae8a3a415094508d
2015-09-04 12:13:32 -07:00
Aaron Schulz
cd027382e0 Default the "watchlisttoken" value to a derived HMAC value
* This got created if unset on API or GUI preferences access,
  which leads to writes on GET requests. Try to avoid that
  deriving it from user_token, unless overriden. This also
  means that changing the password always resets the key,
  which is how these things work on most sites anyway.
* The whole getTokenFromOption() method is deprecated, and
  this functionality is already in OAuth.

Bug: T92357
Change-Id: I96c0d6f6e535e67545049f01205430249eea8da0
2015-09-03 06:22:30 +00:00
Aaron Schulz
a15cf05188 Optimized notification timestamp clearing
* Hint that mariadb can avoid scanning already NULL rows since
  we want to set them all to NULL. This lets the index with the
  timestamp be used, which avoids logs of scanning for users with
  many rows. For non-parallel replication, this also avoids slave
  lag in particular.

Bug: T107923
Change-Id: I8cded5476ef6adb2f8fea57239afd6e9b2a49708
2015-08-12 15:37:57 -07:00
Aaron Schulz
3f24d1e348 Make Special:ConfirmEmail load the user from the master
* This can help guard against stale reads if the user was
  created or changed a second ago.

Bug: T105896
Change-Id: Ib2a59762cd8f4a4b7ad86d0700f186bee1d5b2d1
2015-08-04 18:40:38 +00:00
Aaron Schulz
dc713626b1 Fixed missing space in User CAS exception
Change-Id: Ibb34a3bd33c1eb92a2e2787a7e2402615ef02ccd
2015-07-23 13:51:37 -07:00
Kunal Mehta
c8ac9622ea Clean up UserMailer::send() parameters
$replyto and $contentType should now be passed as an array of $options.
This will make it easier to add more options in the future without
having a long list of optional parameters.

Change-Id: I2c38bb438bd01e0ed2552024a40311f3e8e2dc08
2015-07-20 21:34:44 -07:00
Aaron Schulz
64bf3a12b5 Defer user_newtalk updates in clearNotification() to post-send
* Also only issue DELETE if notifications exist. Previously,
  this would issue a DELETE for all self talk page views.

Bug: T92007
Change-Id: Ifef11c9e5175d68d9615e59e2ed7de2f2c57bde1
2015-07-17 21:56:36 +00:00
jenkins-bot
36f21b89ca Merge "Tweaked User::READ_LOCKING to use LOCK IN SHARE MODE" 2015-07-16 22:26:32 +00:00
jenkins-bot
eeb2329ac3 Merge "Upgraded User::saveSettings logged errors to exceptions" 2015-07-15 07:36:56 +00:00
jenkins-bot
8352deb985 Merge "Fixed User class IDE warnings" 2015-07-15 07:30:21 +00:00
csteipp
6a69a4eb73 Add "purpose" to password validity check
Allow callers to specify why they are checking a passwords validity, so
some checks can be modified. Only check the default policy on creation,
since the account doesn't exist it's not a member of any groups.

Bug: T104615
Change-Id: I56b66002562aaa1493d94a90309bc8e4ae3841c8
2015-07-14 20:04:23 +00:00
Aaron Schulz
939dbec87a Tweaked User::READ_LOCKING to use LOCK IN SHARE MODE
* This better alignes with IDBAccessObject docs and
  still locks out INSERTs

Change-Id: Ib8713938e0afa14bee6f90bc51d6331eaf356447
2015-07-14 11:13:05 -07:00
Legoktm
4c528691e1 Revert "Add 'AuthPluginStrict' log to identify users who are unable to authenticate"
Does not work as it will also log failed login attempts due
to a wrong password.

This reverts commit 9a97a7530f.

Change-Id: I6abd19da4e6939315a7fe6f7debe5227b68d38a7
2015-07-13 23:07:02 +00:00
Aaron Schulz
e47c2e0c95 Fixed User class IDE warnings
Change-Id: I68c30fd81a266aa1acdf74162bfa864b67922347
2015-07-13 14:30:50 -07:00
Kunal Mehta
9a97a7530f Add 'AuthPluginStrict' log to identify users who are unable to authenticate
To be able to identify any users who are unable to log in when switching
from allowing local authentication to strict.

Change-Id: I2ebdccdad9c7794d1c1b13db6a646a43bc770c4e
2015-07-13 17:37:35 +00:00
jenkins-bot
05fce41bb7 Merge "Made the prior user existence check in LoginForm use DB_MASTER" 2015-07-11 00:37:31 +00:00
Aaron Schulz
e0ee2cdc4b Fixed bitfield check in User::loadFromId()
* READ_LOCKING is a composite field, so it can yeild 00, 01,
  10, or 11 for the relevant two bits. Only one of them should
  pass the check to avoid locking and snapshot breaking queries
  for no reason.

Change-Id: Ief04ac20c7639fcf79443a3ee39a471542a59551
2015-07-10 16:52:28 -07:00
Aaron Schulz
08698e48e8 Made the prior user existence check in LoginForm use DB_MASTER
* This helps if multiple account creation attempts were made in a row
  and the slave selected was lagged (either too much for Chronology
  Protector or the user did not resend the cookies to link the session).
* The locking also better handles concurrent attempt to make another
  account, especially with CentralAuth trying to make external accounts.
  This assumes that the rate of concurrent account creations with close
  names is low enough given trx speed to avoid gap locking issues. This
  will need to be confirmed with low error log rates to be sure.
* The User::idFromName() method now includes a $flags parameter.

Bug: T104615
Change-Id: I8385526a19efc528a016ad2bbf376b377138966b
2015-07-10 16:45:28 -07:00
Aaron Schulz
ed1b8d3a0e Upgraded User::saveSettings logged errors to exceptions
* This gives more visibility and the error rate is not
  extreme (and mostly affects certain users due to
  usage patterns).

Change-Id: I3eae28a584e4db8ae40ae80087a97c416b3bd3e8
2015-07-10 01:41:29 -07:00
Aaron Schulz
84758e6f10 Made WANObjectCache::getCheckKey() automatically init the key
* This still allows If-Modified-Since logic but does not
  need to broadcast initialization values just because a
  key fell out of cache. The value can differ between DCs
  anyway via skew, this just lets them drift more. Actual
  purge events are still broadcasted, which is what matters.
* The User class has now been simplified given this change.
* Added more general comments to getCheckKeyTime().

Change-Id: Ic1f4bbb1947e0d1dd47499c9e9dc86991c30580c
2015-07-02 07:13:22 +00:00
jenkins-bot
b42a5e851c Merge "Replace some MWException usage in User" 2015-07-01 04:19:14 +00:00
Aaron Schulz
35fb85ba0b Replace some MWException usage in User
Change-Id: I61dbd6223354530311c497ad0f45ed49a573d0cb
2015-06-30 21:07:48 -07:00
Aaron Schulz
0aa93ad8b8 Made User::loadFromId() use READ_NORMAL by default
* This covers CentralAuthHooks::onUserLoadFromSession()
  among other cases (OAuth user loading, ect).

Bug: T92357
Change-Id: I9c90027d8852ff8c1d626c03b5dbd765b95b0ce1
2015-06-25 20:16:55 +00:00
Sam Smith
16cea35d85 Configure logged in session length independently
* Add the $wgExtendedLoginCookies configuration variable, which defines
  the set of login cookies that can have their lifetime configured
  independently
* Add the $wgExtendedLoginCookieExpiration configuration variable, which
  dictates when the extended lifetime login cookies expire
* Default $wgExtendedLoginCookieExpiration to null so that the current
  behaviour is unaffected

Bug: T68699
Change-Id: I0cc24524e4d7d9d1d21c9fa8a28c7c76b677b96c
2015-06-23 19:31:20 -04:00
Aaron Schulz
dd42294d29 Made User generally use DB_SLAVE by default
* By default, users will load from the slave unless
  the thread did a recent DB write. This is to handle
  changes within a request.
* ChronologyProtector should avoid staleness in common
  cases, and the CAS check on user_touched is a final
  barrier to block stale user object updates.
* Note that passwords are not cached, so they hit the
  DB when ever needed. Passwords now load from slaves
  when possible, instead of the master.
* This should get the code closer to handling user
  login and logged in users when the master is down.
* Fixed loadFromId() when READ_LOCKING is used.
* Also addressed TODO comment in load().

Bug: T92357
Change-Id: I0a8bdab720c19fe3fc2381799ae2e90ff09bb4cf
2015-06-16 08:29:06 -07:00
jenkins-bot
9ce9ca079f Merge "Password validity by policy per group" 2015-06-10 17:46:20 +00:00
csteipp
1a20dc9362 Password validity by policy per group
Make password policies defined in a configurable policy, which is
defined by group. A user's password policy will be the maximum of
each group policy that the user belongs to.

Bug: T94774
Change-Id: Iad8e49ffcffed38df6293db0ef31a227d3962003
2015-06-10 10:34:17 -07:00
Aaron Schulz
fd5bde60ec Fixed "wfTimestamp() fed bogus time value" errors
* This broke OutputPage::checkLastModified() as the touched time was false

Change-Id: I118d3ddf07c7b69ad269f3aee0c70ab4159df192
2015-06-09 18:47:49 -07:00
jenkins-bot
6378a12c88 Merge "Made User::touch no longer call load()" 2015-06-03 07:47:00 +00:00
Aaron Schulz
5399fba68b Use less fuzzy User::getDBTouched() in ApiStashEdit::getStashKey()
* The getTouched() value can bump more often or vary in DCs

Change-Id: Idffa22c9dde7c7950943b104ed61f5779636b7e7
2015-06-02 20:31:14 +00:00
Aaron Schulz
833bdbab37 Fixed $flags bit operation precedence fail in User::loadFromDatabase()
* The bug made READ_LATEST also act as READ_LOCKING

Bug: T100577
Bug: T100869
Bug: T98706
Change-Id: I85092970c236fc4482371216b9f6592c49a27942
2015-06-02 18:39:37 +00:00
Aaron Schulz
5b2670b31b Made User::touch no longer call load()
* Just reset mQuickTouched instead of guessing a new value
  in touch() for simplicity

Change-Id: Ibfe551cf061919ab18c4ff634d8db8f3c0eaf0a5
2015-06-02 17:24:48 +00:00
Ori Livneh
05aac977eb User::clearSharedCache: don't load the full user record for just the ID
Rather than call $this->load() unconditionally, get just the ID via
$this->getId(), potentially saving us a database lookup.

Change-Id: Ifa3b96956a1d66d3e877573ff01970758fad8790
2015-05-19 15:45:46 -07:00
jenkins-bot
d1150378f1 Merge "Converted User object cache to the WAN cache" 2015-05-18 06:38:06 +00:00
jenkins-bot
fe5c31a59b Merge "Converted User touched key to using the WAN cache" 2015-05-11 16:52:48 +00:00
jenkins-bot
d892c0f86f Merge "Made wl_notificationtimestamp updates able to use queues" 2015-05-04 18:35:45 +00:00
Aaron Schulz
b614290f73 Converted User object cache to the WAN cache
Bug: T93141
Change-Id: I93dc5367d85d661bd5bdce29f4665bb8cd21ba02
2015-04-30 01:30:06 +00:00
Aaron Schulz
4a8da41079 Converted User touched key to using the WAN cache
Bug: T93141
Change-Id: Id5478d3007bde3f621b4c3ffe9950a654e0ac30a
2015-04-30 01:30:00 +00:00
Aaron Schulz
76f961097a Remove cache use in setNewtalk, as nothing reads from that
Change-Id: Ia094fa99be49816b48e35aeb695b5d9558fd1d28
2015-04-27 16:45:58 -07:00
Aaron Schulz
836ad263c3 Made wl_notificationtimestamp updates able to use queues
* This adds a wgActivityUpdatesUseJobQueue setting, which lets
  these updates work via the job queue, rather than direct DB
  master updates.

Bug: T91284
Change-Id: Ie60e20162fd833e64d81763a6aa1dc3faf2162f3
2015-04-25 14:47:42 -07:00
jenkins-bot
786a37c577 Merge "Added CAS logic to User::addAutopromoteOnceGroups" 2015-04-21 15:43:54 +00:00