Руководство: сброс паролей

From mediawiki.org
This page is a translated version of the page Manual:Resetting passwords and the translation is 51% complete.
Outdated translations are marked like this.

Существует множество ситуаций, когда пользователю может потребоваться сбросить пароль. Как правило, люди либо забывают свой пароль, либо сталкиваются с каким-либо нарушением безопасности, которое могло привести к раскрытию их пароля. В большинстве случаев они могут сбросить свой собственный пароль using "Email new password".

В ситуациях, когда пользователь забывает свое имя учетной записи или теряет доступ к своей электронной почте, администратор или системный администратор может принять дополнительные меры.

Методы

Use Special:UserLogin

Если вы знаете имя пользователя для учетной записи, вы можете использовать функцию «Отправить новый пароль по электронной почте» на странице Special:UserLogin. Чтобы использовать эту функцию, посетите страницу Special:UserLogin соответствующей вики, заполните поле «Имя пользователя» формы и нажмите кнопку «Отправить новый пароль по электронной почте». Временный пароль вместе с инструкциями по сбросу пароля учетной записи будет отправлен на адрес электронной почты, связанный с именем пользователя. Это произойдет, даже если адрес электронной почты не подтвержден.

Поиск имени пользователя для данного адреса электронной почты

Если вы знаете адрес электронной почты пользователя, но не знаете его имя пользователя, query the user table of the MediaWiki database, чтобы найти соответствующее имя пользователя. Например, чтобы найти имя пользователя для user@example.com, выполните следующий запрос:

SELECT user_name FROM user WHERE user_email = 'user@example.com';

Use the changePassword.php maintenance script

The changePassword.php maintenance script allows system administrators to change the password for an account. For complete instructions see changePassword.php . If you are already familiar with maintenance scripts, run the following command from maintenance subdirectory:

# set the password for username 'example' to 'newpassword'
php run.php changePassword.php --user=example --password=newpassword

Предупреждение: Системные администраторы не должны знать незашифрованный пароль для учетных записей пользователей. Пользователь может использовать один и тот же пароль на многих разных сайтах. Если одна из их учетных записей, использующих тот же пароль, будет скомпрометирована, то подозрение может пасть на администратора. It is better to use "Email new password" to force the user to reset the password for their own account or to set a temporary password the user changes directly afterwards.


Use Special:PasswordReset

Special:PasswordReset allows accounts with the 'editmyprivateinfo' permission to reset account passwords for the local installation of MediaWiki.

To use:

  • Введите имя пользователя, которое вы хотите сбросить, в соответствующем поле и нажмите «Сбросить пароль».
  • Автоматически сгенерированный пароль будет отправлен пользователю по электронной почте.

For automatically inserting the username in links, use Special:PasswordReset?wpUsername=Foo.

Differences between Special:PasswordReset and Special:ChangePassword

MediaWiki differentiates between "resetting" and "changing" a password. In password reset request (via Special:PasswordReset or from the login page), you will be asked to provide either an email and/or username (this is configurable) and then an email is automatically sent to you with a generated password. No login is required to access this page, but might be restricted with internal permission checks.

In password change request (via Special:ChangePassword), you'll be able to directly change the password on the spot (give the old one, and choose new one), but login is required to access the page. So if you cannot access Special:ChangePassword, use Special:PasswordReset to first get a temporary password to log in. But if you can access the former page, use it directly to change the password, this eliminates the need for the email stage. Special:PasswordReset can be disabled with Manual:$wgPasswordResetRoutes setting, if that's the case, and you cannot access Special:ChangePassword, then you need to ask your system administrator for help.


Use the resetpassword API

The resetpassword API provides the same functionality as Special:PasswordReset.

Прямая модификация базы данных

To reset a password you can change the value of the user_password field inside the user table in your database. However, it's generally far easier and safer to use "Email new password" or use the changePassword.php script. Вы должны использовать прямую модификацию БД только в крайнем случае, так как очень легко случайно испортить вашу вики. Всегда делайте резервную копию своей базы данных, прежде чем вносить какие-либо изменения вручную. The following only works when using MediaWiki's default authentication provider. If you are using an extension that modifies the authentication process (Like LDAPAuth), the following may not work.

The format you see in the user table will depend on $wgPasswordDefault in LocalSettings.php . However if you use a different format, it will automatically be changed to the correct format the next time the user logs in. Thus for this guide, we show how to manually set the "B" format. This format is very easy to set from an SQL query. It is not the default format as it is weaker than pbkdf2, however that's ok as the user_password field will be upgraded to the correct format the next time the user logs in.

MySQL salted (1234 is the salt. You can replace it with any number as long as both places the number is used are the same)
UPDATE `user` SET user_password = CONCAT(':B:1234:', MD5(CONCAT('1234-', MD5('somepass')))) WHERE user_name = 'someuser';
PostgreSQL salted
update mwuser SET user_password = text(':B:1234:') || MD5(text('1234-') || MD5('somepass')) WHERE user_name = 'someuser';

Примечания

Также может помочь перезапуск Apache и очистка кеша браузера.

Вы можете скопировать известный пароль из одной учетной записи в другую:

SELECT user_id, user_name, user_password FROM user;
+---------+-----------+----------------------------------------------+
| user_id | user_name | user_password                                |
+---------+-----------+----------------------------------------------+
|       1 | User1     | :B:1d8f41af:1ba8866d9c43d30b7bc037db03a067de |
|       2 | User2     | :B:ee53710f:4291b056175513a5602d48eaeb79705c |
+---------+-----------+----------------------------------------------+

UPDATE user SET user_password = ':B:ee53710f:4291b056175513a5602d48eaeb79705c' WHERE user_id = 1;