我的公司正在寻求实施集中式安全服务,它似乎是一个流行的标准是XACML。我有一个复杂的授权方案,我一直在弄清楚如何使用XACML策略的属性来定义它。
我正在处理的系统有几个与此身份验证方案相关的部分:
如果用户想要查看特定商品的配方,则必须满足以下任何条件:
根据这些规则,确定用户是否可以查看配方所需的属性似乎包括:
问题:
答案 0 :(得分:4)
(免责声明 - 我为Axiomatics工作,这是XACML和ABAC的领先实现)
好问题。我实际上已经整合了一个授权策略生命周期,它引导用户完成收集需求,识别属性和实施策略的过程。
在您的情况下,让我们完成您的要求
以下任何一项都必须为真:
- 用户必须是食谱的所有者(撰写者的所有者)。
- 用户必须是创建配方的项目的团队成员。 (直接或通过团体会员资格)
- 用户必须是制作配方的组的成员。 (他们需要看到制作它的配方。)
- 用户必须是过去两周内制作配方的组的成员。 (即,在完成制作配方的请求后,他们可以继续查看配方两周以纠正任何问题。)
- 用户必须是管理员。
我喜欢将要求作为主语 - 动词 - 对象重新修改,例如:用户可以查看配方...根据此模型,您的原始要求可以重新编写如下:
您可以将属性分解为不同的类别(或语法功能)。 XACML本身使用类别,因此这是实现使用XACML(或ALFA)的自然步骤。
在这个类别中,从它的外观来看,你只有:
下一步是实施您的政策。您可以使用ALFA(授权的缩写语言)。 Axiomatics有一个Eclipse plugin,可将ALFA转换为XACML 3.0。
让我们创建一个处理食谱的策略集。该策略集将包含处理操作视图的策略。反过来,该政策将包含满足每项要求的规则。
policyset recipe{
target clause objectType == "recipe"
apply firstApplicable
/**
* View recipes
*/
policy viewRecipe{
target clause actionId == "view"
apply firstApplicable
/**
* Administrators can view all recipes
*/
rule administrator{
target clause user.role == "administrator"
permit
}
/**
* Recipe owners can view their own recipes
*/
rule owner{
permit
condition user.userId == recipe.owner
}
/**
* Users can view recipes in their project
*/
rule sameProject{
permit
condition user.assignedProject == recipe.assignedProject
}
/**
* Users can view recipes in their project
*/
rule sameGroup{
target clause recipe.stage == "manufacturing"
permit
condition user.assignedGroup == recipe.assignedGroup
}
/**
* Users can view recipes in their project
*/
rule sameGroupManufactured{
target clause recipe.stage == "manufacturing"
permit
condition user.assignedGroup == recipe.assignedGroup && currentDate<=dateTimeAddDayTimeDuration(dateTimeOneAndOnly(recipe.manufacturedDate),"P14D":dayTimeDuration)
}
}
}
PIP如何收集这些信息?直接来自数据库?通过服务调用存储此信息的系统?
PIP只是外部属性源的抽象概念。它可以是任何东西。不同的实现将具有不同的PIP连接器。例如,Axiomatics Policy Server提供SQL,LDAP和REST服务的连接器。这涵盖了客户的大部分需求。
您比较两种技术,但它们有点不同。 OAuth 2.0首先关注身份验证。它开始打败password anti-pattern。然后需要定义权限,或者在OAuth中调用它们的范围。但是这些范围只是准时权限。您仍然依赖目标应用程序来发布一组有效的作用域,但您仍然无法进行细粒度的访问控制。我的同事写了一篇关于这个主题的三部分博客,第一部分你可以read here。
我希望这会有所帮助。随意向我询问后续问题或推文。
<?xml version="1.0" encoding="UTF-8"?>
<!--This file was generated by the ALFA Plugin for Eclipse from Axiomatics AB (http://www.axiomatics.com).
Any modification to this file will be lost upon recompilation of the source ALFA file-->
<xacml3:PolicySet xmlns:xacml3="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
PolicySetId="http://axiomatics.com/alfa/identifier/so.recipe"
PolicyCombiningAlgId="urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:first-applicable"
Version="1.0">
<xacml3:Description>Control access to recipes</xacml3:Description>
<xacml3:PolicySetDefaults>
<xacml3:XPathVersion>http://www.w3.org/TR/1999/REC-xpath-19991116</xacml3:XPathVersion>
</xacml3:PolicySetDefaults>
<xacml3:Target>
<xacml3:AnyOf>
<xacml3:AllOf>
<xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<xacml3:AttributeValue
DataType="http://www.w3.org/2001/XMLSchema#string">recipe</xacml3:AttributeValue>
<xacml3:AttributeDesignator
AttributeId="so.objectType"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
MustBePresent="false"
/>
</xacml3:Match>
</xacml3:AllOf>
</xacml3:AnyOf>
</xacml3:Target>
<xacml3:Policy xmlns:xacml3="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
PolicyId="http://axiomatics.com/alfa/identifier/so.recipe.viewRecipe"
RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable"
Version="1.0">
<xacml3:Description>View recipes</xacml3:Description>
<xacml3:PolicyDefaults>
<xacml3:XPathVersion>http://www.w3.org/TR/1999/REC-xpath-19991116</xacml3:XPathVersion>
</xacml3:PolicyDefaults>
<xacml3:Target>
<xacml3:AnyOf>
<xacml3:AllOf>
<xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<xacml3:AttributeValue
DataType="http://www.w3.org/2001/XMLSchema#string">view</xacml3:AttributeValue>
<xacml3:AttributeDesignator
AttributeId="so.actionId"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action"
MustBePresent="false"
/>
</xacml3:Match>
</xacml3:AllOf>
</xacml3:AnyOf>
</xacml3:Target>
<xacml3:Rule
Effect="Permit"
RuleId="http://axiomatics.com/alfa/identifier/so.recipe.viewRecipe.administrator">
<xacml3:Description>Administrators can view all recipes</xacml3:Description>
<xacml3:Target>
<xacml3:AnyOf>
<xacml3:AllOf>
<xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<xacml3:AttributeValue
DataType="http://www.w3.org/2001/XMLSchema#string">administrator</xacml3:AttributeValue>
<xacml3:AttributeDesignator
AttributeId="so.user.role"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
MustBePresent="false"
/>
</xacml3:Match>
</xacml3:AllOf>
</xacml3:AnyOf>
</xacml3:Target>
</xacml3:Rule>
<xacml3:Rule
Effect="Permit"
RuleId="http://axiomatics.com/alfa/identifier/so.recipe.viewRecipe.owner">
<xacml3:Description>Recipe owners can view their own recipes</xacml3:Description>
<xacml3:Target />
<xacml3:Condition>
<xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:any-of-any">
<xacml3:Function FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal"/>
<xacml3:AttributeDesignator
AttributeId="so.user.userId"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
MustBePresent="false"
/>
<xacml3:AttributeDesignator
AttributeId="so.recipe.owner"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
MustBePresent="false"
/>
</xacml3:Apply>
</xacml3:Condition>
</xacml3:Rule>
<xacml3:Rule
Effect="Permit"
RuleId="http://axiomatics.com/alfa/identifier/so.recipe.viewRecipe.sameProject">
<xacml3:Description>Users can view recipes in their project</xacml3:Description>
<xacml3:Target />
<xacml3:Condition>
<xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:any-of-any">
<xacml3:Function FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal"/>
<xacml3:AttributeDesignator
AttributeId="so.user.assignedProject"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
MustBePresent="false"
/>
<xacml3:AttributeDesignator
AttributeId="so.recipe.assignedProject"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
MustBePresent="false"
/>
</xacml3:Apply>
</xacml3:Condition>
</xacml3:Rule>
<xacml3:Rule
Effect="Permit"
RuleId="http://axiomatics.com/alfa/identifier/so.recipe.viewRecipe.sameGroup">
<xacml3:Description>Users can view recipes in their project</xacml3:Description>
<xacml3:Target>
<xacml3:AnyOf>
<xacml3:AllOf>
<xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<xacml3:AttributeValue
DataType="http://www.w3.org/2001/XMLSchema#string">manufacturing</xacml3:AttributeValue>
<xacml3:AttributeDesignator
AttributeId="so.recipe.stage"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
MustBePresent="false"
/>
</xacml3:Match>
</xacml3:AllOf>
</xacml3:AnyOf>
</xacml3:Target>
<xacml3:Condition>
<xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:any-of-any">
<xacml3:Function FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal"/>
<xacml3:AttributeDesignator
AttributeId="so.user.assignedGroup"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
MustBePresent="false"
/>
<xacml3:AttributeDesignator
AttributeId="so.recipe.assignedGroup"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
MustBePresent="false"
/>
</xacml3:Apply>
</xacml3:Condition>
</xacml3:Rule>
<xacml3:Rule
Effect="Permit"
RuleId="http://axiomatics.com/alfa/identifier/so.recipe.viewRecipe.sameGroupManufactured">
<xacml3:Description>Users can view recipes in their project</xacml3:Description>
<xacml3:Target>
<xacml3:AnyOf>
<xacml3:AllOf>
<xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<xacml3:AttributeValue
DataType="http://www.w3.org/2001/XMLSchema#string">manufacturing</xacml3:AttributeValue>
<xacml3:AttributeDesignator
AttributeId="so.recipe.stage"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
MustBePresent="false"
/>
</xacml3:Match>
</xacml3:AllOf>
</xacml3:AnyOf>
</xacml3:Target>
<xacml3:Condition>
<xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
<xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:any-of-any">
<xacml3:Function FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal"/>
<xacml3:AttributeDesignator
AttributeId="so.user.assignedGroup"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"
MustBePresent="false"
/>
<xacml3:AttributeDesignator
AttributeId="so.recipe.assignedGroup"
DataType="http://www.w3.org/2001/XMLSchema#string"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
MustBePresent="false"
/>
</xacml3:Apply>
<xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:any-of">
<xacml3:Function FunctionId="urn:oasis:names:tc:xacml:1.0:function:dateTime-greater-than-or-equal"/>
<xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:dateTime-add-dayTimeDuration" >
<xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:dateTime-one-and-only" >
<xacml3:AttributeDesignator
AttributeId="so.recipe.manufacturedDate"
DataType="http://www.w3.org/2001/XMLSchema#dateTime"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
MustBePresent="false"
/>
</xacml3:Apply>
<xacml3:AttributeValue
DataType="http://www.w3.org/2001/XMLSchema#dayTimeDuration">P14D</xacml3:AttributeValue>
</xacml3:Apply>
<xacml3:AttributeDesignator
AttributeId="currentDate"
DataType="http://www.w3.org/2001/XMLSchema#dateTime"
Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment"
MustBePresent="false"
/>
</xacml3:Apply>
</xacml3:Apply>
</xacml3:Condition>
</xacml3:Rule>
</xacml3:Policy>
</xacml3:PolicySet>