[英]Luracast Restler Multiple Authentication Classes Not Allowing Access
我定義了兩個認證類。
在我的index.php中,我定義了以下內容
$r = new Restler();
$r->addAuthenticationClass('APIKeyAuth');
$r->addAuthenticationClass('OAUTH2Server');
然后,我保護APIKeyAuth的其余方法之一
/**
* @access protected
* @class APIKeyAuth{@requires apikey}
*/
public function .......etc
如果我對其進行調試,則將通過第一步,並且$ authObj(請參閱restler.php中的以下代碼)將為APIKeyAuth。 它檢查__isAllowed並返回true ...這很好。
然后,它通過OAUTH2Server(我認為不應這樣做,因為其余方法已被修飾為使用APIKeyAuth。
如此一來,OAUTH2Server中的__isAllowed為false,因此用戶將獲得未授權的響應。
foreach ($this->authClasses as $authClass) {
$authObj = Scope::get($authClass);
if (!method_exists($authObj,
Defaults::$authenticationMethod)
) {
throw new RestException (
500, 'Authentication Class ' .
'should implement iAuthenticate');
} elseif (
!$authObj->{Defaults::$authenticationMethod}()
) {
throw new RestException(401);
}
}
我是否需要更改OAUTH2服務器以檢查其是否使用API密鑰並添加邏輯? (似乎是錯誤的方法)。
Restler直至RC5依次處理身份驗證類,這意味着所有身份驗證類必須返回true才能通過受保護的api調用
從RC6開始,這已更改為並行,這意味着身份驗證類中的任何一個都可以允許訪問受保護的api
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.