I'm working on a Java EE web application where I use Spring MVC and Spring security. Until now, I succeeded in implementing the common security features using a custom userService (which retrieves the information from my database) but I'm now facing a new security issue and I don't really know what's the best way to tackle it...
Here is what I need to do: Users who are authenticated in my app are allowed to navigate through their projects but should only be able to open the projects they have authorizations to (and open what is inside) but no other project.
My current implementation deals with it with the navigation (user interface) offering only the list of the authorized projects to the user. However if a clever user directly edits the URL to open a project with another id then no authorization test on the project id and the user is done so that it opens the project without trouble.
So, what I would like to add is a control on every requests for opening a project or something inside it. This control will test if the project id requested can be opened by the current user or not. If not, it will return to the user an access denied page. This control is easy to implement in itself but as it is a bit of code which could be in many methods of my app I would like to find the cleanest way to do it !
What do you think is the best way to implement that ? I considered several possibilities but I need advice:
1) Use servlet filters ?
2) Add a special access on Spring security with a custom authenticationManager ? something like :
<security:intercept-url pattern="/open*" access="canOpen()" />
(but I'm not sure how to define this and if I would be able to get the parameters coming from the original request...)
3) Use Aspect Oriented Programming ? (but I read somewhere that it does not work on controller calls)
4) Use Spring interceptors ?
5) other ideas ?
Thanks in advance for you help!