[keycloak-user] Configure spring application with Spring Security Adapter and Multi Tenancy

Mattia Bello Mattia.Bello at horsa.it
Tue Sep 18 10:34:38 EDT 2018


Hello,
                i tried to integrate keycloak Spring Security Adapter and Multi Tenancy but i encountered some problems.

I followed the guide step by step:

1. I installed keycloak on server and runned it in standalone mode on port 8180.

2. I added the dependency in pom file:

<dependency>
    <groupId>org.keycloak</groupId>
    <artifactId>keycloak-spring-security-adapter</artifactId>
    <version>4.4.0.Final</version>
</dependency>

Because my spring app is a old spring app, i prefer use the xml configure to manage the security.
I created keycloakApplicationContext.xml with the configuration describe in the guide (attached keycloakApplicationContext.xml file).

The guide continue introduce the Multi tenancy:
The Keycloak Spring Security adapter also supports multi tenancy. Instead of injecting AdapterDeploymentContextFactoryBean with the path to keycloak.json you can inject an implementation of the KeycloakConfigResolver interface. More details on how to implement the KeycloakConfigResolver can be found in Multi Tenancy.

3. Then, to implement the Multi tenancy i followed the section:
I created the PathBasedKeycloakConfigResolver java class (attached PathBasedKeycloakConfigResolver.java file) and added rows in web.xml file (attached web.xml file).

In the previous point, the guide describe that:
Instead of injecting AdapterDeploymentContextFactoryBean with the path to keycloak.json you can inject an implementation of the KeycloakConfigResolver interface. More details on how to implement the KeycloakConfigResolver can be found in Multi Tenancy
But in the Multi Tenancy section i didn't found the istructions to do that.

In the web.xml i specify the path to keycloak.json and it is required to create the bean. If i delete it the app when starting will will go to error.

What do i do to use Multi Tenancy? 

Thanks to all


 


Mattia Bello
Developer

[Descrizione: cid:image001.jpg at 01CEB308.188717E0]
Horsa S.p.A.
Via Cadorna, 67
Vimodrone (MI)
Mobile  (+39) 347 37 64 875
www.horsa.it<http://www.horsa.it/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PathBasedKeycloakConfigResolver.java
Type: application/octet-stream
Size: 1824 bytes
Desc: PathBasedKeycloakConfigResolver.java
Url : http://lists.jboss.org/pipermail/keycloak-user/attachments/20180918/f94b0639/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: web.xml
Type: text/xml
Size: 11027 bytes
Desc: web.xml
Url : http://lists.jboss.org/pipermail/keycloak-user/attachments/20180918/f94b0639/attachment-0002.xml 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: keycloakApplicationContext.xml
Type: text/xml
Size: 14101 bytes
Desc: keycloakApplicationContext.xml
Url : http://lists.jboss.org/pipermail/keycloak-user/attachments/20180918/f94b0639/attachment-0003.xml 


More information about the keycloak-user mailing list