Commit graph

61 commits

Author SHA1 Message Date
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
Martin Urbanec 73a3848557 showqrcode-related RL modules should also target mobile devices
Otherwise, the QR code will not be displayed when using
the mobile interface.

Bug: T214986
Change-Id: I08c3f66d836f5fc854d5c7ae2ca580aa896f3f38
2021-09-05 23:07:35 +02:00
jenkins-bot 005dc5a364 Merge "Remove $wgOATHAuthSecret" 2021-07-01 00:22:02 +00:00
Reedy ec3c499138 Remove $wgOATHAuthSecret
It's unused

Change-Id: Ia62672c36a8241e0f25c69444b3db693aaea9db7
2021-07-01 00:48:17 +01: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
libraryupgrader 255d43e6a1 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 34.0.0 → 35.0.0
* mediawiki/minus-x: 1.1.0 → 1.1.1

npm:
* eslint-config-wikimedia: 0.17.0 → 0.18.1

Additional changes:
* Added the "composer phan" command to conveniently run phan.
* Removing manual extensions for eslint.

Change-Id: I8bb66a4485564d0518f105ccbbdd8f8ba73d20a3
2021-01-30 06:33:24 +00:00
Martin Urbanec b5a187624e Add oathauth-verify-user to oath grant
Change-Id: I4baf29ad39bd56bcbf45670423fd553643af6b55
2021-01-29 00:51:06 +01: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 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
daniel a7b8ce496c Use "user-global" limit for TOTP attempts.
Depends-On: Id680b96be2ea81d29447c4c1abafc8f98a339626
Bug: T251661
Change-Id: I5c81d6cd39a783997cbaf6dc1ca8b5b5008cf0b9
2020-09-03 15:04:44 +02: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
DannyS712 c5ded3d748 Don't try to grant oathauth-enable to *
Bug: T248282
Depends-On: Ia4c04645bff5e19adbc31557449fc0a9b0ed6d5a
Change-Id: I1030ea396abe3b888ecb001f0790f73e7ef3eff0
2020-03-23 02:34:17 +00:00
DannyS712 4f8eca9f43 extension.json - don't use array syntax when hooks only have 1 handler
Change-Id: I143fbcb8a425241164e534b39bc6677750aa5f63
2020-03-11 10:49:27 +00:00
Umherirrender 275a5d4163 Move test-only namespaces to new TestAutoloadNamespaces declaration
Bug: T196090
Change-Id: I90882f3c0da996bd5fc3d5ab07adbe277969c1ba
2019-12-31 00:47:41 +01:00
Reedy 6b993ae3c6 Bump 0.4.4
Change-Id: I3097526954c18c6759461f800168ebeb4a92e9e7
2019-10-23 15:45:50 +01:00
Reedy 9c254ab7e5 Bump 0.4.3
Change-Id: Id6ea1e2e41d64ccdfb02b6b081595c0a2b490329
2019-10-09 22:07:08 +01: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
Reedy 1cfb3fc840 Bump version 0.4.2
After PHP interface change, useful for WebAuthn

Change-Id: I37e53c9a67f7591b5f2a41afaf96695d99a60867
2019-09-28 18:12:21 +01:00
Reedy 94be789597 Bump 0.4.1 for a few small bugfixes
Change-Id: Ia194f096f3cbfeb1b5394f279dbb99e46f3c06df
2019-09-05 14:54:09 +01:00
Reedy 89438231ba Update version to 0.4.0 to keep better track of changes
Especially for usage in Webauthn extension

Change-Id: Id5fae4ec9ffbd188151b8d91e4b6ae9c71c8a2ec
2019-08-30 19:42:48 +00: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
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
Amir Aharoni 53251f752c Split apihelp messages to a separate file
Bug: T189982
Change-Id: I04f84c10c99de9bdd5d7b9828e852615488328db
2019-07-04 20:09:00 +01: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 62d83ab1e6 Bump version to 0.3.0
Change-Id: If1dd738cba260a4270f943b1b98610d47f2023bd
2019-06-19 13:28:43 +01:00
rvogel d1475452a6 Fix remoteExtPath in RL module definition
Change-Id: Ie2a1af68f498d551da77df907a965d4fec0ece65
2019-06-18 22:22:03 +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
Amir Sarabadani 808df6dc55 Add private logging when user disables 2fa for someone else
It's better that we add for when someone enables or disables for self too
But that can be done in a follow-up patch

Bug: T180896
Change-Id: Ic173ebb7e39d22e40fea23c2b906d246adef1e05
2019-04-12 12:10:43 +00:00
Reedy bac94daedb Replace hotp.php with composer library
Adds jakobo/hotp-php 1.0.0

Change-Id: Ifeb43a5e20cd868b35182d4233cdcab154354f84
Depends-On: I6e34c6dcc79fb46496fe63b16064500a5ef3bc43
2019-04-11 17:05:16 +00:00
Reedy 24e4510cf3 Replace base32.php with composer library
Add christian-riesen/base32 1.3.1

Change-Id: I6c8c62bde48ac5793c09d9f0ee7dabf3f4c485ee
Depends-On: If549500ba8aa8c4dbf7bfa43b5f4165e0a39d1f0
2019-04-11 11:45:39 +00:00
Amir Sarabadani a95802a14e Add SpecialDisableOATHForUser
Bug: T195207
Change-Id: I695a376e15e8a95a02849a6ec67b882228852ef8
2018-10-26 14:52:44 +00:00
James D. Forrester 3546c62f19 Drop pre-MW1.32 Special:Preferences (non-OOUI) compatability
Depends-On: I65b89385c3ec28ef01b86dd933dae3801e503631
Change-Id: Id9c840e979b723806883bb3e63d7f2f691fea629
2018-10-04 00:52:06 +00:00
Kunal Mehta 146b26349a Make licensing explicit, add missing GPL file headers
Since this repository has multi-licensed code, add GPL v2+ file headers
to code that had no licensing blocks to make it obvious which files
carry which license.

And add "AND GPL-3.0-or-later" to extension.json's license-name property
to make it clear that this extension does have code that isn't
redistributable under GPL v2.

Change-Id: Id3059fb9596527ef054bec9d89a28f1ccbe2113d
2018-04-10 18:29:26 -07:00
Kunal Mehta 7451a5df33 Move classes to includes/
Change-Id: I2d2a917e5a22f88dc644eb3c33f775642728e1f4
2018-04-09 00:51:39 -07:00
Kunal Mehta e3fc6fdd94 Use SPDX 3.0 license identifier
SPDX released version 3 of their license list (<https://spdx.org/licenses/>),
which changed the FSF licenses to explicitly end in -only or -or-later
instead of relying on an easy to miss + symbol.

Bug: T183858
Change-Id: Ia282470aefef930bd867de521f9c45ded8349193
2018-03-02 15:27:50 -08:00
Jayprakash12345 d7bdefda31 Update at-ease calls in extensions
Bug: T187037
Change-Id: Iae9b24abf3751740bd77e4ab10e01d154a0ea161
2018-02-12 18:24:47 +00:00
Umherirrender 5f8c22e9cd Rename file OATHAuth.hooks.php to match class
Change-Id: Iac3d687f20d6d1805ece0d1c83f3f5e722353a16
2017-12-10 00:24:36 +01:00
Reedy 0f5772e7bd Remove SpecialOATHLogin.php as more AuthManager related cleanup
Change-Id: I9d7fd0a2da0e3e54bb5031d7e70769a2a27703c8
2017-04-01 16:51:41 +01:00
Kunal Mehta a6810b041d Hide empty square for QR code with CSS for no-JS users
Change-Id: Id557bce14a623d894e0b23123c8ef037ddd3cc53
2016-11-14 18:23:53 -08:00
Kunal Mehta bf4637200a Get rid of separate ext.oathauth module
It's only used as a dependency for one module, so it doesn't really make
sense to have it as a separate module.

Change-Id: I0936073358e98d236ce9440d92873a2ea3851e60
2016-11-14 18:23:53 -08:00
Reedy 872a4768ff Allow override of Site prefix without changing sitename
Bug: T147901
Change-Id: Id5b565f9c05b591e3638dbf51dd784224203669c
2016-10-31 14:17:27 +00:00
Reedy e38c68c13e Remove pre authmanager MW support
Change-Id: I46712392e48c263bd30b849777caea8e22650d40
2016-10-15 21:56:40 +01:00
Bryan Davis a6b60d2465 Apply rate limits to all token verifications
Extend the token validation failure checks introduced in I4884f6e to the
other interactions where OATHAuthKey::verifyToken is used.

Depends-On: Ia3add8bbbab0307f036e9b77e752c382da3a0d04
Change-Id: Icbe5cdf561c683dc971a099d61cedff311b26b43
2016-10-07 17:24:32 -07:00
Bryan Davis 36c523ab23 Add an api action to validate an OATH token
Add a new internal action=oathvalidate Action API module that can be
used to validate an OATH token collected from a user. Using the module
requires the 'oathauth-api-all' permission introduced in I4884f6e.

Attempts to call the action for a given user are rate limited to only
allow 10 failures per minute using the new 'badoath' key.

The check is primarily useful as an internal network service in an
environment where MediaWiki and other applications are sharing the same
backing authentication store (e.g. LDAP) and the non-MediaWiki
applications would like to respect the OATH protections enabled on the
MediaWiki install.

Complete usage in an LDAP shared auth environment would look something
like:
* Authenticate a user with the LDAP server via auth-bind
* Call action=query&meta=oath as a privileged user to check for OATH
  protection.
* If OATH is active for the account, prompt the user for their current
  OATH token.
* Call action=oathvalidate as a privileged user to validate the token.
* If validation succeeds, complete authentication.
* If validation fails, do not authenticate the user.

Bug: T144712
Change-Id: I1b18d9f3b99364fc47c760bdfc2047c1cbb5c04a
2016-10-07 16:55:50 -07:00
Bryan Davis 766e18bca1 Add a query meta api option to check for OATH
Add a new internal action=query&meta=oath Action API module that can be
used to check for OATH protection on a given user account. Using the
module requires a new 'oathauth-api-all' permission which is not granted
to any group by default. The permission is also added to the new
'oath' grant so that it can be used via OAuth and bot passwords.

Use of this API is security sensitive and should not be granted lightly.
Configuring a special 'oathauth' user group to grant the needed
'oathauth-api-all' permission is recommended.

This check is primarily useful as an internal network service in an
environment where MediaWiki and other applications are sharing the same
backing authentication store (e.g. LDAP) and the non-MediaWiki
applications would like to respect the OATH protections enabled on the
MediaWiki install.

Bug: T144712
Change-Id: I4884f6efdfa42db82c25eadb70c7aefa98c370e9
2016-10-07 12:10:18 -07:00
Kunal Mehta 525f54186e Set license-name in extension.json
Change-Id: Ie2457a3e5ffee0377facd4a2f62df5aa0ee4559f
2016-06-23 11:23:18 +02:00
Brian Wolff 185bce5859 Fixup qrcode-generating js, to stop race condition.
Previously there was a race condition where the qrcode would
not show if the startup module finished loading prior to the
div that should contain the qrcode being loaded. This quite
commonly happened on wikipedia during a hit where js is cached
(But does not happen locally, my theory is that that is due to
how packets get split over the network but not from localhost).

Change it to use a normal RL module, as that seems best practise.
Also do not load the qrcode js on special pages that do not use it.
Finially, remove position:top as its not needed.

Bug: T136988
Change-Id: I5139f222207203d834bdc979b21c1fc94f242ac2
2016-06-20 03:42:28 -04:00