Commit graph

135 commits

Author SHA1 Message Date
Timo Tijhof
57290f6926 user: Minor clean up of User::isLocallyBlockedProxy()
Change-Id: If8bcb2f26f14ce04ee23fb9500be95c8cdf1a967
2016-12-16 22:11:49 -08:00
Max Semenik
866884763f Remove deprecated function User::isPasswordReminderThrottled()
Deprecated and stubbed in 1.27, only throws exceptions these days.
The only user in core or extensions is AjaxLogin which is completely
broken anyway (T153385).

Change-Id: I298fbc3e65d98b3af2f3cfef3d9884e277e6717c
2016-12-16 12:55:30 -08:00
Max Semenik
12d13acde4 Remove 2 deprecated functions from class User
They've been deprecated in 1.27 and only throw exceptions
no callers in core or extensions.

Change-Id: I1ccfa39c287b640b435a075449e4674daf8d24e7
2016-12-16 12:54:04 -08:00
Brad Jorsch
01a3b2b0bf Add the concept of "system blocks"
Blocks made for configured proxies, dnsbls, or the configured range
soft-blocks being added in I6c11a6b9 aren't real blocks stored in the
database. Let's actually flag these blocks as such and use a more
appropriate message when displaying them to the user.

Change-Id: I697e3eec2520792e98c193200c2b1c28c35bf382
2016-12-16 12:30:03 -05:00
Thiemo Mättig
00c3f09566 Remove empty lines from PHP and JavaScript comment blocks
This is a pure documentation change. It mostly removes empty lines from
comments (and entirely empty comments), as well as adds a few missing
documentation blocks and fixes a minor mistake. I hope it's ok to have
this in one patch. I can split it, please tell me.

Change-Id: I9668338602ac77b903ab6b02ff56bd52743c37c4
2016-12-09 09:01:06 +00:00
Brad Jorsch
901d575b54 Set token properly when creating in User::newSystemUser()
Otherwise callers that don't use 'steal' is going to break because it'll
think it needs to steal the user.

If such a user exists on a wiki, it can be fixed by setting the token to
the invalid token. The easiest way is probably to just call
User::newSystemUser( $name, [ 'steal' => true ] ) with eval.php.

Note there's no way for anyone to use these users unless they steal the
token from the DB, since they still don't have a password, email, or any
other method of authentication or account recovery set up.

Change-Id: I9efd2d2f5fffb4e4411a894f9514cdf2c66663a9
2016-12-02 17:12:33 +00:00
Reedy
2f1d7d2759 User::edits() was removed
Change-Id: I3ebe2cceb94a0d61a9e0ab5bb0599e8a03146046
2016-12-02 00:31:13 -08:00
Brad Jorsch
5840c440ce Remove $purpose parameter from password validity check
This was added in I56b6600 in an attempt to work around a bug in
CentralAuth, but the bug has since been fixed in a better way. No hook
functions in Gerrit use the parameter (or ever have, as far as I can
tell), and anything that was passing a value other than the default
'login' has since been removed. So let's just get rid of it instead of
keeping it around doing nothing.

Change-Id: Ie604e03d268706221161ac93eb866f477e466fb4
2016-12-01 18:41:01 -05:00
jenkins-bot
bfcbf215f7 Merge "Use isDisabled() instead of isBlank() in getGrantName in User.php" 2016-11-29 23:03:55 +00:00
Justin Du
fcd5b14c92 Use isDisabled() instead of isBlank() in getGrantName in User.php
Bug: T151956
Change-Id: Ic23c75b784c725f8f73eb1cf98d2bdb3763ab09d
2016-11-29 16:36:21 -06:00
MtDu
9e2ce38a03 List grant codenames next to grants on Special:ListGrants
Bug: T145351
Change-Id: Ia07de6269fa6192071aaea5d750362685389001c
2016-11-29 16:24:42 -06:00
Kaldari
9ba7296687 Prevent fatal error if $wgCookieSetOnAutoblock is changed to false
... and user still has a block cookie set.

Bug: T151097
Change-Id: I5a2fdc53250f629579428efbed39f6fb1f1531f3
2016-11-28 11:44:36 -08:00
Brian Wolff
f12a3edff7 Remove passwordreset capture feature
If anyone wants such a thing, they can make their own extension.

