Skip to content

Commit

Permalink
feat(shop): add shop policies
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerald Baulig committed Jan 24, 2024
1 parent b749614 commit 0c1d044
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 3 deletions.
28 changes: 27 additions & 1 deletion datasets/system/data/seed-data/policies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@
- id: urn:oasis:names:tc:xacml:1.0:action:action-id
value: urn:restorecommerce:acs:names:action:execute
resources: [ ]
subjects: [ ]
combiningAlgorithm: urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides
meta:
modifiedBy: ""
Expand Down Expand Up @@ -462,7 +463,6 @@
- id: urn:restorecommerce:acs:names:ownerInstance
value: system
---
## Customers policy and 5 Products policy
id: customers_policy
name: Customers Policy
description: Allows normal users to read Customer resource
Expand All @@ -488,6 +488,32 @@
attributes:
- id: urn:restorecommerce:acs:names:ownerInstance
value: system
---
id: shops_policy
name: Shops Policy
description: Allows normal users to read Shop resource
evaluationCacheable: false
effect: PERMIT
target:
resources:
- id: urn:restorecommerce:acs:names:model:entity
value: urn:restorecommerce:acs:model:shop.Shop
subjects: [ ]
actions: [ ]
rules:
- org_scoped_shop_read_rule # Permit: normal user under an Org scope
- user_scoped_shop_read_rule # Permit: normal user who owns the resource and not bounded to any organization
- superadmin_rule # Permit: SuperAdmin
- fall_back_rule # Deny: All
combiningAlgorithm: urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides
meta:
modifiedBy: ""
owners:
- id: urn:restorecommerce:acs:names:ownerIndicatoryEntity
value: urn:restorecommerce:acs:model:organization.Organization
attributes:
- id: urn:restorecommerce:acs:names:ownerInstance
value: system
---
id: products_policy
name: Products policy
Expand Down
3 changes: 2 additions & 1 deletion datasets/system/data/seed-data/policy_sets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
subjects: [ ]
actions: [ ]
policies:
- execute_action_policy
- users_policy
- organizations_policy
- address_policy
Expand All @@ -18,7 +19,6 @@
- countries_policy
- roles_policy
- locales_policy
- execute_action_policy
- commands_policy
- jobs_policy
- policy_sets_policy
Expand All @@ -27,6 +27,7 @@
- timezones_policy
- orders_policy
- customers_policy
- shops_policy
- products_policy
- manufacturers_policy
- product_prototypes_policy
Expand Down
61 changes: 60 additions & 1 deletion datasets/system/data/seed-data/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,66 @@
attributes:
- id: urn:restorecommerce:acs:names:ownerInstance
value: system
## Product, Manufacturer, ProductPrototype, ProductCategory, PriceGroup - Master Data
---
id: org_scoped_shop_read_rule
name: Shop read rule for Organizational Scope
description: Permits any read if the resource is under an organizational hierarchical scope
target:
subjects:
- id: urn:restorecommerce:acs:names:role
value: user-r-id # NormalUser
- id: urn:restorecommerce:acs:names:roleScopingEntity
value: urn:restorecommerce:acs:model:organization.Organization
actions:
- id: urn:oasis:names:tc:xacml:1.0:action:action-id
value: urn:restorecommerce:acs:names:action:read
resources:
- id: urn:restorecommerce:acs:names:model:entity
value: urn:restorecommerce:acs:model:shop.Shop
effect: PERMIT
condition: ""
evaluationCacheable: false
contextQuery:
filters: [ ]
query: ""
meta:
modifiedBy: ""
owners:
- id: urn:restorecommerce:acs:names:ownerIndicatoryEntity
value: urn:restorecommerce:acs:model:organization.Organization
attributes:
- id: urn:restorecommerce:acs:names:ownerInstance
value: system
---
id: user_scoped_shop_read_rule
name: Shop read rule for Independent User Scope
description: Permits any read if the resource is under an user hierarchical scope
target:
subjects:
- id: urn:restorecommerce:acs:names:role
value: user-r-id # NormalUser
- id: urn:restorecommerce:acs:names:roleScopingEntity
value: urn:restorecommerce:acs:model:user.User
actions:
- id: urn:oasis:names:tc:xacml:1.0:action:action-id
value: urn:restorecommerce:acs:names:action:read
resources:
- id: urn:restorecommerce:acs:names:model:entity
value: urn:restorecommerce:acs:model:shop.Shop
effect: PERMIT
condition: ""
evaluationCacheable: false
contextQuery:
filters: [ ]
query: ""
meta:
modifiedBy: ""
owners:
- id: urn:restorecommerce:acs:names:ownerIndicatoryEntity
value: urn:restorecommerce:acs:model:organization.Organization
attributes:
- id: urn:restorecommerce:acs:names:ownerInstance
value: system
---
id: normal_user_product_read_rule
name: Product read rule
Expand Down

0 comments on commit 0c1d044

Please sign in to comment.