首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用ALFA和XACML编写一个示例ABAC授权策略

使用ALFA和XACML编写一个示例ABAC授权策略
EN

Stack Overflow用户
提问于 2014-10-09 00:46:04
回答 1查看 1.4K关注 0票数 1

我是XACML新手,正在使用ALFA编写策略。我想写的政策是在一家银行设定2000美元的转账限额。如果要转移的金额大于该数额,则应拒绝该操作。

我该怎么做?

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2014-10-09 06:53:51

您所拥有的用例非常简单。我建议你先用英语写,然后用阿尔法写:

  • 用户可以在type==bank account资源上执行type==bank account当且仅当amount transferred < the amount limit (例如,2000年) ==> 允许
  • ==> 拒绝的所有其他案例

在阿尔法,上述政策成为

代码语言:javascript
复制
namespace policies{
    attribute actionId{
        category = actionCat
        id = "actionId"
        type = string
    }

    attribute resourceType{
        category = resourceCat
        id = "resourceType"
        type = string
    }

    attribute amount{
        category = resourceCat
        id = "amount"
        type = double
    }
    /**
     * The limit could be a subject attribute in the case it's user-specific
     */
    attribute limit{
        category = subjectCat
        id = "limit"
        type = double
    }

    /* 
     * A user can do the `action==transfer` on a resource of `type==bank account` if and only if the `amount transferred 
     * < the amount limit` (e.g. 2000 in your case) ==> **permit**
     * 
     */
     policy transfer{
        target clause actionId == "transfer" and resourceType=="bank account"
        apply firstApplicable
        rule allow{
            condition amount <= limit
            permit
        }
        rule denyTransfer{
            deny
        }
     }
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26268648

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档