Team, We're working on a POC with Keto. In that t...
# talk-keto
c
Team, We're working on a POC with Keto. In that there is a definition of permission language that we came up with something like this,
Copy code
class StorageObject implements Namespace {
  related: {
    viewers: User[]
    editors: User[]
    owners: User[]
  }
  permits = {
    read: (ctx: Context): boolean =>
      this.related.viewers.includes(ctx.subject) ||
      this.related.editors.includes(ctx.subject) ||
      this.related.owners.includes(ctx.subject)
  }
}
Instead of mentioning
owner
,
editor
and
viewer
in all the applicable permission, Is there a way that I can say,
everything that the viewer has access, the owner has access too
?
s
you can use e.g. an
isMember
helper permission:
Copy code
class StorageObject implements Namespace {
  related: {
    viewers: User[]
    editors: User[]
    owners: User[]
  }
  permits = {
    isMember: (ctx: Context): boolean => 
      this.related.viewers.includes(ctx.subject) ||
      this.related.editors.includes(ctx.subject) ||
      this.related.owners.includes(ctx.subject),
    read: (ctx: Context): boolean =>
      this.permits.isMember(ctx)
  }
}
you should think in object-oriented terms here really, so not role or subject focused
c
Thanks a lot Patrick, that helps! Could you please elaborate what do you specifically mean by "think in object-oriented terms" in this context?
s
focus on the object, so "who can do what with this thing" instead of "what can this role do"
just as a way of thinking when working on the model