I asked stewards, and they said they don't use this.

See also T32636 / 9de2bfd1fe

Bug: T150930
Change-Id: I3ab5962dba668e5d628e55ad0c0feae471d82b5e
2016-11-23 00:02:33 +00:00
niharika29
7665985070 Add var to User class to store block type for eventlogging purposes
Bug: T146230
Change-Id: I70b54243a3018191a4e0cc311e90f66d240e1813
2016-11-16 19:43:27 +00:00
Tyler Anthony Romeo
1cc3a57296 Send a cookie with autoblocks to prevent vandalism.
Send a cookie with blocks that have autoblock turned on so that
the user will be identified to MediaWiki and any IP they try
to edit anonymously from will be blocked, even without logging
in to the originally blocked account. Additionally, the block
info is stored in local storage as well as an even stronger
deterrence.

Note: this is meant to deter normal vandals, i.e., not attackers
who know what cookies and local storage are and will be actively
removing the cookie.

This feature is disabled by default, and can be enabled with the
new $wgCookieSetOnAutoblock configuration variable (by setting
it to true);

The cookie will expire at the same time as the block or after
$wgCookieExpiration (whichever is sooner).

Bug: T5233
Bug: T147610
Change-Id: Ic3383af56c555c1592d272490ff4da683b9d7b1b
2016-11-16 10:29:46 -08:00
jenkins-bot
69ae945e8d Merge "Update weblinks in comments from HTTP to HTTPS" 2016-11-08 21:32:00 +00:00
Fomafix
202f695f67 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Also update some defect links.

Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
2016-11-07 15:24:46 +01:00
umherirrender
34fe90ac52 Remove empty lines at end of functions
It looks like there is something missing after the last statement
Also remove some other empty lines at begin of functions, ifs or loops
while at these files

Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
2016-11-05 11:55:10 +01:00
Gergő Tisza
c21f49aec7 Force User::__toString() return value to be string
Bug: T148486
Change-Id: I19f483b16c99d05f4d1626ee89ba1cfb7a78d52b
2016-10-18 23:50:47 +00:00
Kunal Mehta
61adc1e146 Use namespaced ScopedCallback
The un-namespaced \ScopedCallback is deprecated.

Change-Id: Ie014d5a775ead66335a24acac9d339915884d1a4
2016-10-17 15:46:05 -07:00
Bryan Davis
bc6e4d0082 wgRateLimits: Add configuration option to ignore 'noratelimit' right
It may be reasonable to ignore the 'noratelimit' right granted to a user
when perfuming some rate limit checks. As an example, a rate limit check
on failed authentication attempts should not be bypassed.

Add an optional '&can-bypass' configuration option for each
$wgRateLimits action that can be set to false to disable checking
User::isPingLimitable(). This bypasses both 'noratelimit' and
$wgRateLimitsExcludedIPs exclusions.

Depends-On: Iacdd1719d5f08eca91de0a35c0042ffee2136f34
Change-Id: Ia3add8bbbab0307f036e9b77e752c382da3a0d04
2016-10-04 05:38:10 +00:00
Aaron Schulz
5bbac35ed1 Replace DatabaseBase:: with Database:: and update type hints
Change-Id: I3919b04eb2de4fa0bf8a02239fb5bbf17d347511
2016-09-27 04:20:03 +00:00
Aaron Schulz
a2790b1b80 Remove wfGetCaller() dependency from DatabaseBase
Change-Id: I3e240b2eb5c1f6a21f1bc974c3d28f5755c7451a
2016-09-15 14:40:00 -07:00
Aaron Schulz
6fed0f430a Avoid creating DB replication lag in clearAllNotifications()
Change-Id: Ifad51cf2aaa9867513615d48753436cf686d7f1c
2016-09-12 06:01:04 -07:00
James D. Forrester
960e4d09ca Documentation: Replace misuse of 'later' when we meant 'latter'
Change-Id: I01bfdb8e0bfaa132533732873f7c840cea7935eb
2016-09-07 13:13:42 -07:00
Aaron Schulz
57e19b610d Renamed some variables from "slave" to "replica"
Change-Id: I455278294cd7ea344d14a76ac5957ece2e07fbf3
2016-09-05 23:03:01 -07:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07:00
Aaron Schulz
16266edff3 Change "slave" => "replica DB" in /includes
Change-Id: Icb716219c9335ff8fa447b1733d04b71d9712bf9
2016-09-05 21:01:01 +00:00
Aaron Schulz
52511952de objectcache: add and use adaptiveTTL() method
* This better handles delayed/lost cache purges by
  having lower TTLs for entries that often changes.
