簡體   English   中英

Luracast Restler多個身份驗證類不允許訪問

[英]Luracast Restler Multiple Authentication Classes Not Allowing Access

我定義了兩個認證類。

  1. API密鑰(APIKeyAuth)
  2. OAUTH2(OAUTH2Server)

在我的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(我認為不應這樣做,因為其余方法已被修飾為使用API​​KeyAuth。

如此一來,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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM