-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into khieta/oopsla-upgrade
- Loading branch information
Showing
11 changed files
with
239 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,4 +115,4 @@ when | |
principal != resource.owner && | ||
resource has isPrivate && | ||
resource.isPrivate | ||
}; | ||
}; |
130 changes: 74 additions & 56 deletions
130
cedar-example-use-cases/hotel_chains/static/policies.cedar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,99 @@ | ||
// ========================================== | ||
// Policies for particular property resource types | ||
permit( | ||
principal, | ||
permit ( | ||
principal, | ||
action in [Action::"viewReservation"], | ||
resource) | ||
when { | ||
resource in principal.viewPermissions.hotelReservations || | ||
resource in principal.viewPermissions.propertyReservations | ||
resource | ||
) | ||
when | ||
{ | ||
resource in principal.viewPermissions.hotelReservations || | ||
resource in principal.viewPermissions.propertyReservations | ||
}; | ||
// ... three similar policies but for Inventory, PaymentDetails, Rates | ||
|
||
permit( | ||
principal, | ||
action in [Action::"viewReservation", | ||
Action::"updateReservation", | ||
Action::"createReservation"], | ||
resource) | ||
when { | ||
// ... three similar policies but for Inventory, PaymentDetails, Rates | ||
permit ( | ||
principal, | ||
action in | ||
[Action::"viewReservation", | ||
Action::"updateReservation", | ||
Action::"createReservation"], | ||
resource | ||
) | ||
when | ||
{ | ||
resource in principal.memberPermissions.hotelReservations || | ||
resource in principal.memberPermissions.propertyReservations | ||
}; | ||
// ... three similar policies but for Inventory, PaymentDetails, Rates | ||
|
||
permit( | ||
principal, | ||
action in [Action::"viewReservation", | ||
Action::"updateReservation", | ||
Action::"createReservation", | ||
Action::"grantAccessReservation" | ||
// ... other actions for all resource types | ||
], | ||
resource) | ||
when { | ||
// ... three similar policies but for Inventory, PaymentDetails, Rates | ||
permit ( | ||
principal, | ||
action in | ||
[Action::"viewReservation", | ||
Action::"updateReservation", | ||
Action::"createReservation", | ||
Action::"grantAccessReservation" | ||
// ... other actions for all resource types | ||
], | ||
resource | ||
) | ||
when | ||
{ | ||
resource in principal.hotelAdminPermissions || | ||
resource in principal.propertyAdminPermissions | ||
}; | ||
|
||
// ========================================== | ||
// Policies for properties and hotels | ||
permit( | ||
principal, | ||
action in [Action::"viewProperty", | ||
Action::"viewHotel"], | ||
resource) | ||
when { | ||
permit ( | ||
principal, | ||
action in [Action::"viewProperty", Action::"viewHotel"], | ||
resource | ||
) | ||
when | ||
{ | ||
resource in principal.viewPermissions.hotelReservations || | ||
resource is Property && resource in principal.viewPermissions.propertyReservations | ||
resource is Property && | ||
resource in principal.viewPermissions.propertyReservations | ||
// || resource in principal.viewPermissions.inventory ... for other resource types | ||
}; | ||
|
||
permit( | ||
principal, | ||
action in [Action::"viewProperty", | ||
Action::"updateProperty", | ||
Action::"createProperty", | ||
Action::"viewHotel", | ||
Action::"updateHotel", | ||
Action::"createHotel"], | ||
resource) | ||
when { | ||
permit ( | ||
principal, | ||
action in | ||
[Action::"viewProperty", | ||
Action::"updateProperty", | ||
Action::"createProperty", | ||
Action::"viewHotel", | ||
Action::"updateHotel", | ||
Action::"createHotel"], | ||
resource | ||
) | ||
when | ||
{ | ||
resource in principal.memberPermissions.hotelReservations || | ||
resource is Property && resource in principal.memberPermissions.propertyReservations | ||
resource is Property && | ||
resource in principal.memberPermissions.propertyReservations | ||
// || resource in principal.memberPermissions.inventory ... for other resource types | ||
}; | ||
|
||
permit( | ||
permit ( | ||
principal, | ||
action in [Action::"viewProperty", | ||
Action::"updateProperty", | ||
Action::"createProperty", | ||
Action::"grantAccessProperty", | ||
Action::"viewHotel", | ||
Action::"updateHotel", | ||
Action::"createHotel", | ||
Action::"grantAccessHotel"], | ||
resource) | ||
when { | ||
action in | ||
[Action::"viewProperty", | ||
Action::"updateProperty", | ||
Action::"createProperty", | ||
Action::"grantAccessProperty", | ||
Action::"viewHotel", | ||
Action::"updateHotel", | ||
Action::"createHotel", | ||
Action::"grantAccessHotel"], | ||
resource | ||
) | ||
when | ||
{ | ||
resource in principal.hotelAdminPermissions || | ||
resource is Property && resource in principal.propertyAdminPermissions | ||
}; | ||
resource is Property && | ||
resource in principal.propertyAdminPermissions | ||
}; |
87 changes: 48 additions & 39 deletions
87
cedar-example-use-cases/hotel_chains/templated/policies.cedar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,62 @@ | ||
@id("ViewReservation") | ||
permit( | ||
permit ( | ||
principal == ?principal, | ||
action in [Action::"viewReservation"], | ||
resource in ?resource); | ||
|
||
resource in ?resource | ||
); | ||
|
||
@id("MemberReservation") | ||
permit( | ||
principal == ?principal, | ||
action in [Action::"viewReservation", | ||
Action::"updateReservation", | ||
Action::"createReservation"], | ||
resource in ?resource); | ||
permit ( | ||
principal == ?principal, | ||
action in | ||
[Action::"viewReservation", | ||
Action::"updateReservation", | ||
Action::"createReservation"], | ||
resource in ?resource | ||
); | ||
|
||
@id("AdminReservation") | ||
permit( | ||
permit ( | ||
principal == ?principal, | ||
action in [Action::"viewReservation", | ||
Action::"updateReservation", | ||
Action::"createReservation", | ||
Action::"grantAccessReservation"], | ||
resource in ?resource); | ||
action in | ||
[Action::"viewReservation", | ||
Action::"updateReservation", | ||
Action::"createReservation", | ||
Action::"grantAccessReservation"], | ||
resource in ?resource | ||
); | ||
|
||
@id("ViewPropertyOrHotel") | ||
permit( | ||
permit ( | ||
principal == ?principal, | ||
action in [Action::"viewHotel", | ||
Action::"viewProperty"], | ||
resource in ?resource); | ||
action in [Action::"viewHotel", Action::"viewProperty"], | ||
resource in ?resource | ||
); | ||
|
||
@id("MemberPropertyOrHotel") | ||
permit( | ||
principal == ?principal, | ||
action in [Action::"viewHotel", | ||
Action::"updateHotel", | ||
Action::"createHotel", | ||
Action::"viewProperty", | ||
Action::"updateProperty", | ||
Action::"createProperty"], | ||
resource in ?resource); | ||
permit ( | ||
principal == ?principal, | ||
action in | ||
[Action::"viewHotel", | ||
Action::"updateHotel", | ||
Action::"createHotel", | ||
Action::"viewProperty", | ||
Action::"updateProperty", | ||
Action::"createProperty"], | ||
resource in ?resource | ||
); | ||
|
||
@id("AdminPropertyOrHotel") | ||
permit( | ||
permit ( | ||
principal == ?principal, | ||
action in [Action::"viewHotel", | ||
Action::"updateHotel", | ||
Action::"createHotel", | ||
Action::"grantAccessHotel", | ||
Action::"viewProperty", | ||
Action::"updateProperty", | ||
Action::"createProperty", | ||
Action::"grantAccessProperty"], | ||
resource in ?resource); | ||
action in | ||
[Action::"viewHotel", | ||
Action::"updateHotel", | ||
Action::"createHotel", | ||
Action::"grantAccessHotel", | ||
Action::"viewProperty", | ||
Action::"updateProperty", | ||
Action::"createProperty", | ||
Action::"grantAccessProperty"], | ||
resource in ?resource | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.