Commit graph

217 commits

Author SHA1 Message Date
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
Umherirrender 4b44d7f9ba Use HookHandlers for Echo hook
Bug: T270971
Depends-On: Iffa2b409502b4269c9746e0304feb4aaee37a86e
Change-Id: I61dd10200c70575690c5c4db3978d6e85a6cfe5d
2023-08-16 00:14:23 +02: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
gerritbot c23d76f21a Migrate ILB::getConnectionRef() calls to ILB::getConnection()
Deprecated since 1.39 (I6e7544763bd)

Bug: T343277
Change-Id: Iac5f0ed8646f9c1cfd10fc02ad39566f97e94a14
2023-08-03 22:19:29 +00:00
Daimona Eaytoy db15682ecd Replace usages of deprecated UserGroupMembership::getLink()
Bug: T183174
Change-Id: Iee5ee954b7d40e1d8be23b605182fb02183faa26
2023-05-21 17:32:27 +00:00
gerritbot 4b32885285 Update moved class RawMessage
See T321882. Moved in I195cf4c67bd514

Bug: T321681
Change-Id: If34bda0a8d0f882d51fea1fcf4257bb5de09948a
2023-05-19 10:31:07 +00:00
Bartosz Dziewoński c64ba2134e List special pages under appropriate sections on Special:SpecialPages
Bug: T333242
Depends-On: Ieba1631ca3c0562b784aa07d2b26c418448e70a1
Change-Id: Ie5ab34bcd93892ef8c7319eeafd5e692766b69a0
2023-03-27 21:51:07 +00:00
jenkins-bot 4cbdd9db0b Merge "Database-level support for multiple auth devices" 2023-03-22 15:13:17 +00: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
Reedy 547da1a0c1 TOTPKey: Add better fallback attempts to find a useable cache
Bug: T330086
Change-Id: Iee5e2d95ef365c9f1767491d3a7008b7bd0eabdb
2023-02-21 22:22:37 +00:00
Taavi Väänänen 8890a44a31
TOTPKey: simplify verify() method
* Do not set the last window cache value when using a scratch token.
* Always return a boolean.

Change-Id: I60ce99ed3c70de73794ebafedd434adfcbf86ffc
2023-01-31 19:50:59 +02:00
Taavi Väänänen b843d75e96
TOTPKey: Move logging/rate limit handling to the callers
Change-Id: I88b946ed9a90e60579b708d71fa65d3d0aaf62b9
2023-01-31 19:42:44 +02:00
jenkins-bot 34acf3b222 Merge "Add separate OATHAuthDatabase service" 2023-01-31 15:43:38 +00:00
Taavi Väänänen 56b1b23805 API: Do not expose the module name in the output
Drop the module name from the oathvalidate API result. As far as I can
tell none of the clients of this internal API (Keystone and Striker) use
the field. This is needed for adding support for a single user having
multiple two-factor keys with different types.

Bug: T242031
Change-Id: I06895c153d7db69a3a6a2e9c34ae432bdc6ca96c
2023-01-31 15:33:59 +00: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 0fbb714b36 Replace deprecated HTMLForm::setPreText
Bug: T325474
Change-Id: I6dbbee52e27fd048cba3bd58a23554324c0db4b9
2022-12-27 12:49:08 +01:00
libraryupgrader 7a07d22494 build: Updating dependencies
composer:
* mediawiki/mediawiki-phan-config: 0.11.1 → 0.12.0
* php-parallel-lint/php-console-highlighter: 0.5.0 → 1.0.0
* php-parallel-lint/php-parallel-lint: 1.3.1 → 1.3.2

npm:
* grunt: 1.4.0 → 1.5.3
* grunt-banana-checker: 0.9.0 → 0.10.0
* grunt-eslint: 23.0.0 → 24.0.0
* async: 3.2.0 → 3.2.4
  * https://github.com/advisories/GHSA-fwr7-v2mv-hh25
