Keycloak extension with dependencies

You have to create your SPI dependencies as jboss modules.

Steps:

  1. Add a jboss-deployment-structure.xml file in src/main/resources/META-INF directory or your SPI with something like this (oficial documentation):

    <jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.json.json" />
        </dependencies>
    </deployment>
    </jboss-deployment-structure>
    
  2. Make $KEYCLOAK_HOME/modules/system/layers/base/org/json/json/main directory

  3. Add json-20160810.jar in created dir

  4. Add a module.xml file in same dir with this content:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <module xmlns="urn:jboss:module:1.5" name="org.json.json">
        <properties>
            <property name="jboss.api" value="private"/>
        </properties>
    
        <resources>
            <resource-root path="json-20160810.jar"/>
        </resources>
    
        <dependencies>
        </dependencies>
    </module>
    
  5. Compile your SPI

  6. Restart keycloak

  7. Redeploy your SPI


There is a better way, deploy as a EAR archive. This project shows how to: https://github.com/stianst/keycloak-experimental/tree/master/fido-u2f