ABAC 属性解析

ABAC Attributes Resolution

我们在 ABAC 中有一个主题、对象(资源)和操作(操作)。主体和客体具有将用于执行规则的属性。

  1. 我们可以有多个不同类型的主题,以及资源。某些属性与某些类型的资源相关,而某些属性在另一种资源的上下文中没有任何意义。在这种情况下,应该如何实施正确的属性模型?例如,我们有 A​​B 类型的资源。对于类型 A​​ 属性 isPublic 是相关的,而对于 B 则不是。如果 PIP 将收到为 B 获取 isPublic 属性的请求,它应该做什么? Return 没有什么会导致消极的规则解决?主题相同的问题。应该如何定义和解析正确的属性模型?

  2. PDP 的请求,我们是否应传递我们拥有的所有可能属性?据我了解,这将提高性能,因为它将允许按策略目标过滤掉很多策略。

关于您的第一个问题,发送规则决策不需要的附加属性不会影响决策。看一下 PDP 的 XACML 决策:

<EvaluationEvent xmlns="http://www.axiomatics.com/v1/EvaluationEvent" xmlns:xacml-ctx="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
    <GroupId>ddc4a53f-1c98-403c-81ce-938c97645d7d</GroupId>
    <GroupVersion>6</GroupVersion>
    <Timestamp>2018-07-24T02:39:21.907Z</Timestamp>
    <EvaluationTimeMillis>0</EvaluationTimeMillis>
    <ClientIdentity>User+username%3D%22pdp-user%22%2C+roles%3D%22pdp-user%22</ClientIdentity>
    <ClientSource>127.0.0.1:49502</ClientSource>
    <InterfaceType>SOAP</InterfaceType>
    <PdpIdentity>f6a721ba-058e-44df-9434-ec1505e99ddc</PdpIdentity>
    <xacml-ctx:Request ReturnPolicyIdList="false" CombinedDecision="false" xmlns:xacml- ctx="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
        <xacml-ctx:RequestDefaults>
            <xacml-ctx:XPathVersion>http://www.w3.org/TR/1999/REC-xpath-19991116</xacml- ctx:XPathVersion>
        </xacml-ctx:RequestDefaults>
        <xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:1.0:subject- category:access-subject" >
            <xacml-ctx:Attribute AttributeId="com.axiomatics.seniority" IncludeInResult="false">
                <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer">1</xacml- ctx:AttributeValue>
            </xacml-ctx:Attribute>
            <xacml-ctx:Attribute AttributeId="role" IncludeInResult="false">
                <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ADMIN</xacml- ctx:AttributeValue>
            </xacml-ctx:Attribute>
            <xacml-ctx:Attribute AttributeId="com.axiomatics.emailAddress" IncludeInResult="false">
                <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">userone@user.com</xacml- ctx:AttributeValue>
            </xacml-ctx:Attribute>
        </xacml-ctx:Attributes>
        <xacml-ctx:Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute- category:resource" >
            <xacml-ctx:Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" IncludeInResult="false">
                <xacml-ctx:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">secretmessage</xacml- ctx:AttributeValue>
            </xacml-ctx:Attribute>
        </xacml-ctx:Attributes>
    </xacml-ctx:Request>
    <ResultEntries>
        <ResultEntry>
            <xacml-ctx:Result>
                <xacml-ctx:Decision>Deny</xacml-ctx:Decision>
                <xacml-ctx:Status>
                    <xacml-ctx:StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/>
                </xacml-ctx:Status>
            </xacml-ctx:Result>
            <EvaluationComplexity>21</EvaluationComplexity>
        </ResultEntry>
    </ResultEntries>
</EvaluationEvent>

在我本地主机上的示例项目中,我在特定规则的主题中寻找的唯一属性是属性 com.axiomatics.seniority 是否等于 1 或 2。这意味着 ADMIN 是提供的额外属性。但是,这并不影响决策。

关于你的第二个问题,我不是完全理解,但我确实了解到你担心 PDP 的性能。一般而言,PDP 决策制定的性能(将 XACML 的内存和软件实现放在一边)基于您的策略。如果发生这种情况,您将希望尽快在您的政策中获得 "DENY"。

关于在 PEP 中设置属性,我发现使用基于将要发生的决策类型设置默认属性的函数很有帮助,如下所示:

@Override
public void uiDecisionSetDefaultAttributes() {
    Authentication auth = 
SecurityContextHolder.getContext().getAuthentication();
    attrCatAry.add("SUBJECT");
    attrTypeAry.add("INTEGER");
    attrIdAry.add("com.axiomatics.seniority");
    Integer userId = null;
    try {
        userId = userRepository.findByEmail(auth.getName()).getSeniority();
    } catch (Exception e) {
        log.info(e.toString());
    }
    attrValAry.add(userId);

}

完全公开 - 我在 Axiomatics 工作,我的答案基于完全符合 XACML 标准的软件,例如 Axiomatics 软件。

On request to PDP shall we pass all possible attributes that we are having? As far as I understood this will increase performance as it will allow to filter out by policy's target a lot of policies.

在 ABAC 中,您可以选择预先将所有属性从 PEP 传递到 PDP。例如你可以说:

  • 销售经理 Alice 可以批准销售草稿中的记录 #123 吗?

在上面的问题中,我们传入了Alice的角色和部门以及记录的状态和部门。我们假设这是做出决定所需的所有政策。这在 PEP(或应用程序)和 PDP 之间引入了紧密耦合,但它使 PDP 非常快,因为它不需要外出到外部源 (PIP)。

极端相反的是仅发送 "key" 属性,例如

  • Alice 可以批准记录 #123 吗?

在那种情况下,PDP 将需要为用户属性和资源属性调用 PIP,从而导致总共有 4 个可能的调用。你可能认为这听起来很糟糕。但事实并非如此。首先

  • 现在查询数据源效率很高
  • 您可以在 PDP 中缓存值,这样您就不必一直去获取 Alice 的角色
  • 只有在确实需要时才获取属性。例如,如果您确定 Alice 不是经理,我们甚至不会去获取她的部门或资源属性。

和 Mike 一样,我也在 Axiomatics 工作。我们已经采用算法来优化策略评估和属性检索。这使得我们的 PDP 非常快。