ABAC return 序列化权限

ABAC return serialized permissions

我们如何使用 ABAC 获得可能的操作(权限)?我需要对前端说这个按钮应该被隐藏,因为这个动作在这个特殊情况下是受限制的,而在另一个情况下则没有。

目前只有混合 RBAC/ABAC 模型是我正在考虑的,但它仍然没有涵盖所有情况,因为我们可能有未经身份验证的访问权限,RBAC 不会涵盖这些权限,因此应该用 ABAC 涵盖。

问题是可以使用 ABAC 收集该用户对当前对象的所有允许操作吗?

是的,您可以根据用户的属性限制 UI 元素。并且如果用户的属性发生变化,比如用户被提升或被降级,那么一旦实现逻辑,前端将根据您的策略进行调整。

我在 Github 上有一个示例项目,它演示了使用 Java + Spring 安全性 https://github.com/michaelcgood/spring-security-ui-demo[=13 使用 ABAC 限制 UI 元素=]

正如我提到的,我在 Axiomatics 工作,这个项目被配置为与 pdp.properties 中的 Axiomatics 项目一起工作。但是,该项目可以与其他为 ABAC 实现 XACML 的软件一起使用,并具有适当的属性设置。

如果您不使用 Java,那么该项目将不会对您有用。但是,它确实证明了您的要求 - UI 元素可以受到限制。

使用的前端框架是 Thymeleaf,这是一个服务器端 Java 模板引擎,HTML 友好。

通过应用资源 ID 来限制 UI 元素的代码是这样的: <div class="jumbotron" style="background-color: green" sec:authorize="XACMLDecisionUI('secretmessage')"> <p style="color:white" align="center">Message only available to senior admins (seniority == 2).</p> </div>

如果您碰巧在使用 Axiomatics 软件,请在评论中告诉我,我可以为您提供进一步的指导。

谢谢, 迈克尔

ABAC is a broad concept that does not specify this kind of low-level behavior; and it is difficult to give a universal best practice for all ABAC frameworks, since there is a growing bunch of them possibly quite different: some of them are standard (eg. OASIS XACML, NIST NGAC), others non-standard yet generic (eg. OPA), others product-specific (eg. Kubernetes ABAC).

无论如何,在 XACML(最成熟的标准)中,您使用 Multiple Decision Profile(例如方案 3.3 重复属性类别),它允许在一个请求中请求多个授权决策单个 XACML 请求:

<Request xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" CombinedDecision="false" ReturnPolicyIdList="false">
   <Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
      <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" IncludeInResult="false">
         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">/objects/XXX</AttributeValue>
      </Attribute>
   </Attributes>
   <Attributes Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject">
      <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" IncludeInResult="false">
         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">bob</AttributeValue>
      </Attribute>
   </Attributes>
   <Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action">
      <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="true">
         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">create</AttributeValue>
      </Attribute>
   </Attributes>
   <Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action">
      <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="true">
         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue>
      </Attribute>
   </Attributes>
   <Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action">
      <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="true">
         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">update</AttributeValue>
      </Attribute>
   </Attributes>
   <Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action">
      <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="true">
         <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">delete</AttributeValue>
      </Attribute>
   </Attributes>
</Request>

在此示例中,我们请求给定用户 (bob) 和资源 (/objects/XXX) 的授权,但同时请求多个操作(创建、读取、更新、删除)。合规的 PDP returns 具有多个结果的单个 XACML 响应,每个单独的授权决策请求一个。 IncludeInResult 告诉响应中要包含哪些属性,以便 PEP 可以关联。

AuthzForce 和 AT&T XACML 等开源 XACML 实现支持此多重决策配置文件。