Hibernate, Spring and row level security¶
- Table of contents
- Hibernate, Spring and row level security
Description of the problem¶
Spring Security is a mature and flexible framework to secure desktop as well as web applications. It provides different authentication and authorizations mechanisms. It allows protecting web requests with filters and is using Spring's standard AOP to wrap around and thus protect service methods. The problem with this that occurs in the cdm library is that we also need to protect data at the rowlevel, that is in the DAO layer (cdmlib-persitence) and in hibernate search (Lucene). Post filtering would break the paging mechanism and it is unclear how we can filter out cdm entities which are returned by the getters of other cdm instances.
Hibernate, Spring Security and paging¶
http://mikemclean.ca/wp/2011/11/22/hibernate-spring-security-and-list-paging/, Solution: "pulling out all the data on each page request is acceptable (we have a query cache enabled, so it’s not as bad as it may sound)."
hibernate fiteringCollections [m.cherian] ==> good hint, using these terms in a search reveals some good information:
Row level security using Spring and Hibernate":http://mattfleming.com/node/243 (* excellent! *) based on "Using Spring AOP and Hibernate Filters to add row level security (3rd Update working impl and conf)
another description of the problem and summary of some possible solutions : Security decorator for Hibernate collection
Hibernate Seach (Lucene) with Paging and Spring Security ACLs¶
a. you have to load the documents and resolve the ACL for each result and then do your own paging. => performance problems ?
b. alternative is to push this work to the indexing side and index your ACL in Lucene. => complicated
c. use org.apache.lucene.search.Filter and BitSets. If your ACL is not too complex, that is you have a small, finite number of levels. And here you'll find additional examples ACL implementation with Filters http://java.dzone.com/articles/how-implement-row-level-access ==> sounds good