Skip to content

Commit

Permalink
Merge pull request #53 from holaplex/mpw/keto-namespaces-update
Browse files Browse the repository at this point in the history
add mint namespace
  • Loading branch information
mpwsh authored Apr 17, 2023
2 parents 25f2116 + e694605 commit 1c084d1
Show file tree
Hide file tree
Showing 2 changed files with 25 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 @@ -19,7 +19,7 @@ type: application
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)

version: "0.1.1"
version: "0.1.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
24 changes: 24 additions & 0 deletions charts/hub-permissions/policies/namespaces.keto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@ class Customer implements Namespace {
}
}

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

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

0 comments on commit 1c084d1

Please sign in to comment.