* minimatch: 3.0.4 → 3.0.8
  * https://github.com/advisories/GHSA-f8q6-p94x-37v3
* minimist: 1.2.5 → 1.2.7
  * https://github.com/advisories/GHSA-xvch-5gv4-984h
* nanoid: 3.1.25 → 3.3.4
  * https://github.com/advisories/GHSA-qrpm-p2h7-hrv2

Additional changes:
* Set `name` in package.json.

Change-Id: I76d70ca68b385b44e647cdbebd1a3e473f3fb566
2022-11-11 21:53:17 +00:00
Reedy dac8cb27dc Move UpdateTables to HookHandler
Standardises code

Bug: T270971
Change-Id: If4ec8443afde189ce69d305857f94249a605dd42
2022-10-05 23:25:55 -04:00
jenkins-bot a01508c78b Merge "ApiOATHValidate: Remove deprecated totp parameter" 2022-10-01 04:19:47 +00:00
jenkins-bot f0c3d426db Merge "Drop broken postgres/patch-oathauth_users-drop-id-nextval.sql" 2022-09-30 08:15:59 +00:00
Kunal Mehta 751cce3259 Drop broken postgres/patch-oathauth_users-drop-id-nextval.sql
This patch has a syntax error. Once fixed, after it's applied to
the original postgres schema (P31006) it makes no difference and
can safely be dropped.

Bug: T312744
Change-Id: Ief18c3a428979d6c7f3592b5763630ac19b85d83
2022-09-29 22:34:19 -04:00
Reedy 5efe6e212a ApiOATHValidate: Remove deprecated totp parameter
Was deprecated in I5fa88704c6da2ae2679a19e0c5a2cfe7f3bf5f50

Bug: T304375
Change-Id: Ibea5ab0b1215b21ef4e0cd1afbd1de8fc87a9810
2022-09-21 19:18:20 +00:00
Umherirrender 7b6d8ccdea phan: Fix type for IMaintainableDatabase::fieldExists on updater
Since core change dffca06 the fieldExists function is only for
maintenance database connections.
Phan reports the type error, the real object on runtime implements the
necessary method, so adjust the doc

Follow-Up: I282cd08d47be1e16cd05903d92561da04889768f
Change-Id: I6d78b3958dc68a61be7e6811b36cc772fa165ffd
2022-09-21 19:05:51 +00: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
Umherirrender c1c8cf8e49 Bump minimum required version for upgrade to 1.31
Remove sql patches, mention the gerrit change to check version
- patch-remove_reset.sql - Ife5f1bae4ad65b66c5e20017cc43c0576b4aba19

Change-Id: Iae21017f7724390470ca89f492ef26f8ea36e0ad
2022-07-11 19:01:36 +02:00
Reedy 4f82fe9bc8 TOTPKey: Apply array return type to jsonSerialize()
Bug: T311673
Change-Id: Ibeeda6e873d1b025a7c43b2f43cf547f981a1692
2022-06-30 00:48:11 +01:00
Klein Muçi 7eb87b5cfc Fix typo
Bug: T201491
Change-Id: Ib5cdd7082c6c4ae3d3c6564ea608a7dedac88446
2022-05-02 22:47:14 +00:00
jenkins-bot 86ba7a8e17 Merge "OATHUser: Annotate that getModule() can return null" 2022-04-11 08:53:36 +00:00
jenkins-bot bf532cea7e Merge "Rename oauthauth-ui-no-module" 2022-04-06 01:04:02 +00:00
gerritbot 3f5f7f6db9 Fix usage of ApiBase::PARAM_* deprecated constants
The ones that are replaced with ParamValidator

