News for hackers. Stuff that matters.
Re:Distributed Authorization by wkirby on Tuesday April 16, 2024 @12:34PM (#40054080)
Same conclusion we came to, and the basis of our in-house permission gem for RoR. The most efficient declaration of permissions is to express them as a WHERE statement, and then the implementation of can_whatever() is just inclusion in the collection returned by the WHERE.

Permissions have three moving parts, who wants to do it, what do they want to do, and on what object. Any good permission system has to be able to efficiently answer any permutation of those variables. Given this person and this object, what can they do? Given this object and this action, who can do it? Given this person and this action, which objects can they act upon?

We’ve found most permissioning systems end up with a pick-2 approach, and the most common one to be abused is given a person and an action, give me the collection. This leads to implementing permissions twice, once in code, and once as a query.

Re:Distributed Authorization by simonw on Tuesday April 16, 2024 @03:50PM (#40056391)
Love how you explained that. Quoted it on my blog here: https://simonwillison.net/2024/Apr/16/wkirby-on-hacker-news/
Re:Distributed Authorization by wkirby on Tuesday April 16, 2024 @09:43PM (#40059515)
Hey cool, I appreciate it!
Re:Distributed Authorization by gsarjeant on Tuesday April 16, 2024 @02:01PM (#40055176)
Hi, wkirby! I'm the post author, I do DevRel at Oso.

> Permissions have three moving parts, who wants to do it, what do they want to do, and on what object. Any good permission system has to be able to efficiently answer any permutation of those variables. Given this person and this object, what can they do? Given this object and this action, who can do it? Given this person and this action, which objects can they act upon?

> We’ve found most permissioning systems end up with a pick-2 approach, and the most common one to be abused is given a person and an action, give me the collection. This leads to implementing permissions twice, once in code, and once as a query.

I love the way you put this! I'm always looking for good ways to talk about authorization without falling back on jargon and I've never come up with a way to talk about the difference between authorizing an action on a single resource and returning a list of authorized resources that I've been happy with. Would you mind if I adapted this in future writing?

Re:Distributed Authorization by wkirby on Tuesday April 16, 2024 @09:42PM (#40059505)
By all means! I enjoyed your article here, and I will keep an eye on Oso on the future. Authorization has become a hobby horse of mine, and I always appreciate people who are thinking about the complexity required to meet real-world needs.
Re:Distributed Authorization by damethos on Friday April 19, 2024 @01:55AM (#40083822)
You might enjoy this one as well then: https://news.ycombinator.com/item?id=30878926
Re:Distributed Authorization by bullfightonmars on Tuesday April 16, 2024 @03:04PM (#40055939)
Yes! My team came to the same conclusion and are in the process of building just such a library for our platform.

- Actor - who is performing an action

- Policy - what types of possible actions are permitted on a resource for a type of actor

- Permission - actions an actor has been granted to perform.

With the intersection of these three objects you can determine if an action can be performed and actors can be granted granular access.