0
votes

We are using multiple datasources distributed across regions. Each datasource is meant to handle all data related to all users of the region including security related data such as roles, tokens etc. I can not have all security related information in one datasource.

Does Spring security rest plugin for Grails support this setup? From what I understand it always looks at the default datasource for all authentication related tables and stores all tokens in default datasource alone.

Could someone confirm this? If the plugin supports multiple datasources, how to make it work?

Our environment: Grails 2.4.4 Spring security rest plugin 1.5.3 Spring security core 2.0-RC4 Postgresql 9.5

1

1 Answers

0
votes

Grails supports multiple datasources:

http://docs.grails.org/2.4.4/guide/single.html#multipleDatasources

In order to adjust Spring security core, one relatively easy option, would be to provide an alternative userDetailsService. (method: loadUserByUsername(String username) could be customized to do that) Which is in use by the DAOAuthenticationProvider to get user's details.

At that point, You would probably need to access more parameters from the request, to determine which datasource to access. So, the request object could be obtained using (for grails 2.x.x):

GrailsWebRequest webUtils = WebUtils.retrieveGrailsWebRequest()
def request = webUtils.getCurrentRequest()