<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    After lots of experimentation, I think I've finally settled on a
    design.&nbsp; Though this whole effort has taken longer than expected, I
    don't think the coding will take that long since I've got
    experimental code that does the hard stuff.&nbsp; I just need to
    rearrange it and clean it up.<br>
    <br>
    Here is the design.&nbsp; I appreciate your feedback.<br>
    <br>
    <u><b>Design Goals</b></u><br>
    * Support auth-server running in a WildFly domain.<br>
    * Eliminate deployment from /deployments directory to make it a
    proper service instead of an ordinary app.<br>
    * Eliminate need to explode or crack open auth-server.war.&nbsp; Keep it
    intact so it doesn't need to be hacked up.<br>
    * Load user-provided overlays for keycloak-server.json, SPI jars,
    and theme jars.<br>
    * Allow uploading overlays from CLI.<br>
    * Allow more than one auth-server in a WildFly instance.<br>
    * Compatibility with EAP6, EAP7, WildFly8, and WildFly9.<br>
    <br>
    <br>
    <u><b>Management Model</b></u><br>
    The Keycloak subsystem introduces a new resource called,
    "auth-server".&nbsp; You can define more than one auth-server if you
    like.&nbsp; The simplest form just looks like this:<br>
    &lt;subsystem xmlns="urn:jboss:domain:keycloak:1.1"&gt;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;auth-server name="my-auth-server-name"/&gt;<br>
    &lt;/subsystem xmlns="urn:jboss:domain:keycloak:1.1"&gt;<br>
    <br>
    On startup, this deploys my-auth-server-name.war with web context
    "auth".<br>
    <br>
    There are two optional attributes under &lt;auth-server&gt;.&nbsp; They
    are "enabled" and "web-context".&nbsp; Here is an example:<br>
    &lt;subsystem xmlns="urn:jboss:domain:keycloak:1.1"&gt;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;auth-server name="auth-server1"/&gt;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;auth-server name="auth-server2"&gt;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;enabled&gt;true&lt;enabled/&gt;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;web-context&gt;auth2&lt;/web-context&gt;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/auth-server&gt;<br>
    &lt;/subsystem xmlns="urn:jboss:domain:keycloak:1.1"&gt;<br>
    <br>
    In a domain environment, there is an additional resource.&nbsp; You
    assign the auth server to one or more server groups:<br>
    &lt;subsystem xmlns="urn:jboss:domain:keycloak:1.1"&gt;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;auth-server name="my-auth-server-name"&gt;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;server-group name="group1"/&gt;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;server-group name="group2"/&gt;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/auth-server&gt;<br>
    &lt;/subsystem xmlns="urn:jboss:domain:keycloak:1.1"&gt;<br>
    <br>
    <u><b>Loading the Auth Server</b></u><br>
    The auth-server.war will be loaded from the Keycloak subsystem
    module.&nbsp;&nbsp; This is just a convenient place to put it.&nbsp; We could
    actually load it from anywhere.&nbsp; Note that it no longer needs to be
    exploded.<br>
    <br>
    <u><b>Using Overalys</b></u><br>
    The Keycloak subsystem can overlay or add to the auth-server.war.&nbsp;
    Overlays do not touch the original content of auth-server.war.<br>
    <br>
    To define an overaly, you just drop your files in the proper
    directories on the file system.&nbsp; The layout is:<br>
    <br>
    /overlays/&lt;auth-server-name&gt;/server-config/<br>
    /overlays/&lt;auth-server-name&gt;/account-spi/<br>
    /overlays/&lt;auth-server-name&gt;/login-spi/<br>
    /overlays/&lt;auth-server-name&gt;/other-spi/<br>
    <br>
    /server-config optionally contains a single json file that replaces
    keycloak-server.json<br>
    /account-spi optionally contains a single jar file that replaces
    keycloak-account-freemarker.jar.<br>
    /login-spi optionally contains a single jar file that replaces
    keycloak-login-freemarker.jar<br>
    /other-spi optionally contains one or more spi jar files to be added
    to WEB-INF/lib.&nbsp; Theme jars also go here.<br>
    <br>
    <u><b>Location of SPI jars and other user-defined overalys</b></u><br>
    For now, I'm planning to have the /overlays directory in the
    Keycloak subsystem module.&nbsp; They could, for instance, go in a
    /keycloak directory such as &lt;wildfly-home&gt;/keycloak.&nbsp;&nbsp; Any
    thoughts on this?<br>
    <br>
    <u><b>Uploading overlays from CLI</b></u><br>
    It is already possible to create overalys via CLI.&nbsp; You upload the
    content and assign it to deployments and server-groups.&nbsp; The CLI
    commands for this are rather complicated and you really need to know
    what you are doing.&nbsp; <br>
    <br>
    We could make this easier by adding simpler CLI operations to the
    Keycloak subsystem.&nbsp; However, I think we should hold off on this
    until we find out if the directory-based approach is acceptable to
    users.&nbsp; In the mean time, we can just document the CLI commands
    needed to upload overlays.<br>
  </body>
</html>