Hello, I have a convention/best
# spicedb
s
Hello, I have a convention/best practices question. We currently have a
definition user {}
to represent the subjects of our authz checks. We recently started discussing a use case for checking if users have permission to look at each other's details. My intuition was to just add relations and permissions directly to that
user
definition, but someone suggested adding a second user definition to act as the "resource" to differentiate between the user treated as a subject and the user treated as a resource. I can kind of see the merits of doing that, but I also worry that it's overcomplicating it. Just looking for some input from the experts
y
ime it's exchanging one kind of complexity for another. a nice thing about treating all users as a single resource type and then writing the appropriate relations is that it matches the domain - a user can view another user if there's a path from the resource user to the subject user. the place where it can get hairy is if you end up with cyclical/recursive relations as a result - if there are paths between the resource user and the subject user but also vice versa, you'll hit a max recursion depth error. having separate definitions for user details and users can be a good way to avoid that categorically. you can also treat them as two different domain objects -
user
vs
user_profile
or something.
s
Gotcha, that makes sense. I'm trying to imagine a situation where I would have a cyclical relation but I can't quite picture it... but in any case, modeling it as accessing a piece of the user instead of the entire user makes sense to me. thanks for the input!
y
sure thing!
7 Views