Skip to content

Commit

Permalink
add -collection- to keto namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mpwsh committed Jul 25, 2023
1 parent 7499a0e commit 9bfd735
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
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.1
version: 0.4.2

# 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
25 changes: 24 additions & 1 deletion charts/hub-permissions/policies/namespaces.keto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,29 @@ class Drop implements Namespace {
}
}

class Collection implements Namespace {
related: {
owners: User[]
editors: User[]
viewers: User[]
parents: Project[]
}

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 Project implements Namespace {
related: {
owners: User[]
Expand Down Expand Up @@ -175,4 +198,4 @@ class Organization implements Namespace {
this.related.owners.includes(ctx.subject) ||
this.related.parents.traverse((parent) => parent.permits.delete(ctx)),
}
}
}

0 comments on commit 9bfd735

Please sign in to comment.