Bug: T275455
Change-Id: Id4800f82472f859d1a725fd98ec1007600ccd369
2022-04-04 01:28:34 +02:00
Reedy b5a762d7fe Rename oauthauth-ui-no-module
Change-Id: I23a05cd04756b87d0a97db32ddedc1ea8af0c1b7
2022-04-02 21:39:07 +00: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
jenkins-bot 7f97014390 Merge "Revert "OATHUserRepository: Stop handling legacy single-key"" 2022-03-30 12:28:58 +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 0535912298 OATHUser: Annotate that getModule() can return null
Change-Id: I83e34a9b1b58956b10af099668177ce426937b58
2022-03-29 13:45:22 +01:00
Reedy 7c4649ce37 ApiOATHValidate: Fix example passing TOTP token in data
Change-Id: Idee5685cbf69e4d6dfe4e03e109a0523bc94784f
2022-03-29 12:12:14 +01: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
Reedy 6adc5ecabf Remove unused $key variables from foreach()
Change-Id: Ib035ff7fc3eeeb73b6f870b226775d61b3caee11
2022-03-21 23:58:03 +00:00
Alexander Vorwerk 248d2bb8d6 Disable user only after it has been removed from the db
OATHUser::disable sets the 'module' value to null, but
OATHUserRepository::remove reads that value, in order to add the type
to the log entry, resulting in fatals.

Bug: T304350
Change-Id: Ied622f1ba65bfabad3f048dbca885e4dadab0907
2022-03-21 21:50:20 +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
jenkins-bot caee0f788b Merge "Explicitly specify SQL columns to SELECT" 2022-02-28 07:36:04 +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 211c1cb930 Replace usages of Wikimedia\(suppress|restore)Warnings()
Change-Id: Iac7480957819652d487e177bc9caf0c8c3db83e4
2022-02-24 21:18:30 +00:00
Reedy 16bc5d7168 Send a notification when 2FA is enabled
Bug: T301987
Change-Id: I0fe32b735e34753442ec9811ea41d15b76999d87
2022-02-24 00:39:37 +00:00
sbassett 274c82043e SECURITY: Use constant time checks for token values
Bug: T302059
Change-Id: If726c61233d44e76a22fe25c2c910ce59771b49c
2022-02-22 16:11:07 -06:00
Reedy de936aef6a Convert OATHAuth to abstract schema
Bug: T268564
Change-Id: I251fac0e1939cc84e7eab3e7514e07c81b2b0f1e
2022-02-18 10:36:56 +00:00
Reedy 239ff36a06 Add module types to log entries
Change-Id: If765f666496492da44efa282011c2605923be3a2
2022-02-18 00:30:32 +00:00
jenkins-bot 361d2829ba Merge "Add some greppable usage of messages" 2022-02-17 21:20:21 +00:00
Reedy 68ca72d7b9 Add some greppable usage of messages
Change-Id: I5ca72a33ecacb15a8a01f6cda0cdb7cdb628eab8
Follows-Up: Idbac3940b36ce21a0b40044482514a28c5fbd45f
Follows-Up: Ic173ebb7e39d22e40fea23c2b906d246adef1e05
2022-02-17 20:44:51 +00:00
Reedy 4a3db51953 DisablePresentationModel: Remove duplicate getExtraParam call
Follows-Up: I99077ea082b8483cc4fd77573a0d00fa98201f15
Change-Id: I3e6d5aad83e005f7ea2b80551b5eb9249bf4b947
2022-02-17 18:16:17 +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
jenkins-bot 4cc5cbe4ad Merge "Require OATHAuth for membership in specified user groups" 2022-02-17 07:41:53 +00:00
Lucas Werkmeister 203a0112c0 Pass context into HTMLForm
Creating a HTMLForm (or OOUIHTMLForm) without passing in a context is
deprecated now.

Bug: T301866
Change-Id: I35eb85f5089bcef04624e5f72fd1a4389be87de9
Depends-On: Ic65c8934ab33c6d1ca0356011923f8933c5072ca
2022-02-16 13:05:35 +01:00
Kunal Mehta 498dcfeb80 Require OATHAuth for membership in specified user groups
Users in groups listed in $wgOATHRequiredForGroups (default none) must
have two-factor authentication enabled otherwise their membership in
those groups will be disabled. This is done using the
UserEffectiveGroups hook, which allows dynamically adding or removing
user groups.

