gorm - Discriminator multi-tenant setup with SpringSecurity plugin in Grails -


i'm trying setup discriminator-based multi-tenant system based on documentation found in gorm guide

do determine tenant using system want use spring security plugin , show data depending on user id.

this tenantresolver:

class mytenantresolver implements alltenantsresolver {      def springsecurityservice      @override     iterable<serializable> resolvetenantids() {         return new detachedcriteria(user)                 .distinct('id')                 .list()     }      @override     serializable resolvetenantidentifier() throws tenantnotfoundexception {         return springsecurityservice.currentuser.id     } } 

and add springsecurityservice in resources.groovy file:

beans = {     mytenantresolver(mytenantresolver) {         springsecurityservice = ref("springsecurityservice")     } } 

unfortunately causes circular dependency:

the dependencies of of beans in application context form cycle:     grailscachefilter       ↓    (inner bean)#6c1f419f       ↓    urlmappingshandlermapping       ↓    opensessioninviewinterceptor ┌─────┐ |  hibernatedatastore ↑     ↓ |  hibernateconnectionsourcefactory ↑     ↓ |  mytenantresolver ↑     ↓ |  springsecuritycorespringsecurityservice ↑     ↓ |  transactionmanager └─────┘ 

what can differently able check against logged in user?

(using grails 3.2.8 , spring security 3.1.1)

finally solved fetching session through requestcontextholder:

class mytenantresolver implements alltenantsresolver {      @override     iterable<serializable> resolvetenantids() {         return new detachedcriteria(customer)                 .distinct('id')                 .list()     }      @override     serializable resolvetenantidentifier() throws tenantnotfoundexception {         user.withtransaction {             def session = requestcontextholder.currentrequestattributes().getsession()             return user.read(session.getattribute('spring_security_context').authentication.principal.id).customerid         }     } } 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -