[keycloak-user] Authentication SPI and connection management

Max Musternam mytestemal at gmail.com
Tue Jun 27 03:50:59 EDT 2017


Hello,


I've followed the instructions from

https://keycloak.gitbooks.io/documentation/server_installation/topics/database.html

But instead of changing the existing DS and provider, I added
another one, because I have to implement additional check and/or actions
against the data in the second database:

   <subsystem xmlns="urn:jboss:domain:datasources:4.0">
      <datasources>
        <datasource jndi-name="java:jboss/datasources/KeycloakDS"
pool-name="KeycloakDS" enabled="true" use-java-context="true">
           ...
        </datasource>
        <datasource jndi-name="java:jboss/datasources/myDbDS"
pool-name="mydb" enabled="true" use-java-context="true">
<connection-url>jdbc:postgresql://192.168.XX.XX/myproject</connection-url>
            <driver>postgresql</driver>
            <pool>
                <max-pool-size>20</max-pool-size>
            </pool>
            <security>
                <user-name>user</user-name>
                <password>password</password>
            </security>
        </datasource>
      </datasources>
   </subsystem>
   <subsystem xmlns="urn:jboss:domain:keycloak-server:1.1">

      <spi name="connectionsJpa">
         <provider name="default" enabled="true">
            ...
         </provider>
         <provider name="mydb" enabled="true">
             <properties>
                 <property name="dataSource"
value="java:jboss/datasources/myDbDS"/>
                 <property name="initializeEmpty" value="false"/>
                 <property name="migrationStrategy" value="validate"/>
             </properties>
         </provider>
      </spi>
      ...
   </subsystem>


Now I can't find this connection provider in the admin console. Only the
default is listed in Server Info > Providers. In the log file I've found
initialization of both datasources

 (MSC service thread 1-8) WFLYJCA0001: Bound data source
[java:jboss/datasources/KeycloakDS
 (MSC service thread 1-1) WFLYJCA0001: Bound data source
[java:jboss/datasources/myDbDS

but only one PersistenceUnit was processed:

HHH000204: Processing PersistenceUnitInfo [
        name: keycloak-default
        ...]



As result the call

context.getSession().keycloakSession.getProvider(JpaConnectionProvider.class,
"default")

does return me an instance of JpaConnectionProvider Class, but the call

context.getSession().keycloakSession.getProvider(JpaConnectionProvider.class,
"mydb")

returns null.

Would you suggest possible solution of the problem?

Server Version: 3.1.0.Final

Thank a lot in advance.


More information about the keycloak-user mailing list