Polar Built-in Constants
Polar provides built-in "constants", which can be referenced in rules and then evaluated at runtime.
@current_unix_time
The @current_unix_time
keyword can be used to refer to the unix time
(the number of seconds that have elapsed since January 1, 1970 at midnight UTC)
at the time of a query.
@current_unix_time
returns an Integer
.
For example, if you have a fact expires_at(File:foo, 1670280790)
indicating
the time that the "foo" file expires, you could use this for time-based access:
has_permission(_: Actor, "read", file: File) if expires_at(file, time) and @current_unix_time < time;
Up next
- Rules + facts to understand how to write Polar rules using constants.
Talk to an Oso engineer
If you want to learn more about Polar, schedule a 1x1 with an Oso engineer. We're happy to help.