Skip to content

Commit

Permalink
Merge pull request #48 from holaplex/mpw/update-permissions-namespaces
Browse files Browse the repository at this point in the history
update namespaces, chart version
  • Loading branch information
mpwsh authored Mar 24, 2023
2 parents 3497446 + 83da6c6 commit 081b57d
Show file tree
Hide file tree
Showing 2 changed files with 47 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.0"
version: "0.1.1"

# 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
46 changes: 46 additions & 0 deletions charts/hub-permissions/policies/namespaces.keto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,52 @@
import { Namespace, Context } from "@ory/keto-namespace-types"
class User implements Namespace {}

class Webhook implements Namespace {
related: {
owners: User[]
editors: User[]
viewers: User[]
parents: Organization[]
}

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.edit(ctx)),
}
}

class Credential implements Namespace {
related: {
owners: User[]
editors: User[]
viewers: User[]
parents: Organization[]
}

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.edit(ctx)),
}
}

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

0 comments on commit 081b57d

Please sign in to comment.