top | item 46374566

(no title)

bencyoung | 2 months ago

If you're using Postgres then using the ltree module is great for permission systems. Available in RDS too

discuss

order

calderwoodra|2 months ago

Agreed, specifically for the file structure use-case, we were able to solve this with ltree.

amcvitty|2 months ago

About to embark on a similar project. Would love to hear any insights you can share!

casper14|2 months ago

Could you explain why this is great over alternatives?

nh2|2 months ago

Do you have an article about that?

bencyoung|1 month ago

Sorry for the delay! It's fairly simple. 1. You have a column on your objects you want secured as an LTREE[] 2. You add a GIST index on that column

The values should be the different hierarchy paths to access the object starting with a "type" e.g departments.root.deptA

When you run a query, depending on how you want to access you use a <@ query. E.g. I'm a user with root access to all depts "col <@ 'departments.root'::ltree" or I'm a user in dept A "col <@ 'departments.root.deptA'::ltree" etc