I can create a secure, multi-tenant web app with Grails by :
- setup spring security plugin,
- setup Multi-tenant plugin (via multi-tenant install and multi-tenant-spring-security)
update config.groovy :
tenant { mode = "multiTenant" resolver.type = "springSecurity" }
add : Integer userTenntId in User domain
- add a domain class for tenant Organization
- associate the tenants with Organization
- Edit BootStrap.groovy.
Everything works fine in multi-tenant mode, but how to use mode = "singleTenant" ?
This configuration sound not working :
tenant { mode = "singleTenant" resolver.type = "springSecurity" }
Edit :
I try this config :
tenant {
mode = "singleTenant"
resolver.type = "springSecurity"
datasourceResolver.type = "config"
dataSourceTenantMap {
t1 = "jdbc:hsqldb:file:custFoo"
t2 = "jdbc:hsqldb:file:custBar"
}
}
But I get :
ERROR errors.GrailsExceptionResolver - Executing action [list] of controller [org.example.TicketController] caused exception: java.lang.StackOverflowError
and :
Caused by: java.lang.StackOverflowError
at org.grails.multitenant.springsecurity.SpringSecurityCurrentTenant.getTenantIdFromSpringSecurity(SpringSecurityCurrentTenant.groovy:50)
at org.grails.multitenant.springsecurity.SpringSecurityCurrentTenant.this$2$getTenantIdFromSpringSecurity(SpringSecurityCurrentTenant.groovy)
at org.grails.multitenant.springsecurity.SpringSecurityCurrentTenant$this$2$getTenantIdFromSpringSecurity.callCurrent(Unknown Source)
at org.grails.multitenant.springsecurity.SpringSecurityCurrentTenant.get(SpringSecurityCurrentTenant.groovy:41)
at com.infusion.tenant.spring.TenantBeanContainer.getBean(TenantBeanContainer.java:53)
at com.infusion.tenant.spring.TenantMethodInterceptor.invoke(TenantMethodInterceptor.java:32)
at $Proxy14.getConnection(Unknown Source)