Commit graph

28 commits

Author SHA1 Message Date
Reedy 1559e32ae9 OATHUserRepository: Minor cleanup/fixes
* Don't use namespace on already imported Manager class
* Fix oauth mention to oathauth

Follows-Up: I6aa69c089340434737b55201b80398708a70c355
Change-Id: Id43fc3cffee589c6d04281edeb778c011dfecda4
2023-11-21 18:11:23 +00:00
Taavi Väänänen 4af2cd2a00 Drop support for old device schema
Bug: T242031
Change-Id: Ib5de429f16b597867624a5a3cdfdac99b96c8bf5
2023-10-11 21:06:45 +00:00
Reedy c56496d62f Various minor cleanup
Change-Id: Idbf84a1f49f1afbd2d3a342cedd72895c5378bc6
2023-10-10 23:29:21 +01:00
Taavi Väänänen 8bafb6fd4e
Keep both tables up-to-date on WRITE_BOTH
Bug: T242031
Change-Id: Ib387a3d448edca0e35d34de54a4c50b33601a2d4
2023-08-16 11:12:32 +08:00
Taavi Väänänen 167d3670cb
OAuthUserRepository: Ensure we don't end up with duplicate rows
To do the migration we need to ensure that a single user has rows in
either the old oathauth_users table, or the new oauthauth_devices table,
but not in both.

Also add a missing startAtomic/endAtomic.

Bug: T242031
Change-Id: Ib0d42370b7206ff031873182c3fd957449656de8
2023-08-15 16:29:38 +08:00
Taavi Väänänen 6ef3d2418a
Database-level support for multiple auth devices
This adds new database tables to support storing multiple authentication
factors for a single user. The current approach taken is to use a single
database row per 2fa method and key. The current module/key abstraction
will have to be updated to support having multiple module types for a
single user (for example for having a separate module for recovery
codes), but this patch does not address that and instead keeps the
existing limitations, however the needed updates for that should be
doable with this database schema.

I've decided to add a new table instead of modifying the existing
oathauth_users table. This is mainly because adding an auto_increment
column to the existing table would be difficult, but also allows us to
update the table definition to follow MW conventions (namely the column
name prefixes). I've also used the opportunity to normalize the device
types onto a separate table.

The migration stage variable is set to SCHEMA_COMPAT_NEW so that
third-party wikis can use update.php normally and don't have to adjust
anything. This means that it needs to be manually set to _OLD on
wmf-config before merging this patch.

Since we're already working with the database schema, this add a new,
currently unused column for the creation data, so that T242847 will not
require a new schema change.

Bug: T242031
Bug: T242847
Change-Id: I6aa69c089340434737b55201b80398708a70c355
2023-02-24 15:33:00 +02:00
Taavi Väänänen e3d07eb0ae
Add separate OATHAuthDatabase service
Add a simple service to access the central database to decrease code
repetition.

Change-Id: Ib33000f4d44d77da31cc375e374cb595ad23bcbd
2023-01-30 14:16:37 +02:00
Taavi Väänänen c0da90be2b
Add separate OATHAuthModuleRegistry service
This new service is separated from the previous OATHAuth class to give
the service a more accurate name. Also removed unnecessary injected
services and do some other minor cleanup.

Change-Id: I8d5fbc7594b69168dc0c8bfade1ac172a5aeef6f
2023-01-01 21:17:04 +02:00
Taavi Väänänen f3382dd3d1
OATHUserRepository: rely less on global state
Inject more stuff into OATHUserRepository properly. Also done other misc
cleanup on that class.

Change-Id: I194345974146517c8216a81330cd930534d655e4
2023-01-01 01:59:22 +02:00
Umherirrender 9b5754e351 Change type hint from Wikimedia\Rdbms\DBConnRef to IDatabase
The interface IDatabase is more common

Change-Id: I346e42fc4f58cc17e659c0fb12bc920afa261d24
2022-07-13 13:56:48 -04:00
Reedy 81b69d625a "OATHUserRepository: Stop handling legacy single-key" take 2
This reverts commit 851656bbdf.

Change-Id: I80b20d6105a1f34834a4b60f215313fd53b0195a
2022-03-31 20:46:08 +00:00
Zabe 851656bbdf Revert "OATHUserRepository: Stop handling legacy single-key"
This reverts commit 6898d6ba93.

Reason for revert: the transition is apparently not completed yet

Bug: T305029
Change-Id: Ie5079b25bf4403da7bbe9aaa927f40190904bf20
2022-03-30 12:17:36 +00:00
Reedy 6898d6ba93 OATHUserRepository: Stop handling legacy single-key
Migration is handled by UpdateTables::switchTOTPToMultipleKeys()

The transition has been completed at WMF as well.

