We are currently experimenting to see whether Keto...
# ory-network
m
We are currently experimenting to see whether Ketos could be a good fit for our permission system. However I’m stuck 😭: I have the following permission model:
Copy code
class Company implements Namespace {
  related: {
    admins: User[]
  }

  permits = {
    owner: (ctx: Context): boolean =>
      this.related.admins.includes(ctx.subject)
  }
}
class LearningPlan implements Namespace {
  related: {
    owners: User[]
    companies: Company[]
  }

  permits = {
    owner: (ctx: Context): boolean =>
      this.related.companies.traverse((parent) => parent.permits.owner(ctx)) ||
      this.related.owners.includes(ctx.subject)
  }
}
With these relations: • Subject
companies/simpleclub
is
companies
of Object
LearningPlan:learning_plans/xyz
• Subject
users/abc
is
admins
of Object
Company:companies/simpleclub
Why does this request
https://{project-slug}.<http://projects.oryapis.com/relation-tuples/checknamespace=LearningPlan&object=learning_plans/xyz&relation=owner&subject_id=users/abc&max-depth=20|projects.oryapis.com/relation-tuples/checknamespace=LearningPlan&object=learning_plans/xyz&relation=owner&subject_id=users/abc&max-depth=20>
return
{"allowed": false}
I thought be cause of the
.companies.traverse()
the user would also get permissions when they are an
admin
in the company?
Created a documentation bug as the example in the documentation doesn’t make it clear how the permission model should be used: https://github.com/ory/docs/issues/1744
🙏 1
1
@magnificent-energy-493 can you clarify and potentially update the documentation on how the permission model should be used? I don’t understand how traverse really works and haven’t found a good example of using it. The only 10 references of the function are on this page and they don’t mention how the relationships need to be setup for traverse to work.
m
Hello Dennis, thanks for the feedback. Will let the team know so we can clarify this.