授权模型:角色的上下文



我目前正在尝试设计一个具有以下组件的授权模型:

Privileges—可以授予或拒绝用户/组的操作

Roles—权限的集合;角色可以与用户或组关联

Security Objects—应用安全的实体

Object Owners—安全对象的所有者

状态——表示安全对象状态的属性

Users—服务的标准消费者;可以拒绝或授予访问权限

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

我的问题如下:是否有一种方法可以用我上面展示的当前组件正确地建模角色的上下文?

例如,假设我有当前授权语句:
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

这个解剖没有说明的一点是蒂姆是玛丽的朋友

是否有一个组件可以添加到这个模型中来捕获这个上下文("of Mary"),或者是否有一种方法可以使用我已经存在的身份验证模型组件重新表示特权语句?什么是最佳实践?

实际上,您不应该尝试实现新的授权模型。已经有一个很好的模型叫做基于属性的访问控制(或ABAC -参见SO标签ABAC和xacml)。

ABAC是一个授权模型:

  • 是由NIST(美国国家标准与技术研究所)定义的,该组织也定义了RBAC(基于角色的访问控制)
  • 使用属性来定义访问控制逻辑。属性
    • 是一个键值对,例如role == manager
    • 可以是多值的,例如国籍=加拿大,瑞典
    • 可以描述任何东西,例如请求用户、目标对象、动作、关系、时间、位置……
  • 使用策略定义访问控制逻辑。这些政策
    • 是用XACML (XACML)编写的
    • 使用属性定义访问控制范围
  • 支持外部化授权:从本质上讲,您的授权逻辑与业务逻辑解耦。这很好,因为你可以独立于安全开发应用程序。
  • 让我们以你为例:

    Tim可以看到Mary的个人资料信息,因为Tim是Mary的朋友。

    因此,授权要求将是:
    A user can view another user's profile if both users are friends.
    

    在ABAC中,您必须标识您的属性。你在你的问题中这样做很好,尽管你的分析是有角色偏见的。我们再来一次。我看到的属性是:

    • action id (view)
    • 资源类型(用户配置文件)
    • 好友列表(Tim的好友列表)
    • 配置文件所有者(Mary)

    有了这些属性,我可以用分解的方式重写您的需求:

    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)在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>
    

    最新更新