我為在 JBoss EAP 6.2 上運行的兩個客戶提供了一個應用程序(打包為 war)。其中之一使用基本 JBoss 身份驗證,另一個使用 Keycloak 身份驗證提供程序。兩個 war 文件完全相同,只有一個區(qū)別:WEB-INF/web.xml 包含<login-config> <auth-method>BASIC</auth-method> <realm-name>ApplicationRealm</realm-name></login-config>分別<login-config> <auth-method>keycloak</auth-method> <realm-name>application</realm-name></login-config>我想防止構(gòu)建兩個不同的 war 文件(因為 web.xml 在 war 文件中)所以我想知道如何在 JBoss 配置中而不是在 web.xml 中配置這些行。
1 回答

蕭十郎
TA貢獻1815條經(jīng)驗 獲得超13個贊
您可以定義login-config如下:
<login-config>
<auth-method>${authentication.method}</auth-method>
<realm-name>${authentication.realm}</realm-name>
</login-config>
然后在應用程序服務(wù)器啟動時將這些參數(shù)作為系統(tǒng)屬性傳遞:
-Dauthentication.method=BASIC -Dauthentication.realm=ApplicationRealm
但您應該記住,默認情況下 WildFly/JBoss 不會替換部署描述符中的變量。您應該在子系統(tǒng)下的服務(wù)器配置中明確啟用此選項ee。在WildFly 13.0.0.Final中是這樣的:
<subsystem xmlns="urn:jboss:domain:ee:4.0">
<spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>
<!-- remaining of the configurations -->
</subsystem>
添加回答
舉報
0/150
提交
取消