* Use this for foreign upload description page caches,
  we purges are never received from the source wiki.
* Also use this for User and LocalFile cache TTLs.
* Also move the Database::getCacheSetOptions() call in
  User *before* doing the queries, which is preferred.
* Fixed some IDEA errors too, like the undeclared
  mApiBase field.

Change-Id: I70f8ebb29ac853c2a530d9eedb9e7facc1b7b710
2016-08-31 03:40:56 +00:00
jenkins-bot
1ded361182 Merge "SECURITY: Move 'UserGetRights' call before application of Session::getAllowedUserRights()" 2016-08-23 04:34:38 +00:00
jenkins-bot
345fcff394 Merge "Remove commit() hack from User::addToDatabase()" 2016-08-23 04:29:20 +00:00
Brad Jorsch
6c0aa7c26b SECURITY: Move 'UserGetRights' call before application of Session::getAllowedUserRights()
This prevents hook functions from accidentally adding rights that should
be denied based on the session grants.

If some extension really needs to be able to override session grants,
add a new hook where the old call was, with documentation explicitly
warning about the security implications.

Bug: T139670
Change-Id: I6392cf4d7cc9d3ea96554b25bb5f8abb66e9031b
2016-08-23 04:02:08 +00:00
Brian Wolff
b675be2083 SECURITY: Make $wgBlockDisablesLogin also restrict logged in permissions
Does both Title and user related methods, so it catches things that only
call $wgUser->isAllowed( 'read' ), as well as giving a nicer error message
for things that use $title->userCan().

Otherwise, the user can still do stuff and read pages if they have an
ongoing session.

Issue reported by Multichill

Bug: T129738
Change-Id: Ic929a385fa81c27cbc6ac3a0862f51190d3ae993
2016-08-22 18:41:01 -07:00
Aaron Schulz
a618d84bfb Remove commit() hack from User::addToDatabase()
This is likely not needed anymore to avoid deadlocks anymore
as AuthManagar uses a lock in autoCreateUser() before hand.

Change-Id: I19ae6562011854495efcb0dd832b7ae99ebbb224
2016-08-21 14:03:24 -07:00
Matthew Flaschen
972b5a1976 Note that you shouldn't use a custom $salt for 'edit' or 'csrf'
Change-Id: I795b3a17791a9e16382a7c6379b0e7a4a498d32e
2016-08-16 18:12:27 -04:00
jenkins-bot
dcd211106c Merge "Don't use SearchEngineConfig::searchableNamespaces in User::getDefaultOptions." 2016-08-16 20:10:36 +00:00
Gergő Tisza
df342ebda5 Rename 'authmanager' log channel to 'authevents'
Also, move some events which did not belong there to the
'authentication' channel.

Change-Id: I4d7564343318899fc498ed2bd2d5260041ee22cc
2016-08-10 01:32:28 +00:00
Gergő Tisza
854a462dc0 Remove $wgDisableAuthManager
Change-Id: I2b2c9693a275fcc026916bd97f303e7a5c8df341
2016-08-09 23:00:27 +00:00
daniel
6f61893400 Don't force loading of groups and options on User::loadFromUserObject
When copying state from one User object to another, don't force
the source object to be initialized. The target object can initialize
groups and options on demand as usual.

Among other things, this helps to avoid some cases of recursive calls
to User::load(), see I6d1b9fe0789b4.

Bug: T142295
Bug: T137051
Change-Id: Ib369cf5b00628550591c2ee5dcb195db7c59a59c
2016-08-06 23:40:39 +00:00
daniel
00e6f58461 Don't use SearchEngineConfig::searchableNamespaces in User::getDefaultOptions.
Default options should be the same for all users. SearchEngineConfig::searchableNamespaces
however calls a hok that allows the set of searchable namespaces to be adjusted per user,
e.g. based on the user groups or permissions, like Extension:Lockdown does.

