【问题标题】:XACML Rule for Time In Range as a Condition将时间范围内的时间作为条件的 XACML 规则
【发布时间】:2016-07-01 16:45:20
【问题描述】:

我想编写一个使用条件语句构建一个规则的规则 XACML 函数:“urn:oasis:names:tc:xacml:2.0:function:time-in-range”使用 ALFA 语言语法。出于易于处理义务的原因,我更愿意在条件函数中使用它,而不是在目标表达式中。
这可能吗?我在手册中没有找到任何参考。

@David Brossard。按照下面的方案,我使用以下 ALFA 代码测试了该策略:

namespace com.ibm.XACML {
import Attributes.*
import attributes.*
import com.ibm.XACML.Attributes.*
  attribute currentTime {
            id = "urn:oasis:names:tc:xacml:1.0:environment:current-time"
            type = time
            category = environmentCat
        }   

function timeInRange = "urn:oasis:names:tc:xacml:2.0:function:time-in-range" : time time time -> boolean                
// lowerBound = "09:00:00-03:00"
// upperBound = "18:00:00-03:00"    
// current-time = "02:00:00-03:00" decision permit 
// current-time = "10:00:00-03:00" decision permit  
// current-time = "22:00:00-03:00" decision permit      

policy checkTimeInRange{
    apply firstApplicable
    rule allowWithinRange{
        permit
        condition timeInRange(timeOneAndOnly(currentTime), timeOneAndOnly(timeBag("09:00:00-03:00":time)), timeOneAndOnly(timeBag("19:00:00-03:00":time)))
        }
    }
}

语法验证运行正常,但从 WSO2 PDP 代码返回的评估结果中有错误,为所有三个测试(02:00:00、10:00:00 和22:00:00。

我已经隔离了这个问题。 WSO2 Try-It 工具默认生成“字符串”,而 XACML 需要时间数据类型。要修复它,必须提出手动请求,并且 @David Brossard 显示的逻辑完美运行。这里是一个示例请求,生成一个“许可”。

<Request xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" CombinedDecision="false" ReturnPolicyIdList="false">
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:environment:current-time" IncludeInResult="false">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">11:00:00-03:00</AttributeValue>
</Attribute>
</Attributes>
</Request>  

结合条件语句的“TimeInRange”函数非常有用。

【问题讨论】:

  • 你指的是什么手册? WSO2 不支持 ALFA...
  • 亲爱的@David Brossard。参考 ALFA 语言的 .doc 规范“授权版本 1.0 的缩写语言”,工作草案 01。我正在 ALFA eclipse 代码编辑器下重写一些 XACML 策略。条件的构造很有用,它对程序员和代码更友好,因为它支持常见的算法,如布尔逻辑。范围内的时间函数会很有用。

标签: authorization access-control xacml abac alfa


【解决方案1】:

XACML standard我可以阅读

urn:oasis:names:tc:xacml:2.0:function:time-in-range

此函数应采用数据类型为time 的三个参数,并应返回boolean。如果第一个参数落在第二个和第三个参数定义的范围内,它应该返回 True。否则,它将返回“False”。

无论其值如何,第三个参数都应被解释为等于或晚于第二个参数的时间少于二十四小时。如果没有为第一个参数提供时区,它应该在上下文处理程序中使用默认时区。如果没有为第二个或第三个参数提供时区,则它们应使用第一个参数中的时区。

ALFA 也有这个功能。它被定义为

function timeInRange = "urn:oasis:names:tc:xacml:2.0:function:time-in-range" : time time time -> boolean

要使用它,只需这样做:

policy checkTimeInRange{
    apply firstApplicable
    rule allowWithinRange{
        permit
        condition timeInRange(timeOneAndOnly(currentTime), timeOneAndOnly(lowerBound), timeOneAndOnly(upperBound))
    }
}

请注意,如果您缺少任何这些值,PDP 将回复 Indeterminate

【讨论】:

  • 上面发布的 ALFA 代码被认为是有效的,但它的模拟没有返回 WSO2 PDP 下的预期结果。请参阅我在初始部分发布的测试代码。
  • 你遇到了什么错误?可能WSO2不支持时间
猜你喜欢
  • 2015-02-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-03
  • 1970-01-01
  • 2023-01-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多