【发布时间】:2017-05-19 10:44:13
【问题描述】:
我的问题,指南和文档有点复杂和令人困惑。 它仅设置为“实现 [ClassName]”,但没有显示示例。
我给定的代码(必须重写的旧代码)如下:
class MyAuthPlugin extends AuthPlugin {
protected $isAuthenticated = false;
function modifyUITemplate( &$template ) {
$template->set( 'usedomain', false );
$template->set( 'useemail', false );
$template->set( 'canreset', false );
$template->set( 'create', false );
}
function autoCreate() {
return true;
}
function userExists( $username ) {
return true; //already handled in ohter function
}
function strict() {
return true;
}
/* Being called twice:
* Login->attemptAutoCreate() (SpecialUserLogin.php) (only for new)
* User->checkPassword() (User.php) external PW-authentication.
*/
function authenticate( $username, $password ) {
global $BBredirect, $BBconnection, $wgRequest;
if($this->isAuthenticated) return true;
$BBConnection['Parameters'] = 'cmd=authenticate&sessionId='.$wgRequest->getVal('sessionId');
$myRequest = new SimpleHttpRequest($BBConnection);
$responseGET = $myRequest->doRequest(SimpleHttpRequest::HTTP_GET);
echo ($responseGET[Content]);
$auth = simplexml_load_string($responseGET[Content]);
if($auth->response->authentication == 'false') {
return false;
}
if($auth->response->authentication == 'ok') {
$this->isAuthenticated = true;
}
return $this->isAuthenticated;
}
function isAuthenticated() {
return $this->isAuthenticated;
}
}
如何将此代码转换为新的 AuthManager 样式? 这个guide 建议了很多不同的类..
-
userExists() → PrimaryAuthenticationProvider::testUserExists()
-
authenticate() → PrimaryAuthenticationProvider::beginPrimaryAuthentication + PasswordAuthenticationRequest(如何将密码传递给进程?)
-
modifyUITemplate() → 来自 AuthenticationProvider 的 AuthenticationRequests(如何?) + AuthChangeFormFields 钩子。
-
autoCreate() 没有直接替换。 (AuthenticationResponse-> 从哪里来?只想强制自动创建)
-
strict() → 不要返回 ABSTAIN(我应该怎么做?不想进行本地身份验证)
-
如何实例化我的类?与
$wgAuth = new MyAuthPLugin()被弃用的说文档。
或者当用户名,密码(哈希),sessionID和secretkey在html-Request中给出时,是否有一种简单的自动登录方法?
【问题讨论】:
标签: php authentication mediawiki