If a user doesn't have 2FA enabled, it will appear to them as if they
aren't a member of the group at all. Special:Preferences will show which
groups are disabled. In the future it would be good to have a hook into
PermissionsError to show this as well. The UserGetRights hook is used to
ensure the user still has the "oathauth-enable" user right in case it
was only granted to them as part of the user group they are disabled
from.

On the outside, Special:ListUsers will still show the user as a member
of the group. The API list=users&prop=groups|groupmemberships will show
inconsistent informaiton, groups will remove disabled groups while
groupmemberships will not.

This functionality was somewhat already available with
$wgOATHExclusiveRights, except that implementation has flaws outlined at
T150562#6078263 and haven't been resolved in I69af6a58e4 for over a year
now. If this works out, it's expected that will be deprecated/removed.

Bug: T150562
Change-Id: I07ebddafc6f2233ccec216fa8ac6e996553499fb
2022-02-14 00:47:20 -08:00
libraryupgrader 76a50e2d77 build: Updating mediawiki/mediawiki-codesniffer to 38.0.0
Change-Id: Ia3f9db90ccc4529513e6ef129add054d4657d806
2021-10-24 08:53:27 +00:00
Reedy 72fb91180f switchTOTPScratchTokensToArray: Don't run a db update unless the row is changed
Change-Id: Ie08db6253ddc3b05a49a7e99fa9637fcacc5f3a7
2021-09-23 18:33:41 +01:00
libraryupgrader 37bab0ccb9 build: Updating composer dependencies
* mediawiki/mediawiki-phan-config: 0.10.6 → 0.11.0
* php-parallel-lint/php-parallel-lint: 1.3.0 → 1.3.1

Change-Id: Ibc5ba5833ca9a72ac72e257e32d3519be42c23a2
2021-09-09 11:12:00 +00:00
MacFan4000 249d1f3daf set autocomplete=‘one-time-code’ on forms
This allows iOS/iPadOS/macOS to suggest filling codes from sms/the built in totp authenticator (in upcoming versions).

Bug: T289086
Change-Id: I555b05fad4806a37a95afcbc63e143efc424f9d3
2021-09-03 22:45:32 +00:00
Reedy 5143076231 Stop trying to return the result of a void return value
Change-Id: I27d9f2bc55d12764b526d226293ff8743a6cb668
2021-09-03 01:27:29 +01:00
TChin e95a74035d Replace deprecated CentralIdLookup::factory
Bug: T288836
Change-Id: Iac0492405951d9c6bb21151f2b70f1989bdec027
2021-08-13 12:57:52 -04:00
vladshapik bae40b8b5e Replace uses of the deprecated setters of AbstractAuthenticationProvider
Since AbstractAuthenticationProvider ::setLogger, ::setManager,
::setConfig methods had been soft deprecated,
so its uses were removed.
* Also bump required MW version to 1.37.0

Bug: T281991
Change-Id: Ifd6ed1bc60d8a7fe6d10af1f08b6670a96ca2851
2021-05-13 17:50:15 +03:00
ZabeMath 7820be3326 Replace uses of DB_MASTER with DB_PRIMARY
Change-Id: Ifd3c5b97b0f519b7f61c8fd76149b1bcd53796d1
2021-05-13 01:25:56 +02:00
Timo Tijhof 6b106fe10c TOTPKey: Use foreach instead of for-i-length and remove dead code
Follows-up c943f75.

* Use foreach to iterate the list of tokens, instead of i-to-length.

* Remove the redundant 'retval = false' assignment, as this was
  within an `if (!$retval)` block where the only previous assignment
  to it was either retval = 1 or retval = false. Hence redundant.