Bug: T304375
Change-Id: I0e6d30075dfbd66d692cd8a5e3f7c9ebf44bc065
2022-03-26 09:44:55 +00:00
Reedy 22505f73ae OATHUserRepository: Remove some legacy handling
The migration from `oathauth_users.secret` to `oathauth_users.module`
was added in I71286534d21d950834. It resides now in the UpdateTables
class, which runs from the LoadExtensionSchemaUpdates hook.

The transition has been completed at WMF as well.

Bug: T304375
Change-Id: I5fa88704c6da2ae2679a19e0c5a2cfe7f3bf5f50
2022-03-25 20:38:16 +00:00
Alexander Vorwerk bd8bb22ecd Revert "Explicitly specify SQL columns to SELECT"
This reverts commit 6f37618f4f.

We are later calling isLegacy and that is checking whether
'secret' is set, but due to the change in the select,
'secret' is never set, breaking the functionality of isLegacy().

Change-Id: Ic2c53dca6d1b1608192a5722408f157505187092
2022-03-21 19:11:42 +00:00
jenkins-bot 3043b1eb75 Merge "Send a notification when 2FA is enabled" 2022-03-15 18:32:59 +00:00
Kunal Mehta 6f37618f4f Explicitly specify SQL columns to SELECT
...instead of `SELECT *`, in anticipation of future schema changes.
Notably, we didn't need to select the `id` field, since we don't ever
use it (spotted by Thiemo!).

Change-Id: I1089199bdad70401684377d88877eccc689427f9
2022-02-27 23:15:50 -08:00
Reedy 16bc5d7168 Send a notification when 2FA is enabled
Bug: T301987
Change-Id: I0fe32b735e34753442ec9811ea41d15b76999d87
2022-02-24 00:39:37 +00:00
Reedy 239ff36a06 Add module types to log entries
Change-Id: If765f666496492da44efa282011c2605923be3a2
2022-02-18 00:30:32 +00:00
Kunal Mehta 329c3133d6 Send a notification when 2FA is disabled
Notify users when 2FA is disabled on their account in case something was
fishy about it. This notification is a "system" notification that will
be displayed in the web UI and sent over email. It can't be opted out of
as a preference.

The notification links to Special:Preferences, where users can see their
2FA status and re-enable it if they want. A secondary help link goes to
[[mw:Help:Two-factor authentication]], but can be overridden by
adjusting the "oathauth-notifications-disable-helplink" message. The
notification text is different based on whether the user disabled 2FA on
their own, or an admin used the special page or a maint script to do it.

On Wikimedia wikis, we'll use the WikimediaMessages extension to
customize the messages.

The Echo (Notifications) extension is not required, this will gracefully
do nothing if it's not enabled.

Bug: T210075
Bug: T210963
Change-Id: I99077ea082b8483cc4fd77573a0d00fa98201f15
2022-02-17 00:14:20 -08:00
TChin e95a74035d Replace deprecated CentralIdLookup::factory
Bug: T288836
Change-Id: Iac0492405951d9c6bb21151f2b70f1989bdec027
2021-08-13 12:57:52 -04:00
ZabeMath 7820be3326 Replace uses of DB_MASTER with DB_PRIMARY
Change-Id: Ifd3c5b97b0f519b7f61c8fd76149b1bcd53796d1
2021-05-13 01:25:56 +02:00
Aaron Schulz 33d6671ac3 Cleanup unique keys parameter to IDatabase::replace() calls
Bug: T248147
Change-Id: I030a40ae32bbcda6801bb7a0b8311bbcf3295734
2020-04-17 15:12:19 -07:00
libraryupgrader 5b1a07906a build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.MissingReturn

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

Change-Id: Idb1b91244e653b2ba2e27bceb3eba769577124a9
2020-01-14 08:27:31 +00:00
libraryupgrader 28c468b1ca build: Updating mediawiki/mediawiki-phan-config to 0.9.0
Change-Id: Iaac7b5f78f26a083e8ad2d12f9c9c4a9ed246283
2019-12-28 14:40:25 +00:00
Dejan Savuljesku 54fc8a0cbf Define fallback for request IP when persisting user
Bug: T237554
Change-Id: I18f57a523a6515f593963a9c149374bd6f6c73b4
2019-12-03 14:34:58 +00:00
Dejan Savuljesku 017d8c8126 Support for multiple keys, improved module form logic #2
Removed unused classes, missed in previous commits

Bug: T218210

Change-Id: Iaf9facb54cd9693f20ed2f48d22b076c4b626705
2019-07-05 20:23:26 +00:00
Dejan Savuljesku ea984e5c2b Refactor the extension to support multiple auth modules
Please note, this patch requires a schema change before merging

Change-Id: I71286534d21d95083436d64d79811943c1a1d032
ERM: #14484
Bug: T218210
2019-06-18 10:45:21 +00:00
Renamed from includes/OATHUserRepository.php (Browse further)