Luracast Restler多个身份验证类不允许访问

时间:2015-03-19 01:09:50

标签: php restful-authentication restler

我定义了两个身份验证类。

  1. API密钥(APIKeyAuth)
  2. OAUTH2(OAUTH2Server)
  3. 在我的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​​密钥并添加逻辑? (似乎错误的方法)。

1 个答案:

答案 0 :(得分:1)

RC5上的Restler连续处理身份验证类,这意味着所有身份验证类必须返回true才能通过受保护的api调用

由于RC6已经变为并行,这意味着任何一个身份验证类都可以允许访问受保护的api

相关问题