Use AuthManager on special pages
authorGergő Tisza <gtisza@wikimedia.org>
Tue, 22 Sep 2015 22:50:04 +0000 (22:50 +0000)
committerGergő Tisza <gtisza@wikimedia.org>
Mon, 16 May 2016 15:12:13 +0000 (15:12 +0000)
commit3617c982c9db793515818e1468fa827ae5880358
treecc7b833f9dc1abceaac2380ea9208cee39742dac
parentd245bd25aef1cc7f17f2323ca4d557cd820cc469
Use AuthManager on special pages

Rewrite authentication-related special pages to use AuthManager.
All the changes mentioned below only take effect when
$wgDisableAuthManager is false.

LoginForm is rewritten to use HTMLForm and split into UserLogin
and CreateAccount; ChangePassword and PasswordReset are rewritten;
ChangeEmail and Preferences are updated. Four new special pages
are added to handle the new capabilities of AuthManager (linked
accounts, secondary authentication providers): LinkAccounts,
UnlinkAccounts, ChangeCredentials, RemoveCredentials.

The old form-based hooks (ChangePasswordForm, UserCreateForm,
UserLoginForm) are deprecated. A new, more generic hook is
available to alter the forms (AuthChangeFormFields);
form changes that involve new fields should be done via
$wgAuthManagerConfig.

UserLoginComplete is limited to web-based login; for more
generic functionality UserLoggedIn can be used instead.

Hooks that assume password-based login (PrefsPasswordAudit,
AbortChangePassword) are removed; the first functionality
is replaced by ChangeAuthenticationDataAudit, the second is
handled by AuthManager. LoginPasswordResetMessage is removed,
the functionality can be recreated via authentication providers.

There are several smaller backwards incompatible changes:
* Adding fields to the login/signup forms by manipulating the
  template via the extraInput/extrafields parameters is not
  supported anymore. Depending on the authn configuration the
  login/signup process might be multistep and it would be
  complicated to ensure that extensions can access the data
  at the right moment. Instead, you can create an
  AuthenticationProvider which can define its own fields and
  process them when the authentication is over.
  (There is B/C support for a transitional period that  works with
  the default login form, but might break with configurations that
  require multiple steps or redirects.)
* Removed cookie redirect check. This was added in 2003 in 9ead07fe9
  for the benefit of bots, but with MediaWiki having an API these days
  there is little reason to keep it. Same for the wpSkipCookieCheck
  flag (added in 2008 in 29c73e8265).
* Instead of embedding a password field on sensitive special pages
  such as ChangeEmail, such pages rely on AuthManager for elevated
  security (which typically involves requiring the user to log in again
  unless their last login was more than a few minutes ago).
  Accordingly, wgRequirePasswordforEmailChange is removed.
* Special:ChangePassword requires login now.
* Special:ResetPassword now sends a separate email to each user when called
  with a shared email address.
* the Reason field had a message with 'prefsectiontip' class
  which was sorta broken but used in extensions for formatting.
  HTMLForm does not support that, so this commit turns it into a help message
  which will break formatting. See https://gerrit.wikimedia.org/r/#/c/231884

Bug: T110277
Change-Id: I8b52ec8ddf494f23941807638f149f15b5e46b0c
Depends-On: If4e0dfb6ee6674f0dace80a01850e2d0cbbdb47a
41 files changed:
autoload.php
docs/hooks.txt
includes/DefaultSettings.php
includes/EditPage.php
includes/Preferences.php
includes/auth/EmailNotificationSecondaryAuthenticationProvider.php [new file with mode: 0644]
includes/exception/UserNotLoggedIn.php
includes/skins/SkinTemplate.php
includes/specialpage/AuthManagerSpecialPage.php [new file with mode: 0644]
includes/specialpage/LoginSignupSpecialPage.php [new file with mode: 0644]
includes/specialpage/SpecialPage.php
includes/specialpage/SpecialPageFactory.php
includes/specials/SpecialChangeCredentials.php [new file with mode: 0644]
includes/specials/SpecialChangeEmail.php
includes/specials/SpecialChangePassword.php
includes/specials/SpecialCreateAccount.php
includes/specials/SpecialLinkAccounts.php [new file with mode: 0644]
includes/specials/SpecialPasswordReset.php
includes/specials/SpecialRemoveCredentials.php [new file with mode: 0644]
includes/specials/SpecialUnlinkAccounts.php [new file with mode: 0644]
includes/specials/SpecialUserLogin.php [new file with mode: 0644]
includes/specials/SpecialUserLogout.php [new file with mode: 0644]
includes/specials/SpecialUserlogin.php [deleted file]
includes/specials/SpecialUserlogout.php [deleted file]
includes/specials/helpers/LoginHelper.php [new file with mode: 0644]
includes/specials/pre-authmanager/README [new file with mode: 0644]
includes/specials/pre-authmanager/SpecialChangeEmail.php [new file with mode: 0644]
includes/specials/pre-authmanager/SpecialChangePassword.php [new file with mode: 0644]
includes/specials/pre-authmanager/SpecialCreateAccount.php [new file with mode: 0644]
includes/specials/pre-authmanager/SpecialPasswordReset.php [new file with mode: 0644]
includes/specials/pre-authmanager/SpecialUserlogin.php [new file with mode: 0644]
includes/specials/pre-authmanager/SpecialUserlogout.php [new file with mode: 0644]
includes/templates/Usercreate.php
includes/templates/Userlogin.php
includes/user/PasswordReset.php [new file with mode: 0644]
includes/user/User.php
languages/i18n/en.json
languages/i18n/qqq.json
languages/messages/MessagesEn.php
tests/phpunit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php [new file with mode: 0644]
tests/phpunit/includes/user/PasswordResetTest.php [new file with mode: 0644]