Since SearchableNamespace hook handlers may access the global user objects, problems arise
when it is that global user object trying to initialize itself that triggers the call to
User::getDefaultOptions. This can cause recursive calls to User::load(), see I6d1b9fe07.

Furthermore, these seems to be no need to actively record the searchable namespaces beyond
the contents of $wgNamespacesToBeSearchedDefault. If a 'searchNs' option is absent, it is
treated as disabled.

Bug: T142295
Bug: T137051
Change-Id: I5f6bcdfc588acef0873136bf338d79890863e009
2016-08-06 14:56:23 +00:00
Stephane Bisson
6e65053cc9 Keep $user->mEditCount up to date
Whenever User::incEditCount() is called,
this tries to keep the user object up
to date so hooks can read the edit count
without reloading the user from the db.

Another option would be invalidate the
instance cache and let the read
repopulate it. It would add a db access
on each edit.

Bug: T128249
Change-Id: I79194c41d6b2fd84ad658909a2941d9d3d28d94e
2016-08-05 09:06:56 -04:00
Bartosz Dziewoński
a49b3216fc Canonicalise '@deprecated since' doc comments
Change-Id: I440041512feb47a998efb45e76e3fd00e0655752
2016-08-02 22:21:57 +00:00
Gergő Tisza
43112b60da Add User::findUsersByGroup()
Needed by Iee6e0074d64.

Change-Id: Idbaf2102410f82343ad38ff51ccb7ab70b15e654
2016-07-27 19:52:25 +00:00
Aaron Schulz
86df9301a9 Use proper SELECT options in User::idFromName() for locking
Change-Id: Ia3ec245ecf5bb2fe7996828696b09f12a8ce10e1
2016-07-15 00:22:00 +00:00
Ori Livneh
8edbab99b0 Permit use of User::getDefaultOptions() in-process cache in unit tests
MediaWiki uses an in-process cache to speed up repeat calls to
User::getDefaultOptions() -- except when the unit tests are running, in which
case the process cache is disabled, because otherwise it would be at risk of
becoming stale due to unit tests manipulating $wgContLang. Well, there's a less
aggressive option, which is to keep the cache enabled but use it only if
$wgContLang hasn't changed. Since MediaWiki's test setup code creates default
users for the unit tests, User::getDefaultOptions() ends up getting called
quite a lot, so enabling the process cache is worth the trouble.

Change-Id: I81f3ae42d356939c81e59ab12d7a9e7d1206cb40
2016-07-07 19:50:52 +00:00
addshore
1af30e9bf0 Fix phpdoc of User::isIP
Change-Id: I0990e91ca70cb6fab7e7023917d6eb0d6fd2ff31
2016-06-23 10:57:48 +01:00
jenkins-bot
7586eef13a Merge "Use READ_NORMAL for User cache regenerations" 2016-06-09 19:45:04 +00:00
Aaron Schulz
a3e92639ad Use READ_NORMAL for User cache regenerations
This fixes a regression from 3bbccc8da6. A large uptick in
master queries showed in DBPerformance logs.

Change-Id: I5cf07aba2c3f928005d3aba55554c406e87026e2
2016-06-09 00:15:20 -07:00
Gergő Tisza
b568497e9a Add new convenience User method for authentication data change
Also update createAndPromote.php to use it so it can display errors.

Note that there are two possible approaches. The other is to
do the update for all requests for which the test passed,
even if some tests fail. The approach of the patch seems
more manageable from the caller's point of view
(either the operation was a success, or it failed and
nothing happened).

Change-Id: I86abed4b80472cd888337444fac0cbcb870b1246
2016-06-08 21:19:11 +00:00
Gergő Tisza
d850025e60 Reject authentication data change when there are warnings
AuthManager uses a status which is OK but not good for authentication
data which is discouraged but still accepted for authentication.
Users should not be allowed to change credentials into such invalid state.
This change brings the web logic and the AuthPlugin fallback in sync with
the API which already used the stricter check.

Change-Id: I4ff54fcc901f6fe11f15ed60fc1a3d8753de9f6c
2016-06-07 17:24:18 +00:00