REST API和OAuth - 验证发送请求的用户是否拥有目标资源的最佳做法是什么?

时间:2015-07-22 22:26:47

标签: php api rest oauth slim

我们有一个带有端点的API,用于我们想要限制访问的用户配置文件信息。

我们的应用程序后端是在Slim框架上用PHP构建的,所以我们在路由中间件时处理授权:

class Authorization {
    public function authorizeAccess() {
        ... // check if oauth token corresponds to the correct id
    }
}

$authorizer = new Authorization(); 

$app->get('/user/:id/profile', [$authorizer, 'authorizeAccess'], function() use ($app) {
    ...
};

这是一个很好的方法吗?

0 个答案:

没有答案