Skip to content

Instantly share code, notes, and snippets.

@francium-lupe
Last active August 29, 2023 13:57
Show Gist options
  • Save francium-lupe/cabe63384d0c552a00138208a53d494b to your computer and use it in GitHub Desktop.
Save francium-lupe/cabe63384d0c552a00138208a53d494b to your computer and use it in GitHub Desktop.
Polar 2
actor User {}
resource Vehicle {
permissions = ["security", "update", "updateAuthorizedUsers"];
roles = ["admin", "manager", "booked-user"];
"security" if "booked-user";
"update" if "manager";
"updateAuthorizedUsers" if "admin";
"manager" if "admin";
"booked-user" if "manager";
}
has_role(actor: User, "admin", _vehicle: Vehicle) if
role in actor.roles and
"admin" = role.name;
has_role(actor: User, role_name: String, vehicle: Vehicle) if
role in actor.roles and
role_name = role.name and
vehicle = role.resource;
allow(actor, action, resource) if
has_permission(actor, action, resource);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment