policy.rego
Thu Oct 26 2023 13:22:51 GMT+0000 (Coordinated Universal Time)
Saved by
@kdelozier
package policy
default allow = false
user_shifts_api_endpoint = sprintf("http://user-shifts-api:8081/api/v1/userShifts/%v", [input.user.userId])
headers = {
"Content-Type": "application/json",
"Accept": "application/json"
}
available_shifts = http.send(
{
"method": "get",
"url": user_shifts_api_endpoint,
"headers": headers
}
)
response = available_shifts
allow {
some i
shiftStart = time.parse_rfc3339_ns(response[i].shiftStart)
shiftEnd = time.parse_rfc3339_ns(response[i].shiftEnd)
now = time.now_ns()
shiftStart <= now
now < shiftEnd
}
content_copyCOPY
Comments