Basically, you will use Spring's RequestHeaderAuthenticationFilter to get the user ID from the request headers and PreAuthenticatedAuthenticationProvider which is for use with any system where the user has already been authenticated (in this case by Shibboleth). This example also makes use of a custom MockRequestHeaderAuthenticationFilter which allows you to pass in a user ID when you're in the development environment to make testing easier.
Of course, first thing is you need to install Spring Security plugin and set its properties so it knows about your domain classes. Then, in conf/spring/resources.groovy you will need to set up a few beans:
In conf/Config.groovy, you need to let Spring Security know to use your preauthAuthenticationProvider:
grails.plugins.springsecurity.providerNames = ['preauthAuthenticationProvider']
This block in conf/BootStrap.groovy actually registers the filter for each environment. For development and test we want the mock filter and for QA and production, we use the real filter:
Thanks Ed, that was very helpful so thanks for writing this up.
ReplyDeleteI've also documented my own version on my blog for others interested in seeing various solutions to the same problem
http://pwu-developer.blogspot.com.au/2015/12/grails-2x-and-shibboleth-authentication.html
Cheers