简体   繁体   English

将用户组添加到Luracast Restler API

[英]Adding user groups to Luracast Restler API

I'm trying to add user groups in my API developed using Luracast Restler using the example class "AccessControl" which implements the iAuthenticate class from Restler. 我正在尝试使用示例类“ AccessControl”(它实现了Restler的iAuthenticate类)在使用Luracast Restler开发的API中添加用户组。

Files: https://gist.github.com/anonymous/d6a315d1f29dc7722b7d 文件: https//gist.github.com/anonymous/d6a315d1f29dc7722b7d

The problem I'm having is with the method defined in AccessControl::__isAllowed() like so: 我遇到的问题是在AccessControl :: __ isAllowed()中定义的方法,如下所示:

Resources::$accessControlFunction = 'AccessControl::verifyAccess';

AccessControl::verifyAccess is never called, so I can't use 永远不会调用AccessControl :: verifyAccess,所以我不能使用

$m['class']['AccessControl']['properties']['requires']

to read the requirements for the method being called in the API. 读取API中所调用方法的要求。

The token system I've added is simply a unique identifier based on a number of criteria which the user gets when a POST /user/token is processed with the correct information. 我添加的令牌系统只是一个基于多个条件的唯一标识符,当使用正确的信息处理POST / user / token时,用户将获得多个条件。

How can I make this work like it should? 我怎样才能使这项工作正常进行? According to the docs for Restler, I should be able to have a method defined like I did and it should return a boolean value, like it does. 根据Restler的文档,我应该能够像我一样定义一个方法,并且它应该返回一个布尔值。 But it never gets called, so... 但是它从未被调用过,所以...

Boy, do I feel stupid. 男孩,我感到愚蠢吗? Turns out I don't actually need the $accessControlFunction. 原来,我实际上不需要$ accessControlFunction。 I just had to use {@Requires ...} instead of {@requires ...} in my Test.php class. 我只需要在Test.php类中使用{@Requires ...}而不是{@requires ...}。

Carry on, good people! 继续,好人!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM