0

我目前在尝试设计出具有以下组件的授权模型:授权模式:角色的上下文?

权限 - 既可以允许或拒绝用户/组

角色的行为 - 特权的集合;到安全性被施加

对象所有者的实体 - - 角色可以与用户或组

安全对象关联的安全对象的所有者

以下状态 - 表示的状态的属性安全对象

用户 - 服务的标准消费者;可以被拒绝或被授予访问权限

组 - 用户共享一个共同事物的集合;角色可以分配给组;权限可以分配给组

我的问题如下:有没有一种方法来正确地模拟角色的上下文与我上面提出的当前组件?

举例来说,假设我有当前的授权声明:

Tim can see Mary's profile information because Tim is Mary's friend. 

我可以解剖这个语句转换成模型组件:

User: Tim 
Security Object: profile information 
Object Owner: Mary 
Privilege: view 
Role: friend 
Group: N/A? 
Status: N/A 

一件事,这个夹层不属性是Tim是一个朋友玛丽

是否有一个组件,我可以添加到这个模型wi我会捕获这个上下文(“Mary的”),还是有一种方法可以使用我的预先存在的auth模型组件重新表示特权声明?最佳做法是什么?

回答

2

实际上,您不应尝试实施新的授权模式。已经有一个很好的模型称为基于属性的访问控制(或ABAC - 见SO标签)。

ABAC是授权模式:

  • 由NIST定义,美国国家标准与技术研究所,定义RBAC(基于角色的访问控制)
  • 使用属性来非常相同的组织定义访问控制逻辑。属性
    • 是一个键值对,例如角色==管理器
    • 可以是多值的,例如,国籍=加拿大人,瑞典语
    • 可以描述任何内容,例如请求用户,目标对象,动作,关系,时间,位置...
  • 使用策略来定义访问控制逻辑。这些政策
    • 都写在XACML(
    • 使用属性来定义访问控制范围
  • 使外部化授权:基本上你的授权逻辑从业务逻辑分离。这非常棒,因为您可以独立于安全性开发应用程序。

让我们把你的例子:

蒂姆可以看到玛丽的个人信息,因为蒂姆是玛丽的朋友。因此

授权要求是:

A user can view another user's profile if both users are friends. 

在ABAC,你必须确定你的属性。你在你的问题中这样做很好,尽管你的分析是有偏见的。让我们再来看看。我看到的属性有:

  • 动作ID(视图)
  • 资源类型(用户配置文件)
  • 好友列表(Tim的好友列表)
  • 配置文件所有者(玛丽)

有了这些属性,我可以在一个破旧的方式重写你的要求:

A user can do the action actionId==view on a resource of type==user profile if profile.owner is in the user's friend list. 

然后,您可以使用ALFA()实施ALFA中的策略,然后使用XACML。

namespace com.axiomatics{ 
    /** 
    * A user can view another user's profile... 
    */ 
    policy viewProfile{ 
     target clause actionId=="view" and resourceType=="user profile" 
     apply firstApplicable 
     /** 
     * Allow if both users are friends. 
     */ 
     rule allowIfFriends{ 
      condition stringIsIn(stringOneAndOnly(subjectId), friendList) 
      permit 
     } 
    } 
} 

的XACML结果(以XML)是:

<?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/com.axiomatics.viewProfile" 
    RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable" 
    Version="1.0"> 
    <xacml3:Description>A user can view another user's profile...</xacml3:Description> 
    <xacml3:PolicyDefaults> 
     <xacml3:XPathVersion>http://www.w3.org/TR/1999/REC-xpath-19991116</xacml3:XPathVersion> 
    </xacml3:PolicyDefaults> 
    <xacml3:Target> 
     <xacml3:AnyOf> 
      <xacml3:AllOf> 
       <xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal"> 
        <xacml3:AttributeValue 
         DataType="http://www.w3.org/2001/XMLSchema#string">view</xacml3:AttributeValue> 
        <xacml3:AttributeDesignator 
         AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" 
         DataType="http://www.w3.org/2001/XMLSchema#string" 
         Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" 
         MustBePresent="false" 
        /> 
       </xacml3:Match> 
       <xacml3:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal"> 
        <xacml3:AttributeValue 
         DataType="http://www.w3.org/2001/XMLSchema#string">user profile</xacml3:AttributeValue> 
        <xacml3:AttributeDesignator 
         AttributeId="resourceType" 
         DataType="http://www.w3.org/2001/XMLSchema#string" 
         Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" 
         MustBePresent="false" 
        /> 
       </xacml3:Match> 
      </xacml3:AllOf> 
     </xacml3:AnyOf> 
    </xacml3:Target> 
    <xacml3:Rule 
      Effect="Permit" 
      RuleId="http://axiomatics.com/alfa/identifier/com.axiomatics.viewProfile.allowIfFriends"> 
     <xacml3:Description>Allow if both users are friends.</xacml3:Description> 
     <xacml3:Target /> 
     <xacml3:Condition> 
      <xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-is-in" > 
       <xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only" > 
        <xacml3:AttributeDesignator 
         AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" 
         DataType="http://www.w3.org/2001/XMLSchema#string" 
         Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" 
         MustBePresent="false" 
        /> 
       </xacml3:Apply> 
       <xacml3:AttributeDesignator 
        AttributeId="friendList" 
        DataType="http://www.w3.org/2001/XMLSchema#string" 
        Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" 
        MustBePresent="false" 
       /> 
      </xacml3:Apply> 
     </xacml3:Condition> 
    </xacml3:Rule> 
</xacml3:Policy> 
+1

这是我还没有考虑过一个有趣的方法。感谢你与我分享这个。 结合这个模型,我发现了一篇关于不同模型的文章,它也可以满足我的要求。这就是所谓的ReBAC(基于关系的访问控制) http://pages.cpsc.ucalgary.ca/~pwlfong/Pub/codaspy2011.pdf 现在,只是看看我的目的,如果ABAC或ReBAC会更好地工作为我的应用程序。 再次感谢。 – Mackers