Skip to content

Commit

Permalink
add updatehistory namespace to keto
Browse files Browse the repository at this point in the history
  • Loading branch information
mpwsh committed Aug 10, 2023
1 parent 8ce11a9 commit 6ef72f2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/hub-permissions/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.4.3
version: 0.4.4

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
23 changes: 23 additions & 0 deletions charts/hub-permissions/policies/namespaces.keto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,29 @@ class Customer implements Namespace {
}
}

class UpdateHistory implements Namespace {
related: {
owners: User[]
editors: User[]
viewers: User[]
parents: Mint[]
}

permits = {
view: (ctx: Context): boolean =>
this.related.viewers.includes(ctx.subject) ||
this.related.parents.traverse((parent) => parent.permits.view(ctx)) ||
this.permits.edit(ctx),
edit: (ctx: Context): boolean =>
this.related.editors.includes(ctx.subject) ||
this.related.parents.traverse((parent) => parent.permits.edit(ctx)) ||
this.permits.delete(ctx),
delete: (ctx: Context): boolean =>
this.related.owners.includes(ctx.subject) ||
this.related.parents.traverse((parent) => parent.permits.delete(ctx)),
}
}

class Mint implements Namespace {
related: {
owners: User[]
Expand Down

0 comments on commit 6ef72f2

Please sign in to comment.