Skip to content

Commit 5a9db79

Browse files
authored
Merge pull request #127 from holaplex/mpw/permissions-chart-update
add -collection- to keto namespace
2 parents 7499a0e + 9bfd735 commit 5a9db79

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

charts/hub-permissions/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type: application
1818
# This is the chart version. This version number should be incremented each time you make changes
1919
# to the chart and its templates, including the app version.
2020
# Versions are expected to follow Semantic Versioning (https://semver.org/)
21-
version: 0.4.1
21+
version: 0.4.2
2222

2323
# This is the version number of the application being deployed. This version number should be
2424
# incremented each time you make changes to the application. Versions are not expected to

charts/hub-permissions/policies/namespaces.keto.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,29 @@ class Drop implements Namespace {
131131
}
132132
}
133133

134+
class Collection implements Namespace {
135+
related: {
136+
owners: User[]
137+
editors: User[]
138+
viewers: User[]
139+
parents: Project[]
140+
}
141+
142+
permits = {
143+
view: (ctx: Context): boolean =>
144+
this.related.viewers.includes(ctx.subject) ||
145+
this.related.parents.traverse((parent) => parent.permits.view(ctx)) ||
146+
this.permits.edit(ctx),
147+
edit: (ctx: Context): boolean =>
148+
this.related.editors.includes(ctx.subject) ||
149+
this.related.parents.traverse((parent) => parent.permits.edit(ctx)) ||
150+
this.permits.delete(ctx),
151+
delete: (ctx: Context): boolean =>
152+
this.related.owners.includes(ctx.subject) ||
153+
this.related.parents.traverse((parent) => parent.permits.delete(ctx)),
154+
}
155+
}
156+
134157
class Project implements Namespace {
135158
related: {
136159
owners: User[]
@@ -175,4 +198,4 @@ class Organization implements Namespace {
175198
this.related.owners.includes(ctx.subject) ||
176199
this.related.parents.traverse((parent) => parent.permits.delete(ctx)),
177200
}
178-
}
201+
}

0 commit comments

Comments
 (0)