3 ms·
The permissions system I designed at work solves the search problem, although it is not as powerful as what's described in the article. We have three main conc
by Diggsey 5y ago
The permissions system I designed at work solves the search problem, although it is not as powerful as what's described in the article.
We have three main concepts in the sytem:
- Capabilities (eg. "read profile")
- Selectors (eg. "profiles belonging to customer X)
- Groups (eg. "profile")
All queries are of the form "Do I have capability X on resource Y" (where resource Y belongs to a particular group). A "permission set" is a mapping from a capability to a set of selectors.
Selectors can be composed (eg. you could OR two selectors together) but are predefined. Since they are predefined, our search implementation can understand a subset of the selectors, and translate them into an ElasticSearch-compatible query.
We then filter the results by evaluating the permissions normally: this catches any cases where there was no way to construct a query, or if the constructed query could not be completely precise. If this occurs, then we show a message on the page like "some profiles were hidden because you do not have permission to view them" and then we might show 19 profiles on a page instead of the full 20, so that our pagination can still work efficiently.