Commit graph

61 commits

Author SHA1 Message Date
Umherirrender 4b45420cec Pass function name to IDatabase::onTransactionCommitOrIdle
Change-Id: I1baac429c08f95339a7456d6dd5e52b1aee2a69c
2024-09-19 23:31:13 +02:00
Umherirrender 87dd7827ee Use real type hints for class properties holding injected services
Provided services are already type-hinted on the construtor
and it is safe to use the same type on the class property

Change-Id: I15b5346353100e2e55d68b0a52fe3398778d60a5
2024-08-23 21:50:41 +00:00
Umherirrender 0cf9669e85 build: Upgrade mediawiki/mediawiki-codesniffer to v43.0.0
Change-Id: Ibad3f653c0b78249eff781596c567182cce281c6
2024-03-11 19:29:34 +01:00
Umherirrender 7fdd24ac9b Use LogicException instead of Exception
Change-Id: I7fcf5e33d1db4d137b0275b0a11f4d69db619515
2024-02-21 22:46:45 +01:00
Tim Starling fc9a494f29 Use Database::expr()
Bug: T350980
Change-Id: I369778002a880f1547940a097d96e55bcba9a08d
2024-02-16 14:20:53 +11:00
Reedy d96e30ec80 LoginNotify: Simplify returns in getMinExpiredId()
Follows-Up: Iea716e660353f16c47f873fe42edc2aeec1b4346
Change-Id: Ie351a210eea4eaf4101930fb18e6e149d4294ab4
2024-01-24 22:11:55 +00:00
Umherirrender 160368a296 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I8943e4e63fb41ca758c9ed25a4abb7664e13bb9f
2024-01-06 17:07:32 +01:00
Tim Starling 6f32dafbc1 Use the new DatabaseVirtualDomains feature
Change-Id: I05b6361bd57ba6754bd308e04da1c635f95d042b
2023-10-26 14:50:22 +11:00
Umherirrender 70703bdce3 build: Add @phan-var to handle varying return value of hash_hmac
Since php8.0 hash_hmac throws exception and does not return false
Reported by phan running with php8.1

Change-Id: I2374daf5e0954bef91da65454d973ef3d1eb2183
2023-10-06 19:25:35 +02:00
Tim Starling a0a387d195 Don't notify of failed logins for system or temporary users
Bug: T329774
Change-Id: I65fa3da22f45002e013d3bd5c8b0efda5f8b5edb
2023-09-04 17:01:52 +10:00
Tim Starling 534e3ce4b3 LoginNotify seen subnets table
Add a table which stores a summary of each user's IP address subnet in
each time bucket, defaulting to 15 days. On edit (and other changes
causing a recentchanges row) and successful login update the table.

On attempted login, check whether the subnet is in the table in any
time bucket back to the expiry time.

Add a job and a maintenance script for purging expired rows.

Disabled by default for now. The idea is to enable it by default after
we have some experience with using it in WMF production.

If CheckUser integration is disabled (the future intended state), the
cache and LoginNotifyChecks job are suppressed since they are
unnecessary.

Details:

* Rename setCurrentAddressAsKnown() to recordKnownWithCookie() and
  split off recordKnown() which does the same thing except without
  sending the cookie. We use recordKnown() to store the IP address
  without sending the cookie, on non-login changes.
* Reorganise isKnownSystemFast() for clarity, and return emphatic
  USER_NOT_KNOWN if the user is not in the table, cache or cookie
  and CheckUser integration is disabled.
* Replace time() calls with a mockable method.

Bug: T345052
Change-Id: Iea716e660353f16c47f873fe42edc2aeec1b4346
2023-09-04 15:04:36 +10:00
Tim Starling 4c369696cc ServiceWiring, dependency injection
* Make LoginNotify into a service. Use a static getInstance() method
  instead of a services container class, since there is only one
  service.
* Removed references to $wgLoginNotifyEnableForPriv. The feature was
  removed in I888c6009fffad1712.

Change-Id: I9120b470d27a0d09e508bd4e12eb2bde2f38d34d
2023-09-04 15:04:36 +10:00
Tim Starling 8521667df9 Doc review and general cleanup
* Remove notification attributes such as title-message, unused since the
  initial commit since it used the new (2015) formatter system.
* isKnownSystemSlow() is always called with a third parameter, and it
  doesn't seem to be nullable in callers.
* Yes, most of the things make sense.
* Add reason why CheckUser has no cuc_ip_hex index.
* Use foreach
* Too late to truncate the hash now

Change-Id: I310bc53ba881842845b9358309954f89c355f81c
2023-09-04 15:04:36 +10:00
Tim Starling 40024f461d Updates for new Echo namespace
Change-Id: I6f83b0353bd33a06b2c9c9506c4114de60b9132f
2023-08-24 10:55:15 +10:00
Tim Starling a247ba5c79 If the user is known in the slow path, don't forget to notify
If the IP address associated with a failed login is found in CheckUser
for the relevant user, the notification was previously omitted.
Notification of failure with a known IP was only possible when the IP
was in the cache or cookie. So, fix that.

Change-Id: I498e6b71d0fab9dd9af63c9c5f88fbcaf6a53fc3
2023-08-24 10:32:05 +10:00
gerritbot eb79e7b8b8 Migrate ILB::getConnectionRef() calls to ILB::getMaintenanceConnectionRef()
Deprecated since 1.39 (I6e7544763bd)

Remove deprecated ILB::reuseConnection() calls as well

Bug: T343277
Change-Id: I477c216fe75bb393fc892ded13f3d117b6fda4aa
2023-08-03 22:27:44 +00:00
gerritbot 0ecf7ee302 Update moved class WikiMap
See T321882. Moved in I60cf4b9ef02b9d5

Bug: T321681
Change-Id: I1fdefa8f3eee67758a59d36a38209b1e418d9281
2023-04-25 09:54:12 +00:00
Alexander Vorwerk d5e7ca063a Update for CheckUser actor migration
Bug: T233004
Change-Id: I13a8d94f405cde255f9fd15aaf98d75819985786
2023-01-23 01:04:05 +01:00
Umherirrender 1356d4847d phan: Fix use of IMaintainableDatabase::tableExists
Since core change dffca06 the tableExists function is only for
maintenance database connections.
DBConnRef implements that interface, use that

Follow-Up: I282cd08d47be1e16cd05903d92561da04889768f
Change-Id: I161c39ad0fce3c48b470a5595a2c58a26c2014a1
2022-08-17 22:53:49 +02:00
jenkins-bot c3127ad1fc Merge "Replace deprecated JobQueueGroup::singleton()" 2022-01-23 21:39:34 +00:00
Umherirrender c223b81e91 Replace deprecated JobQueueGroup::singleton()
Change-Id: I9f02c492921171ac7b78997c001bd415fc3975f5
2022-01-21 17:21:51 +00:00
Alexander Vorwerk 6be5c9599b Use namespaced CentralAuthUser
Bug: T298840
Change-Id: Ib2eef3aaec85d8b9397ece6d1c9ff583b54d39c3
2022-01-09 13:56:23 +01:00
Alexander Vorwerk 591a9b49b4 Replace usages of deprecated wfWikiID()
The global function wfWikiID() is deprecated since 1.35 and it's usages
should be replaced with WikiMap::getCurrentWikiId().

Bug: T298059
Change-Id: I87140148f53266a2bc828a4fae75aa28aa098602
2021-12-21 01:58:01 +00:00
Umherirrender b34445b90a Use static closures where safe to use
Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: Iadeca93606fdce46f50dc587774673b6d5ed8315
2021-05-04 19:34:58 +02:00
Aaron Schulz 012f47bf32 Switch checkAndIncKey() to using BagOStuff::incrWithInit()
Change-Id: Id75ee8bcf9e01effd2185be0b01d6eaebd635a86
2021-04-01 15:45:33 -07:00
James D. Forrester 7500b622a4 Use User->isRegistered(), not deprecated isLoggedIn()
Bug: T270450
Change-Id: If61bd037b4f82d1f792035ca6f5139ba7d95b417
2020-12-17 18:27:21 -08:00
Umherirrender 674c24f807 Add missing @var and improve documentation
Change-Id: Iee58d1ac85939290c341568ebb10dc757e664425
2020-12-17 20:55:01 +01:00
Umherirrender 3b7b61fd71 Pass function name to IDatabase::tableExists
Useful for logging

Change-Id: I7644d1c84463c53576b35d679445e7093cccd2be
2020-06-07 01:40:03 +02:00
DannyS712 a5d764e44f Fix PSR12.Properties.ConstantVisibility.NotFound
Bug: T253169
Change-Id: Ie5a9ba0e65eeda936e63ea2345515a9b59a1ff11
2020-05-19 23:23:47 +00:00
Umherirrender 159b6b3b38 Improve param docs
Change-Id: I4b91b39757bb1a2717550f7c771537ee28ce0761
2020-02-29 21:28:35 +01:00
Reedy 3a68770d61 Don't use 'type' as a log parameter as it is a reserved word
Bug: T245280
Change-Id: I75de123ed7a17a24b41805a56cab16f0a93180dd
2020-02-14 17:47:16 +00:00
Ammar Abdulhamid f79c19acca Replace deprecated IP class with IPUtils
* Bump required MW version to 1.35.0

Bug: T242556
Change-Id: Ia25b7b6f8bc49e4b3d77f9f755b796f09a9aebaf
2020-02-09 07:36:57 +01:00
libraryupgrader 3103915e78 build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.ParamNameNoMatch

Additional changes:
* Also sorted "composer fix" command to run phpcbf last.

Change-Id: Ie0f3c44edd654994ca1aa3c55a40cbef22465c0b
2020-01-14 07:37:43 +00:00
libraryupgrader 19ef39f143 build: Updating mediawiki/mediawiki-phan-config to 0.9.0
Change-Id: I3d27bc41baf88e12c3874d6acc064abd5c847192
2019-12-28 20:12:51 +00:00
Umherirrender 99ed58f71b Fix doc of LoginNotify::generateUserCookieRecord
gmdate would also return string, it also given a string from the caller
site (result from explode)

Change-Id: I1bf314f7ad976e590fdb021c0921dbf7de7504bd
2019-12-13 17:16:23 +01:00
Max Semenik 4a89319c81 Don't use deprecated function IDatabase::getWikiId()
Change-Id: I1d18cff5326d13e3606d13299c84d42c7084125a
2019-06-13 19:41:40 -07:00
Aaron Schulz 93b9ab17aa Use IDatabase for type hints rather than Database
Change-Id: Iafd392f7b33a4cec6013633a520059ba3858a2fe
2019-04-07 19:44:40 +00:00
Kunal Mehta c5d999a10d Upgrade to newer phan
Bug: T216926
Change-Id: Iadebf5698e8c15db0d0009bd66f55c3b534a192f
2019-03-17 16:17:46 -07:00
Umherirrender 112a8678f6 Use ExtensionRegistry rather than class_exists
Change-Id: If1fb84ccb09ddfc357fae6ca6095b741ac81c0e8
2019-03-03 02:02:00 +01:00
Roan Kattouw fb3db4779b Notifications: Set canNotifyAgent per event type, rather than per event
Depends-On: I4f558654ec23757dd4ecd6986eb3e9a5593f5386
Change-Id: I40cb66596a7285ae9b961f9d85dd940d759b0abd
2018-10-26 17:37:33 -07:00
Umherirrender 313d2e4af1 Use extension registry to check for CheckUser to be installed
Class was renamed in I39c60b2d059d1cb2c1c0d3a4206232d961536697

Change-Id: I8ca79302b9bbd8999e49a134240420d5cd6117c1
2017-12-15 19:23:06 +01:00
jenkins-bot d6b547044c Merge "Lazy initialize salt" 2017-08-30 04:49:02 +00:00
Max Semenik 517342ae84 DB_SLAVE -> DB_REPLICA
Change-Id: Id47c23acf22af03964a6899e00a46ebf2088ab8a
2017-08-29 19:58:08 -07:00
Max Semenik 9bc4403bbf Lazy initialize salt
No need to get into cryptography when the salt is needed at most in 50% of
cases.

Change-Id: I3efd7332970005fdd32e47c6177e2e62e2f94a5c
2017-08-25 13:33:40 -07:00
Max Semenik a2b67b38b4 Remove unused import
Change-Id: I791728d08032c03ebbaa84f4c621c9ccd164c3c0
2017-08-25 11:39:49 -07:00
Max Semenik 8acdeae44d Fix check
Bug: T173888
Change-Id: I2643f7cbcdf6c9ad8dff8b6369a5ba6e402684b3
2017-08-24 14:43:10 -07:00
Max Semenik 228a2f3ee3 Even more logging
Bug: T173888
Change-Id: I7f9f3cf0657af100c6ae3a8b2bfb5206b86514eb
2017-08-24 13:56:35 -07:00
jenkins-bot ee7595d2ae Merge "Minor fix for phan 0.8.5" 2017-08-23 22:51:27 +00:00
Brian Wolff 1d81d4a4d5 Use global stash instance instead of local cluster instance
This seems like something that should be global so login
attempts are accumulated across all data centers

At first I thought this might be related to T173888,
but now I don't think so, as logins would be POSTs
so should all be in the master db anyways.

Change-Id: I8d64a8b1c6607cb5b32a25182ec3496477361fdd
2017-08-23 15:26:28 -07:00
jenkins-bot deef3ee3cd Merge "Do not record failures for non-existent accounts" 2017-08-23 21:59:28 +00:00