Commit graph

22 commits

Author SHA1 Message Date
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
Ammarpad 3cd669d148 Hooks: Do not attempt user creation when there's no username
Bug: T345373
Change-Id: I9b7d8dbb67eb9277e121e52a6140773302d74734
2023-08-31 19:00:04 +01:00
Tim Starling a47af7c73d Fix deprecations and non-static providers
Change-Id: Ia267a93a13191a2289aff70d47c31b2afcb1647b
2023-08-25 15:10:07 +10:00
Umherirrender 4edd893fcc Use HookHandlers for Echo hook
Bug: T344297
Depends-On: Iffa2b409502b4269c9746e0304feb4aaee37a86e
Change-Id: I38fd96f2c4a5913b89d5dd760efb68273cb344a1
2023-08-16 00:59:03 +02:00
Umherirrender f02ff3ab36 Use HookHandlers for core hooks
The use of "HookHandlers" attribute in extension.json makes it possible
to inject services into hook handler classes in a future patch.

Bug: T344297
Change-Id: Icfa49dc56848c9b375f09d67ed839d0e10f57bfb
2023-08-16 00:34:21 +02:00
Reedy bc6e531aa2 Hooks: Use better callable with EchoAttributeManager::ATTR_LOCATORS
Bug: T325950
Change-Id: Iaf7f51453802e4ca9ffae786129bb402994adc03
2022-12-27 01:16:08 +00:00
Roan Kattouw fd827a88a0 Disable web notifications for login-success
Per Niharika's comment at T220762#5105917, "we don't want an attacker
to learn that we detected an unusual login and cause them to change
the account password or such".

This was already set in WMF's config for LoginNotify; this moves it into
the extension itself, where it belongs.

Bug: T220780
Change-Id: I5adc5a52f10f2f37ae64ff0400c8d77b35d36aa1
2019-04-12 12:54:20 -07: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
Brian Wolff 4a88e8375b Do not send email notice for throttled login attempts
I did the blacklisting throttled instead of whitelisting
wrong password as i didn't want to accidentally miss other
statuses equivalent to wrong password that use different messages

Bug: T193762
Change-Id: I8d51cb5a9c9856f175d31967a7d143836b9d67ee
2018-05-07 16:36:25 +00:00
Huji Lee 0cd8f9e926 Maintenance script to generate fake login attemps from any IP
Depends on: Ifb28222cf75ad23859bbdceff332cf1e526afe9c

Bug: T183722
Change-Id: I01221923387a9e94499efdda39b2e40ee207e27c
2018-02-01 20:10:48 -05:00
Max Semenik ee5ae41740 Remove compatibility with pre-1.27 MediaWiki
Change-Id: I3f7fd7b11d5f710ae4e940bdddd7001aa6948cf3
2017-10-25 18:26:57 -07:00
Max Semenik e13be59e42 Remove support for per-group preference defaults
Not used and introduces serious compexity, likely causing
the bug with users receiving notifications they've opted out of.

Bug: T174220
Change-Id: I888c6009fffad17121765678387022ed7d454cb0
2017-10-13 17:12:20 -07:00
jenkins-bot 8e4b7b0510 Merge "Log usage statistics" 2017-08-16 21:14:34 +00:00
Umherirrender e123da51eb Improve some parameter docs
Change-Id: I47e04c7e2b773d52289f459f59a46aeb9c4ad12e
2017-08-09 22:20:16 +02:00
Max Semenik 3b9faadf7d Log usage statistics
Bug: T170345
Change-Id: I7ec1214800062d9a22cd3fe0ce2ee9031fc9e21e
2017-07-28 11:09:20 -07:00
Max Semenik 0a70efc9da Move expensive processing into job queue
Bug: T167731
Depends-On: I618840fafd22d9b6471eb470ef0414e354aa17f5

Change-Id: I1fcd15f523828141e8fadee9a8ad824eacefc0f9
2017-07-11 22:08:53 +00:00
Matthew Flaschen 12cee85fd8 Remove dead code and messages
Change-Id: Ifbbf6844648940357df41d6998453edfe113c9a8
2017-07-07 22:15:50 +00:00
Niharika29 d283f05ef1 Fix 'Undefined class: LoginNotifyPresentationModel' error
Bug: T168899
Change-Id: Id845fcb5c53a2ac172a86fb4aa1cc8c246c9e19b
2017-06-27 18:16:25 +00:00
Max Semenik f944f5daf9 Cleanup
* PHPDoc
* Deprecated functions
* Undeclared property

Change-Id: I91ef41257d9bb53e14fbe762ad41798acaa06bb0
2017-06-16 04:15:17 +00:00
Max Semenik 9b3bd403ec Cleanup: namespace this extension, move stuff into includes
Change-Id: I7cf55685de955912c8637681c397179553d17152
2017-06-16 04:15:12 +00:00
Renamed from LoginNotify.hooks.php (Browse further)