你在哪里存储的政策基本上是无能为力的。这取决于您使用的引擎,例如AuthZForce(我已经把作者钉住了,所以他可以插入),SunXACML,WSO2或Axiomatics。
声明:我为Axiomatics工作。我们确实使用数据库来存储XACML策略,但不会更改授权要求或建模。
我对你原来的帖子有一些评论。
subject.id==resource.ownerId
是我们通常称为XACML中的一个条件。您将两个属性进行比较以实现关系。
- 您提到了权限,例如
DELETE_USER
。在XACML中,你通常将它们分成原子属性,例如一方面是动作,另一方面是对象或资源(USER
)。虽然RBAC是基于角色和许可的,但ABAC是基于属性的。理想的情况是这些属性表示一个方面(作为一个用户,试图删除 ...)
ROLE
仍然存在ABAC。这将是您的政策的基础。
- 功能和公司是您使用的属性。
考虑到这一点,你可以写的政策,如以下(使用ALFA符号):
namespace axiomatics{
namespace user{
attribute role{
category = subjectCat
id = "axiomatics.user.role"
type = string
}
attribute company{
category = subjectCat
id = "axiomatics.user.company"
type = string
}
attribute userId{
category = subjectCat
id = "axiomatics.user.userId"
type = string
}
}
namespace action{
attribute actionId{
category = actionCat
id = "axiomatics.action.actionId"
type = string
}
}
namespace resource{
attribute company{
category = resourceCat
id = "axiomatics.resource.company"
type = string
}
attribute owner{
category = resourceCat
id = "axiomatics.resource.owner"
type = string
}
}
policyset springapp{
apply firstApplicable
policy employees{
target clause user.role == "employee"
apply firstApplicable
/**
* Employees can create roles in their own company
*/
rule createRole{
target clause action.actionId=="create"
condition user.company==resource.company
permit
}
/**
* Employees can delete roles they own
*/
rule allowDelete{
target clause action.actionId == "delete"
condition user.userId == resource.owner
permit
}
}
}
}
谢谢你的详细解答。我看到我自己的解决方案与XACML类似,这是完美的,因为迁移不会那么困难。但对我来说,将策略存储在数据库中(以便在运行时更改它们)非常重要。你知道哪些免费或开源解决方案支持这个吗? – benkuly
我会假设所有的开源引擎都可以从数据库中读取XACML策略。试试AT&T的XACML,WSO2或AuthZForce,你提到的那个。它是OSS社区中最新和最完整的之一 –
您是否知道我应该如何或应该开始一个新问题。问题是,他们都没有或稀疏的文件,所以我不知道哪一个是最适合数据库策略。 – benkuly