Azure移动服务自定义API中多个路由的权限

Azure移动服务自定义API中多个路由的权限,api,azure,azure-mobile-services,Api,Azure,Azure Mobile Services,我在Azure移动服务中工作,在那里我制作了一个自定义api。对于那些用户,可以设置权限(如public、application、user和admin),这非常有用。但是我需要多级api(比如/api/user/profile/{userId}),并且能够为子级api设置一些权限 我发现可以使用以下代码添加其他级别的api路径 exports.register = function (api) { /* Get public user profile on some other use

我在Azure移动服务中工作,在那里我制作了一个自定义api。对于那些用户,可以设置权限(如public、application、user和admin),这非常有用。但是我需要多级api(比如
/api/user/profile/{userId}
),并且能够为子级api设置一些权限

我发现可以使用以下代码添加其他级别的api路径

exports.register = function (api) {

    /* Get public user profile on some other user */
    api.get('/profile/:userId', getProfileFunc);

    /* Get private profile only for the authenticated user */
    api.get('/profile', getProvateProfileFunc);

    /* Update provate profile only for the authenticated user */
    api.put('/profile', updateProfileFunc);
}

exports.get = getUserListFunc;
api权限是通过顶层的{api name}.json文件设置的。 但是,如何为不同于父api的子级别api设置权限?一个例子:
获取:api/user获取用户列表,是权限应用程序
GET:api/user/profile获取(经过身份验证的)用户的配置文件,因此需要用户权限

user.json中的权限是


我可以使用连接到WAMS的git存储库。

该.json文件支持路由。请尝试以下操作:

{
    "routes": {          
        "/" : { "permission": "public" },
        "/user/profile/:userId" : {
            "get": { "permission": "public" },
            "post": { "permission": "authenticated" }
        }
    }
}
{
    "routes": {          
        "/" : { "permission": "public" },
        "/user/profile/:userId" : {
            "get": { "permission": "public" },
            "post": { "permission": "authenticated" }
        }
    }
}