Note that there are some explanatory texts on larger screens.

plurals
  1. POGrails 2.2.3 + Spring security core + Multi-tenant Single DB plugin
    primarykey
    data
    text
    <p>I am new to grails and I am trying to implement spring security core and Multi-tenant single db plugin. I have implemented the spring security core first and implemented custom AuthenticationProvider and Authentication. Then I have installed the multi-tenant single db plugin and ran the 'mt-spring-security' script that automatically created custom tenantResolver and tenantRepository. I have hard-coded the tenantId in tenantResolver for testing purpose. I have added the @MultiTenant annotation in the domain classes. </p> <p>@MultiTenant</p> <p>class ClientUser implements Serializable {</p> <pre><code>long idclient_user Userprofile user Client client int tenantId ... </code></pre> <p>}</p> <p>In the AuthenticationProvider, the ClientUser data is not filtered for the current tenant. It is bringing the data the all the tenant.</p> <p>class ClientAuthenticationProvider implements AuthenticationProvider {</p> <pre><code>Authentication authenticate(Authentication auth) throws AuthenticationException { ClientAuthentication authentication = auth String password = authentication.credentials String username = authentication.name String clientName = authentication.clientName ... Userprofile.withTransaction { status -&gt; def user = Userprofile.findWhere(username: username) def client = Client.findWhere(clientname: clientName) def clientUser = ClientUser.findWhere(client: client, user: user) &lt;-- NOT FILTERED FOR THE CURRENT TENANT. I HARD-CODED INVALID TENANTID IN THE TENANTRESOLVER AND EXPECTING IT TO FAIL BUT IT STILL FINDS THE USER. if (!clientUser) { throw new UsernameNotFoundException('User not found', username) } ... } ... result } </code></pre> <p>I am not sure how the multi-tenant and spring security works together. I am having a hard time understanding the Architecture/design.</p> <p>If anyone could provided me with a sample implementation or point me in the right direction, it will be really helpful. Thanks, dinesh</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload