【问题标题】:Compare attributes inside a XACML policy比较 XACML 策略中的属性
【发布时间】:2016-01-29 05:57:00
【问题描述】:

我正在开发 XACML 策略,并且正在使用 sun.xacml 库。 我想比较两个属性:一个用于主题,一个用于资源,以允许访问资源。

我已经生成了这个 XACML 文件

<?xml version="1.0"?>
<Policy PolicyId="GeneratedPolicy" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:permit-overrides">
  <Description>Policy che permette la lettura del file ai client che hanno un livello di permesso maggiore o uguale al livello di permesso del file richiesto</Description>
  <Target>
<Subjects>
  <AnySubject/>
</Subjects>
<Resources>
  <AnyResource/>
</Resources>
<Actions>
  <Action>
	<ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
	  <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue>
	  <ActionAttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string"/>
	</ActionMatch>
  </Action>
</Actions>
  </Target>
  <Rule RuleId="canRead" Effect="Permit">
<Target>
  <Subjects>
	<AnySubject/>
  </Subjects>
  <Resources>
	<AnyResource/>
  </Resources>
  <Actions>
	<Action>
	  <ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
		<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue>
		<ActionAttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string"/>
	  </ActionMatch>
	</Action>
  </Actions>
</Target>
<Condition FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-greater-than-or-equal">
  <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
	<SubjectAttributeDesignator AttributeId="level-permission" DataType="http://www.w3.org/2001/XMLSchema#string"/>
  </Apply>
  <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">4</AttributeValue>
</Condition>
  </Rule>
  <Rule RuleId="FinalRule" Effect="Deny"/>
</Policy>

问题是资源有等级权限,我想比较主题的等级权限和资源的等级权限,但我不知道怎么做。

非常感谢

【问题讨论】:

  • 我不确定我理解你到底想要做什么。您所说的“级别权限”指的是什么?是不是像 MLS 模型中那样的某种访问级别,其中每个主题都有一个(最大)访问级别(秘密、绝密......),每个资源都有一个(最小)访问级别好吗?
  • 你能用简单的古英语(或意大利语)表达你的最终目标吗?例如:具有角色==经理的用户想要对 X 类型的文档执行操作==查看,当且仅文档分类
  • 另外,这看起来像 XACML 1.1 或 XACML 2.0 策略。您使用什么来生成策略?你调查过 ALFA 吗?
  • ognisubjects e risorsa ha un livello di permesso, la policy mi deve dire se il subject può leggere la risorsa.
  • 每个主题和资源都有一个级别权限,政策目标是主题是否可以读取资源。

标签: authorization access-control xacml abac alfa


【解决方案1】:

你快到了。每当您需要将 2 个属性一起比较时,例如user-clearanceresource-classification,您需要使用 XACML Condition。您在示例中确实尝试过这样做,但您将该属性与静态值进行了比较。

这是 ALFA (Axiomatics Language for Authorization) 中的一个简单示例。

policy documentAccess{
    apply firstApplicable
    rule allowAccessIfClearanceSufficient{
        condition user.clearance>document.classification
        permit
    }
}

我定义我的属性如下:

    attribute classification{
        category = resourceCat
        id = "document.classification"
        type = integer
    }

    attribute clearance{
        category = subjectCat
        id = "user.clearance"
        type = integer
    }

请注意,我在这里使用整数而不是字符串。它更高效、更安全。

XACML 3.0 中的输出如下:

<?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:Policy xmlns:xacml3="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
    PolicyId="http://axiomatics.com/alfa/identifier/example.documentAccess"
    RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable"
    Version="1.0">
    <xacml3:Description />
    <xacml3:PolicyDefaults>
        <xacml3:XPathVersion>http://www.w3.org/TR/1999/REC-xpath-19991116</xacml3:XPathVersion>
    </xacml3:PolicyDefaults>
    <xacml3:Target />
    <xacml3:Rule 
            Effect="Permit"
            RuleId="http://axiomatics.com/alfa/identifier/example.documentAccess.allowAccessIfClearanceSufficient">
        <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-greater-than"/>
                <xacml3:AttributeDesignator 
                    AttributeId="user.clearance"
                    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="document.classification"
                    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:Policy>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-20
    • 2019-08-11
    • 1970-01-01
    • 2012-09-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多