Node Acl动态链接 [英] Node Acl dynamic links

查看:117
本文介绍了Node Acl动态链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用npm模块Acl来实现ACL系统。主页可以在以下位置找到: https://github.com/OptimalBits/node_acl

I'm trying to use the npm module Acl to implement an ACL system. The homepage can be found here: https://github.com/OptimalBits/node_acl.

该文档显示了很多非常简单的示例,这些示例提供了角色访问权限。特别是,这里有一段不错的代码:

The documentation shows a lot of very simple examples for giving a role access. In particular, there is a good piece of code here:

acl.allow([
    {
        roles:['guest','member'], 
        allows:[
            {resources:'blogs', permissions:'get'},
            {resources:['forums','news'], permissions:['get','put','delete']}
        ]
    },
    {
        roles:['gold','silver'], 
        allows:[
            {resources:'cash', permissions:['sell','exchange']},
            {resources:['account','deposit'], permissions:['put','delete']}
        ]
    }
])

不幸的是,文档没有显示任何更复杂的url的示例,例如'/ blogs /:id / today'。是否可以为此类动态网址设置ACL?

Unfortunately, the docs don't show any examples of a more complicated url like '/blogs/:id/today'. Is it possible to set acls for these kinds of dynamic urls?

而且,我还需要指定仅某些用户可以获取自己的信息。这意味着只有在用户ID与网址相同的情况下, users /:id才有效。

And, I also need to specify that only certain users can get their own information. This means that 'users/:id', should only work if the user's id is the same as that of the url. Is this possible?

推荐答案

尽管文档确实说过节点acl支持此处的动态url。但是在查看源代码之后,我们找不到任何支持访问动态网址的参考。

Although docs do say that node acl supports for the dynamic urls here. But after looking at the source code we do not find any reference which supports the access to the dynamic urls.

还有一个打开github问题,请在此处 https://github.com/OptimalBits/node_acl/issues / 192 指向相同的位置。

There is also an open github issue here https://github.com/OptimalBits/node_acl/issues/192 which points the same.

尽管我们可以实现自己的中间件过滤器来支持动态url,但我想应该是

Although we can implement our own middleware filters to support for the dynamic urls , but I guess instead of that it should be fixed in node acl library itself.

结论:-节点ACL库不支持带参数的网址(即动态网址)。
但是,如果我们仍然想使用Node ACL库来动态生成URL,则可以使用https://github.com/OptimalBits/node_acl/issues/192#issuecomment-226761840

Conclusion:- Node ACL library does not supports for urls with params (i.e. dynamic urls). But if we still want to use Node ACL library for dynamic urls the suggestion from the https://github.com/OptimalBits/node_acl/issues/192#issuecomment-226761840 can be used.

这篇关于Node Acl动态链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