2017-06-15 55 views
1

我将使用OAuth2和XACML(使用AuthZForce)来保护我的Spring Cloud应用程序。从自定义ABAC切换到XACML

我已经实现了一个简单的ABAC解决方案,它可以处理下面的用例,但我想切换到XACML。可能吗?

旧域

我有(数据库):

  • 政策(例如subject.id == resource.ownerId),即由enfocement点检查,以决定
  • 权限(例如DELETE_USER),有一些明确的政策
  • 的角色(如员工),持有一些权限
  • 壮举(例如PREMIUM),持有一些默认值,由公司使用的角色和权限
  • 公司,有一些功能
  • 用户,分配给公司

用例

现在来自公司的用户可以创建新角色ROLE_X。他可以为这个角色分配一些权限。

UPDATE

因为这个问题原本包含两个不同的问题,我决定外包的第二个问题(AuthZForce for Spring Cloud

回答

1

你在哪里存储的政策基本上是无能为力的。这取决于您使用的引擎,例如AuthZForce(我已经把作者钉住了,所以他可以插入),SunXACML,WSO2或Axiomatics。

声明:我为Axiomatics工作。我们确实使用数据库来存储XACML策略,但不会更改授权要求或建模。

我对你原来的帖子有一些评论。

  • subject.id==resource.ownerId是我们通常称为XACML中的一个条件。您将两个属性进行比较以实现关系。
  • 您提到了权限,例如DELETE_USER。在XACML中,你通常将它们分成原子属性,例如一方面是动作,另一方面是对象或资源(USER)。虽然RBAC是基于角色和许可的,但ABAC是基于属性的。理想的情况是这些属性表示一个方面(作为一个用户,试图删除 ...)
  • ROLE仍然存在ABAC。这将是您的政策的基础。
  • 功能和公司是您使用的属性。

考虑到这一点,你可以写的政策,如以下(使用ALFA符号):

namespace axiomatics{ 

    namespace user{ 
     attribute role{ 
      category = subjectCat 
      id = "axiomatics.user.role" 
      type = string 
     } 
     attribute company{ 
      category = subjectCat 
      id = "axiomatics.user.company" 
      type = string 
     } 
     attribute userId{ 
      category = subjectCat 
      id = "axiomatics.user.userId" 
      type = string 
     } 
    } 

    namespace action{ 
     attribute actionId{ 
      category = actionCat 
      id = "axiomatics.action.actionId" 
      type = string 
     }   
    } 

    namespace resource{ 
     attribute company{ 
      category = resourceCat 
      id = "axiomatics.resource.company" 
      type = string 
     } 
     attribute owner{ 
      category = resourceCat 
      id = "axiomatics.resource.owner" 
      type = string 
     } 
    } 

    policyset springapp{ 
     apply firstApplicable 
     policy employees{ 
      target clause user.role == "employee" 
      apply firstApplicable 
      /** 
      * Employees can create roles in their own company 
      */ 
      rule createRole{ 
       target clause action.actionId=="create" 
       condition user.company==resource.company 
       permit 
      } 
      /** 
       * Employees can delete roles they own 
       */ 
      rule allowDelete{ 
       target clause action.actionId == "delete" 
       condition user.userId == resource.owner 
       permit 
      } 
     } 
    } 
} 
+0

谢谢你的详细解答。我看到我自己的解决方案与XACML类似,这是完美的,因为迁移不会那么困难。但对我来说,将策略存储在数据库中(以便在运行时更改它们)非常重要。你知道哪些免费或开源解决方案支持这个吗? – benkuly

+0

我会假设所有的开源引擎都可以从数据库中读取XACML策略。试试AT&T的XACML,WSO2或AuthZForce,你提到的那个。它是OSS社区中最新和最完整的之一 –

+0

您是否知道我应该如何或应该开始一个新问题。问题是,他们都没有或稀疏的文件,所以我不知道哪一个是最适合数据库策略。 – benkuly