I have an application where document creators determine what access permission (s) to give. The permissions are of the form:
- EVERYONE => 1
- MY_FRIENDS => 2
- ME_ONLY => 3
Example:
- User 1 creates doc1 and sets permission to EVERYONE
- User 2 created doc2 and sets permission to ME_ONLY
- User 3 creates doc3 and sets permissions to MY_FRIENDS
In the index we have creator_ids representing the list of users who created the document. e.g. for doc1: creator_ids=[1]
The list of MY_FRIENDS (for each document creator) is determined by different module, accessible at runtime.
A document can be created by more than one user, with each user giving permissions independently. e.g.:
- User 4 & 5 creates doc4. User 4 sets permission as EVERYONE while user 5 sets permission to ME_ONLY.
- User 6 & 7 creates doc5. User 6 sets permissions to MY_FRIENDS while user 7 sets permissive to ME_ONLY
For the case of multiple creators the less restrictive permission is used. e.g.:
- For doc4 the overriding permission will be EVERYONE
- For doc5 the overriding permission will be MY_FRIENDS
I have checked several discussions and can't find one that fits the model above:
- SOLR Permissions / Filtering Results depending on Access Rights
- https://issues.apache.org/jira/browse/SOLR-1872
- https://issues.apache.org/jira/browse/SOLR-1834
- http://lucene.472066.n3.nabble.com/Solr-and-Permissions-td2663289.html
- Fine grained security in Solr
To handle security I was thinking of 2 methods:
Create a dynamic field ("permissions_*") that holds permission for each document creator. e.g:
a) For doc1 permissions_1=1 b) For doc4 permissions_4=1 & permissions_5=3 Then a created a runtime method that checks each document permission (s) and decides if user trying to access is allowed.
For each permission create a field that hold user(s) that have set that permission. e.g.
a) For doc2 permission_1=[4], permission_2=[] & permission_3=[5] b) For doc5 permission_1=[], permission_2=[6] & permission_3=[7] Then use solr fq query to filter out documents based on permissions. However, I am not an expert in solr, so I still trying to find out how to create such a query.
A couple of questions:
- Is there a better way of handling this?
- Which of the 2 methods would scale?
Thanks in advance.