AuthPlugin/zh

直到MediaWiki 1.26版之前的认证插件界面.

已存在的认证插件
分类用户验证扩展程序列出了已存在的认证插件，涵盖了IMAP、轻量活动目录系统等多种情况.

创建一个认证插件
如果您需要编写您自己的插件，可以参考MediaWiki Source Documentation（也可参见latest source code）的原文档.

Instantiate a subclass of AuthPlugin and set to it to authenticate against some external source.

The default behavior is not to do anything, and use the local user database for all authentication. A subclass can require that all accounts authenticate externally, or use it only as a fallback; also you can transparently create internal wiki accounts the first time someone logs in who can be authenticated externally.

备选
As mentioned above, a subclass can fall back to local (i.e. mediawiki db) authentication. It does this by returning false when its strict method is being called. The $wgUser object then proceeds to compare the submitted password to the one in its database.

See this excerpt of includes/User.php for details, method checkPassword: if( $wgAuth->authenticate( $this->getName, $password ) ) { return true; } elseif( $wgAuth->strict ) { /* 认证插件不允许本地认证 */ return false; } elseif( $wgAuth->strictUserAuth( $this->getName ) ) { /* 认证插件不允许这个用户名的本地认证 */ return false; } if ( self::comparePasswords( $this->mPassword, $password, $this->mId ) ) { return true;

As you can see, it is even possible for the AuthPlugin to allow only certain users to fall back to their passwords stored locally by returning false when its strictUserAuth is being called next.

备注

 * The username is translated by MediaWiki before it is passed to the function: First letter becomes upper case, underscore '_' become spaces ' '.
 * If autoCreate returns true (MediaWiki should create a local account for the user) updateExternalDB( $user ) is called anyway. I guess this is to allow the plugin to synchronize the user settings with the external database. updateExternalDB must return true to make MediaWiki store the settings in the local account.
 * AuthPlugin->userExists(...) is not called when the user has already been stored in the wiki DataBase.

安装
Put the files in the extensions folder (preferably a sub folder), than add something akin to the below to your LocalSettings.php

外部会话
In order to check the login status against some external session management scheme, use the AutoAuthenticate hook (MediaWiki 1.5 - 1.12) or UserLoadFromSession (since MediaWiki 1.13). You may also use (since MediaWiki 1.14). These hooks can be used to implement a single-signon setup, in addition to simple account sharing.

参见

 * 扩展:中心认证