* Remove the conditional that made the list only checked if the
  list was not identical to `[ 0 => "" ]`.
  It is unclear to me why this check existed.
  I can imagine one of two scenarios, neither of which appears
  to be the case:
  1. Maybe the scratch list contains 10 tokens plus an empty string,
     and if we see it only contains that, we know it's logically empty
     and don't "need" to iterate the list.
     Except... iterating the list is cheap, so why bother?

  2. Maybe the scratch list contains 10 tokens plus an empty string,
     and we don't want to allow the empty string to be considered
     a valid scratch token to we skip the loop if that's the only
     one left.

     Except... if that were the case we'd be in trouble as it
     isn't being disallowed when the list contains other items
     still. And again, afaik it never contains an empty string,
     and hopefully empty input is already rejected by now.

   Neither of these are good reasons to remove the code without
   knowing what it was for though, so I'd rather we figure this
   out before merging. I can restore the check if it's non-trivial
   to find out.

Bug: T256918
Change-Id: Ide4160bdc18bc47da9632791fb4321e44d6d115a
2021-03-29 21:42:56 +00:00
Reedy 615965c730 Inject services to Special Pages
Change-Id: Ice0c63368e9c0aa77688b63a74eb706dd00691ce
2020-12-31 23:54:43 +00:00
Reedy 85d6681fef Convert to HookHandler
Bug: T270971
Change-Id: Idf8dad4872a220624b4355a8a9b5e9a02d0e442c
2020-12-31 19:52:49 +00:00
Reedy 1d97d5ef1b OATHManage: Code cleanup
* Stop returning return values of function that don't return anything
* Remove & from IManageForm reference

Change-Id: I7afa12a4f154cabee03be8947a0bfaadf9598a03
2020-12-31 04:25:10 +00:00
jenkins-bot dccf665960 Merge "Minor code style changes" 2020-12-31 03:29:55 +00:00
Reedy 37d2b0ff19 Remove TwoFactorIsEnabled hook handler
Hook was part of Extension:OpenStackManager, but removed by REL1_35, so unnecessary
I4741fcb073f8463f017bc1b477206dee801b662b / 46d9149c2db7c2b2d4573bede74b54779d66bee8

Change-Id: I2c5f99bfa9028c57a1eadbd81a51f84b47668848
2020-12-31 02:37:42 +00:00
Reedy ec1c1dcb22 Update TOTP Scratch Tokens to array
Bug: T237303
Change-Id: Ie8de059888363bf1cea4f0b268a46faaa5671904
2020-12-31 01:18:05 +00:00
Reedy 6bb34e9265 Minor code style changes
Change-Id: I4bdc173fb6dd1cfeefc537c904a92724ea50112f
2020-12-28 02:47:09 +00:00
Umherirrender 69ef3c1bcb Avoid wfMessage in special page
Use self::msg instead to avoid global state

Change-Id: I78f914facee4174e76bbc77716b99d4aebd26c67
2020-12-19 12:16:51 +01:00
Ed Sanders 60714e7a81 Convert null global to false
Bug: T270147
Change-Id: I7b6d3bae126d7a1dc57eaf9ab0aef070595910e0
2020-12-16 17:52:16 +00:00
Reedy 53bb01d46a Minimise duplication of getting correct database instance in UpdateTables
Change-Id: Ide7dfe87f5e23997321c39623d3c574ae52fdb3e
2020-12-16 17:51:00 +00:00
Martin Urbanec 96bea3eed8 Use existing message instead of oathauth-disable-header
Bug: T265693
Change-Id: Ie9c3f787dd435709aa3aa17eb6e0cb6dd109dc33
2020-10-16 21:05:47 +02:00
jenkins-bot 7d13959016 Merge "Allow privileged accounts to use action=query&meta=oath" 2020-10-06 18:21:11 +00:00
Martin Urbanec 446f013c65 Allow privileged accounts to use action=query&meta=oath
Since T209749, privileged users have an UI to query 2FA status.
We should allow them to do the same thing via the API as well.

