I have one application (packaged as war) for two customers running on JBoss EAP 6.2. One of them uses Basic JBoss Authentication, the other one Keycloak authentication provider.
Both war files are exactly the same with one difference: The WEB-INF/web.xml contains
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ApplicationRealm</realm-name>
</login-config>
respectively
<login-config>
<auth-method>keycloak</auth-method>
<realm-name>application</realm-name>
</login-config>
I would like to prevent to build two different war files (because web.xml is inside of the war file) so I wondered how I can configure these lines in the JBoss configuration instead of in web.xml.
You can define your login-config
as below:
<login-config>
<auth-method>${authentication.method}</auth-method>
<realm-name>${authentication.realm}</realm-name>
</login-config>
And then pass those parameters as system properties when application server starts:
-Dauthentication.method=BASIC -Dauthentication.realm=ApplicationRealm
But you should remember that by default WildFly/JBoss will not replace variables in deployment descriptors. You should explicitly enable this option in your server configurations under ee
subsystem. In WildFly 13.0.0.Final it's like this:
<subsystem xmlns="urn:jboss:domain:ee:4.0">
<spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>
<!-- remaining of the configurations -->
</subsystem>