我试图将我们的数据库模型输入到ALFA中,以检查ALFA和XACML的功能。
类似于以下的属性可能吗?那么规则会怎样呢?
1:n按字符串列表
namespace com.mycompany {
namespace resources {
namespace patient {
attribute trustedDoctorIds{
category = resourceCat
id = "trustedDoctorIds"
type = list<string> //maybe it should be bag[string]
}
}
}
}1:n按复杂类型列表排列
namespace com.mycompany {
namespace resources {
namespace patient {
attribute trustedDoctors{
category = resourceCat
id = "trustedDoctors"
type = list<doctor> //maybe it should be bag[doctor]
}
}
}
namespace subjects {
namespace doctor {
attribute id {
category = subjectCat
id = "id"
type = string
}
attribute lastname {
category = subjectCat
id = "lastname"
type = string
}
}
}
}发布于 2018-05-23 18:27:50
你有个很好的问题。
默认情况下,ALFA和XACML中的所有属性都是多值的。属性是值的袋子,而不是单个值。这意味着当您定义以下内容时,
attribute trustedDoctorIds{
category = resourceCat
id = "trustedDoctorIds"
type = string
} 这意味着该属性具有字符串的类型,并且可以是多值的。您可以选择在上面的属性定义注释中表示基数信息。
/**
* This attribute, trustedDoctorIds, contains the list of doctors a patient
*trusts. The list can have 0 or more values.
*/该策略将根据所使用的函数来传达有多少值。
例如,您可以编写一个条件来声明
stringOneAndOnly(trustedDoctorIds)==stringOneAndOnly(userId)在这种情况下,您将强制每个属性只有一个值和一个值。如果有0或1以上的值,那么XACML策略的评估将产生Indeterminate。
在XACML (或ALFA)目标中,当您编写:
trustedDoctorIds == "Joe"你的意思是:如果trustedDoctorIds中至少有一个值等于‘Joe’.
在阿尔法条件下,当你写
trustedDoctorIds==userId您是说:*如果trustedDoctorIds中至少有一个值等于userId中的至少一个值
注意:如果可以的话,我总是用单数名称来表示我的属性。这是一个惯例,不是一个严格的限制。记住属性的基数将在稍后的策略测试中有所帮助。
对评论的答复
按照你的惯例,你会尽量避免什么名字呢?
嗯,在我看来,托管人--*,除非您知道属性总是多值的,否则我将使用trustedDoctorId。
因此,这应该是可能的:在我的请求中,我提供了resource.patient.trustedDoctorIds=="2,13,67“和subject.doctor.id=="6”。那么,阿尔法的规则会是什么样子呢?斯莫斯。像"resource.patient.trustedDoctorIds.contains(subject.doctor.id)许可证一样“
该规则如下所示:
stringIsIn(stringOneAndOnly(subject.doctor.id),resource.patient.trustedDoctorIds)请确保在请求中提供多个值,而不是一个包含逗号分隔值的值。输入1,2,3,而不是"1,2,3“。
进一步编辑
因此,到了2,13,67,结果就像"2,13, 67“和doctorId==6一样被拒绝,不允许。
不要混淆stringIsIn()和stringContains()。
stringIsIn(a, b)接受两个参数a和b,其中a是原子值,b是一个值袋。如果a的值在b的值袋中,则stringIsIn(a, b)返回true。stringContains(a, b)接受两个参数a和b,它们都是string类型的原子值。如果在b中找到字符串值a,则返回true。示例:
stringIsIn(stringOneAndOnly(userCitizenship), stringBag("Swedish", "German"))返回true。stringContains("a", "alfa")返回true。所以在这个例子中它返回true。https://stackoverflow.com/questions/50485038
复制相似问题