Bug: T250901
Change-Id: I28720c762ca595c0ab83aa400f0a593ed6a9285e
2020-10-05 00:32:42 +02:00
Reedy 9952cf8ee6 Make SQLite compatible patches
Bug: T264492
Change-Id: I622b177015740ca5f6f625250efa3d4ad71be448
2020-10-04 20:40:27 +00:00
Daimona Eaytoy 8774167f97 Parse oathauth-scratchtokens message
It's using wikitext, so it must be given to the parser.
Follow-up to I2abc96bea0543d600c3a48361da1a626d27d5067

Change-Id: Id6d938c2d2d5775d55d3c4c1aeeaa1c002294a9f
2020-08-22 15:17:41 +00:00
Umherirrender 779ef411af Pass function name to IDatabase::fieldExists
Useful for logging

Change-Id: I7abf96902f74e1f7fabd7fa77c4b018b922fb5cb
2020-06-07 01:43:37 +02:00
Umherirrender 778460805a Parse messages in string context
Change-Id: I2abc96bea0543d600c3a48361da1a626d27d5067
2020-06-02 21:09:48 +00:00
DannyS712 130e649191 Add Special:VerifyOATHForUser to check if users have OATH enabled
Bug: T209749
Change-Id: Idbac3940b36ce21a0b40044482514a28c5fbd45f
2020-04-22 00:47:22 +00: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
DannyS712 bce8776341 Use lowercase for primitive type 'string'
Change-Id: I00a825b873b3647fba68a9683a0c0804fec9d2cb
2020-03-20 16:01:07 +00:00
Umherirrender b3c7d912b2 Improve param docs
Change-Id: Ib5d2e6cfe3b0825c9ded342de6c905567d01dc06
2020-02-29 21:34:07 +01:00
Martin Urbanec 7eefeed2bc SECURITY: Disallow user JS at our special pages
Bug: T243608
Change-Id: Ib0deea7a986dd37f23ad5a68a1fb9784ac346db6
2020-02-13 14:12:28 -06:00
Dejan Savuljesku c943f75cee Fix removing scratch tokens
Due to using unset(), array keys would be preserved, and therefore, for loop would crash.
Now using array_splice, but had to "reset" the values on construct to fix currently broken
arrays.

Bug: T244308
Change-Id: I6f3dd3df95d5a071b92aa7693ed7ae3fddf35a9d
2020-02-05 10:54:25 +01: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
Umherirrender 7f39d94d02 Use WebRequest::getBool to have bool cast
Change-Id: Ic6e4db33f3a919ebfa28ea69db4b22c8c7d173fe
2019-12-13 22:45:21 +01:00
Reedy 86986442f9 Remove Oracle and MSSQL schemas
MSSQL schema wasn't even plumbed in...

Change-Id: I07061b5e3ceb2464e6def363c6fe5b18ad4ce225
2019-12-10 14:27:55 +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
Reedy 18c257fa55 Remove ApiOATHValidate::getCacheMode()
It's not a query module, so this doesn't actually do anything.

Non query modules are private by default, so ApiMain->setCacheMode()
is not needed

Change-Id: I789edbf0693f8b1928fb32c3aedc0d8899aecc40
2019-11-12 16:49:51 +00:00
Reedy 1bc446c9ad Remove and fix remaining phpcs exclusions
Change-Id: Ib93f4c70383e838cf28bb07a05ea5d962263d14c
2019-11-09 07:42:58 +00:00
Reedy 659012e543 Remove and fix phpcs exclusion PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I7840910881e18fe76228571c24256c4fa6549c89
2019-11-09 07:15:26 +00:00
Reedy 3132064fe2 Enable schemaUpdateTOTPToMultipleKeys
Change-Id: I6cb10a877652a10412664e124f94c5d0c58932fe
2019-11-04 18:45:22 +00:00
Dejan Savuljesku 98d151fb27 Ask for user re-auth only on initial requests
Make sure user is asked to re-authenticate (if needed) only on initital request,
not after submitting the form

