views:

416

answers:

1

What I am looking to accomplish is a filter (or similar) that would handle the authentication model for my Spring MVC application. My application is also hosted on Google App Engine.

The authentication on this application can tend to be very dynamic and the permissions are not something that would fit cleanly into a predefined Role structure. These permissions would be tied to the different action methods on my controllers. Ideally I would like to be able to annotate these permissions but I am open for other suggestions.

I am finding that there is not very much information around on how to accomplish this. Ideally I would like to be able to intercept the call to my controller actions and be able to read off the annotations and handle accordingly. What I am hoping is that someone here has a little bit more knowledge on Spring MVC and where I can inject some custom code, and would be able to point me in the right direction.

+3  A: 

I would still use Spring Security to do this. It may not have a class that 100% fits your login scheme, but that's what inheritance is for. Write your own. You can easily get rid of the ROLE based DecisionManager and make it fit your paradigm.

Based on your comments have you checked out the MethodInterceptor in Spring? It creates a Proxy that will intercept calls to any method on the proxied class and allow you to run or disallow the method based on any code you want. In Spring Security there is an AbstractSecurityInterceptor, but I find it very hard to use and for most access decisions I think it's overkill.

So I would use Spring Security to authenticate the user (and populate the SecurityContext) and then use interceptors to wall off access to methods in your controllers that you want protected.

Gandalf
I'm resigned to writing my own code implementation but I'm finding the documentation on Spring Security lacking, if you have any links that you have found useful it would be appreciated. Thanks.
bdorry
Sure, I know it took me a while to get through it all - and some of the docs are a little ambiguous. If it seems like they are saying there are multiple ways to do something, well, there probably is. Could you augment your question with a bit more detail and maybe I could point you in the right direction.
Gandalf
To be more concise, what I really need is the ability to intercept an action and perform some quick checks on the authenticated user. These checks will read permission from the database and perform redirects according to business.This information I can receive out of App Engine's built in services and through the use of my own proprietary services but I currently cannot find a way to intercept the calls to my controller actions.
bdorry