【问题标题】:how do I know which api is called in iAuthenticate.__isAllowed我怎么知道在 iAuthenticate.__isAllowed 中调用了哪个 api
【发布时间】:2013-12-06 09:47:36
【问题描述】:

我使用 Restler 作为 OAuth Server,并在 OAuthServer 中实现 iAuthenticate.__isAllowed

public function __isAllowed() {
    return self::$server->verifyResourceRequest(static::$request, null, $scope );
}

当我有多个类似的 api 时

$r = new Restler();
$r->addAuthenticationClass('OAuthServer', 'oauth')
$r->addAPIClass('EMail', 'email');
$r->addAPIClass('Member', 'member');

问题来了,我在每个 api 中都有不同的范围,我如何知道在 __isAllowed 中调用了确切的 api??

我知道使用“url”作为范围的解决方案,但如果我仍然想知道如何使用“电子邮件”或“成员”作为范围怎么办??

谢谢

【问题讨论】:

    标签: php oauth-2.0 restler


    【解决方案1】:

    由于 Authentication Class 也是一个 api 类,因此它获取 rester 实例作为 restler 属性

    Restler 有 apiMethodInfo,它是 ApiMethodInfo 的一个实例,因此您可以执行以下操作来获取数据

    class AccessControl implements iAuthenticate
    {
        /**
         * @var \Luracast\Restler\Restler
         */
        public $restler;
    
        public function __isAllowed()
        {
            /**
             * @var \Luracast\Restler\Data\ApiMethodInfo
             */
            $info = $this->restler->apiMethodInfo;
            $info->className;
            $info->methodName;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-12-01
      • 1970-01-01
      • 2012-07-02
      • 2023-03-29
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多