【问题标题】:Perform user token check in CakePHP API routes在 CakePHP API 路由中执行用户令牌检查
【发布时间】:2012-10-03 02:32:33
【问题描述】:

我正在创建一个 API,我想知道检查用户令牌的最佳做法是什么。

这是我正在使用的路径及其随附规则的示例:

http://www.domain.com/api/user/ede12-snip-f50b9/project/1

路由器::连接( "/api/user/:token/project/:projectid/issues", array("action" => "issues", "controller" => "projects", "[method]" => "GET"), array("id" => "[0-9]+", 'pass' => array('token', 'projectid')) );

这可行,但是我必须在每个操作中检查令牌凭据。而且我不希望那样。

有人知道另一种方法吗?

【问题讨论】:

    标签: cakephp rest


    【解决方案1】:
    This works, but then I have to check the token credentials in every action. And I don't want that.
    

    如果您的 API 是无状态的,则没有其他方法。

    【讨论】:

    • 当然,我的意思是:我必须在每个公共操作函数的开头添加相同的代码。
    猜你喜欢
    • 2017-04-29
    • 1970-01-01
    • 2019-09-22
    • 1970-01-01
    • 1970-01-01
    • 2020-01-26
    • 2017-02-23
    • 1970-01-01
    • 2014-02-10
    相关资源
    最近更新 更多