how do I know which api is called in iAuthenticate.__isAllowed

269 views Asked by At

I use Restler as the OAuth Server, and implement iAuthenticate.__isAllowed in OAuthServer

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

when i have multiple apis like

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

Here is the question, I have different scope in each api, How do I know the exact api is called in __isAllowed??

I know is a solution to use "url" as scope, but what if I still wana know how to use "email" or "member" as scope ??

thanks

1

There are 1 answers

0
Arul Kumaran On

Since Authentication Class is also an api class it gets the rester instance as restler property

Restler has apiMethodInfo which is an instance of ApiMethodInfo so you can do the following to get the data

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;
    }
}