Bug: T235645
Change-Id: Ic315f49ac5810da0a703ccf4b51f558d17f905fb
2019-10-23 09:49:37 +02:00
Dejan Savuljesku 920136e67b Do not store proper objects in session data
Bug: T233146
Change-Id: I2f75261b276993d27f6c96e066ea7769cf7fc082
2019-10-16 13:04:49 +02:00
Dejan Savuljesku a244d95224 Ask user to reauthenticate before changing 2FA method
Re-auth period set to 60s

Bug: T218211
Change-Id: I17a84b8e60da2ada35c6b86cf6b66d75fb3f13fe
2019-10-09 20:45:30 +00:00
Dejan Savuljesku 8ca4dabd70 Add warning page before method gets disabled
- When explictly disabling a method
- When method is implicity disabled if user switches to another method

Bug: T232008
Change-Id: I97a96ca7c1935ecb3a81aea35f607b8ff9f8817d
2019-09-28 16:22:41 +00:00
Dejan Savuljesku ae53dc5c60 Make sure key is of correct type before running operations on it
Bug: T231786
Change-Id: I54aad0753fa3eda48e7f382b27b1c89069f40d36
2019-09-04 11:53:22 +00:00
Dejan Savuljesku 36485440ee Improve ManageForm
Make sure that particular form is only loaded when it actually makes sense
for it to load, not when its just requested.

Bug: T218211
Change-Id: Ibae0279451b4a6a4a1d1ce212bbbbf919900a46d
2019-09-03 14:17:48 +02:00
Dejan Savuljesku 630a17da01 UI upgrade
Help messages for 2FA in general and for TOTP module are taken from Wikipedia.
Those could probably be improved, any suggestions are welcome

Bug: T218214
Bug: T226056
Change-Id: Ifc81a3c0e1adc9f6d0d49e7eee086714fc2c0f81
2019-08-29 10:38:10 +00:00
Dejan Savuljesku 019cf6ccdd Add method to clear all keys associated with the user
This is needed when changing modules, we need to remove all keys
from the old module

Change-Id: Iaada3df631260dbd612cce01f5477e93e6da4596
2019-08-26 12:13:23 +00:00
Aaron Schulz cb4e6a15a6 Make TOTPKey use the main stash for the token key
Change-Id: Idd20c778f7ea1d2393f1e08eb3cf7f74b8ee2b2d
2019-08-12 18:10:10 -07:00
Dejan Savuljesku 6c09ac0c53 Allow revocation of user rights if 2FA isn't enabled on an account
Bug: T199118
Bug: T218215

Change-Id: I7036dd0d95598b90654a1fcf3130c6bdc6b635b4
2019-07-31 13:36:33 +00:00
DannyS712 a9af4e59e1 Hide Special:OATHManage from users who can't use it
Bug: T228609
Change-Id: I3bce2b8ae9316ccc9ee77140de56f616ed981b24
2019-07-27 09:53:33 +00:00
James D. Forrester 142bda9170 build: Upgrade phan-taint-check-plugin from 1.5.x to 2.0.1
Change-Id: I456638fd0b59b0acebcc0e873f171d1ef0f69564
2019-07-11 14:09:30 +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
rvogel b9f768e20a Refactor includes to src #2
Bug: T218210

Change-Id: I079e6e819c079b68bbfecdac0d873b26d4e16e86
2019-07-04 13:36:13 +00:00
rvogel b04722a1eb Rework the way user interacts with 2FA settings
Bug: T218210

Change-Id: Iaa6f6ae1c25f47ef43a0e6467474284d89a7a213
2019-07-04 12:45:27 +00:00
Reedy 707f33398f Disable autocomplete on 2FA verification fields
For both enabling and disabling 2FA TOTP

Bug: T226049
Change-Id: Ib0f4c8d1d19fe6cdc403ba306ec44dadbe6320c9
2019-06-19 13:21:29 +01:00
Reedy 8099c0ac7d Make token fields always ltr
Bug: T153556
Change-Id: Iff116722e60dee3e370905c9d7d0b2269e1c4c87
2019-06-18 23:36:20 +01: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