【问题标题】:ABAC return serialized permissionsABAC 返回序列化权限
【发布时间】:2019-01-02 01:25:46
【问题描述】:

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

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

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

【问题讨论】:

  • 您好,您能澄清一下您的问题吗?您是否尝试根据属性限制 UI 元素?
  • @MichaelCGood,是的,我愿意。我更新了问题。
  • 我也遇到了这个问题,也使用 nodejs 作为后端语言。现在我的解决方案是只向前端发送当前用户的所有权限,让前端通过判断权限来进行条件渲染。我想知道你最后对这个问题做了什么,非常感谢。

标签: security permissions abac


【解决方案1】:

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

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

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

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

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

通过应用资源 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 软件,请在 cmets 中告诉我,我可以为您提供进一步的指导。

谢谢, 迈克尔

【讨论】:

  • 不幸的是,我使用的是 Node.js、TypeScript,没有什么能真正很好地解决 ABAC 任务。所以,我正在实施我的解决方案,我相信一段时间后它也会被重写以接受 XACML。
  • 您好,无论您使用 Node.js 还是其他一些技术,实际上只是传递属性并在 PEP 端执行它的问题。如果你愿意,你可以开始另一个问题并展示你是如何传递属性的,你可以 ping 我,我可以看看。一些 XACML 实现也支持 REST。如果我已经回答了您的问题,请随时接受我的回答:-)
  • 我们正在使用客户端渲染,并且不能对每个应该隐藏的 UI 元素执行额外的请求。我们有权限请求路由,该路由返回用户当前上下文的所有权限。所以现在,我看到我们只能模拟这个。
  • 我明白了。不需要对每个 UI 元素都有额外的请求。我认为在加载时您可以以 JSON 格式发送属性。
  • 只是最初的一个,但与本次讨论无关。与其说是实践,不如说是缺乏理论。谢谢你的回答。
【解决方案2】:

ABAC 是一个宽泛的概念,没有指定这种低级行为;并且很难为所有 ABAC 框架提供一个通用的最佳实践,因为它们中的许多可能完全不同:其中一些是标准的(例如OASIS XACMLNIST NGAC),另一些非标准但通用(例如OPA),其他产品特定的(例如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 返回一个带有多个结果的 XACML 响应,每个单独的授权决策请求一个。 IncludeInResult 告诉在响应中包含哪些属性,以便 PEP 可以关联。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-31
    • 1970-01-01
    • 2010-10-17
    • 2013-09-10
    • 2018-09-21
    • 2010-12-16
    • 1970-01-01
    相关资源
    最近更新 更多