首页 文章

授权模型:角色的语境?

提问于
浏览
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

这个解剖没有归因于蒂姆是朋友的一件事 of Mary

是否有一个组件可以添加到此模型中以捕获此上下文(“Mary”),还是有一种方法可以使用我之前存在的auth模型组件重新表示权限语句?什么是最佳做法?

1 回答

  • 2

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

    ABAC是一种授权模型:

    • 由美国国家标准与技术研究院NIST定义,该组织定义了RBAC(基于角色的访问控制)

    • 使用属性来定义访问控制逻辑 . 属性

    • 是键值对,例如角色==经理

    • 可以是多值的,例如公民身份=加拿大人,瑞典人

    • 可以描述任何事情,例如请求用户,目标对象,动作,关系,时间,位置......

    • 使用策略来定义访问控制逻辑 . 这些政策

    • 是用XACML编写的(xacml

    • 使用属性来定义访问控制范围

    • 启用外部授权:基本上您的授权逻辑与业务逻辑分离 . 这很棒,因为您可以独立于安全性开发应用程序 .

    我们举个例子:

    Tim可以看到Mary的 Profiles ,因为Tim是Mary的朋友 .

    因此授权要求是:

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

    在ABAC中,您必须识别您的属性 . 你可以在你的问题中做到这一点,虽然你的分析偏向于角色,但这很好 . 我们再来吧 . 我看到的属性是:

    • 动作ID(查看)

    • 资源类型(用户配置文件)

    • 朋友列表(蒂姆的好友列表)

    • Profiles 所有者(玛丽)

    有了这些属性,我可以用一种简单的方式重写你的需求:

    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>
    

相关问题