Sorry for missing your ping as this is something that we definitely need. I was going down the keycloak.js path (since we use AngularJS as our UI layer) but doing it on the server side is so much more elegant.
Picking the realm name from the URI is the way to go. Maybe we have it as a query parameter rather than within the path as then it is less invasive for the war application.
I don't understand the keycloak code base enough to comment on how we can deploy the new AdapterDeploymentContext but what if this feature is plugged into the current AdapterDeploymentContext and this is a feature of the core product?
Also with regard to getting realm information from the server using a shared client secret, or public clients, another way to do this might be to provide an alternate way to pick the keycloak.json file by storing it outside the war in the file system and then based on the realm name in the uri, pick the corresponding keycloak.json file and run the KeycloakDeployment. We can name the the files as keycloak-{realmname}.json
Note we can keep the current functionality where it can pick it from within the war but if the file is missing, currently its throwing an exception. Maybe before we throw the exception, we also check the file system as well.
Then maybe we don't need to load this on request but can have a directory scanner and whenever a new file is added or removed, it will automatically pick it up. Sort of how the JBoss/Wildfly deployment scanner works. On each request of course it will need to pick the correct realm to perform the authentication.
This might be more elegant but once again I don't know enough of the core keycloak code to comment if doing this is more complex than the other option.
Obviously these changes will not go into 1.0 release but a subsequent release (hopefully the first beta release after 1.0 :)
Therefore it might be good to give some thought and get this right. For me this and the multi-lingual are the two key items that we need to tick off to be able to use this in a multi tenancy environment.
Keen to know your thoughts.
Cheers
Travis