【发布时间】:2021-11-17 09:15:50
【问题描述】:
我创建了一个以 keycloak 作为子系统的 Wildfly 容器(wildfly 25.0.1 和 keycloak 15.0.2)。我还有一个正在运行的 keycloak 容器。 尝试使用以下 web.xml 部署一个简单的 jakarta 应用程序(通过 maven 构建为 war 并将其上传到 wildfly)会导致以下错误:
{"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"demo1-1.0-
SNAPSHOT.war\".undertow-deployment" => "java.lang.RuntimeException:
java.lang.IllegalStateException: The required mechanism 'KEYCLOAK' is not available
in mechanisms [BASIC, CLIENT_CERT, DIGEST, FORM] from the HttpAuthenticationFactory.
Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: The
required mechanism 'KEYCLOAK' is not available in mechanisms [BASIC, CLIENT_CERT,
DIGEST, FORM] from the HttpAuthenticationFactory.
Caused by: java.lang.IllegalStateException: The required mechanism 'KEYCLOAK' is
not available in mechanisms [BASIC, CLIENT_CERT, DIGEST, FORM] from the
HttpAuthenticationFactory."}}
WEB-INF下我的web.xml:
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<module-name>demo</module-name>
<security-constraint>
<web-resource-collection>
<web-resource-name>Application</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>KEYCLOAK</auth-method>
<realm-name>my-auth</realm-name>
</login-config>
<security-role>
<role-name>user</role-name>
</security-role>
</web-app>
我的 Wildfly docker 文件:
FROM jboss/wildfly:25.0.0.Final
ENV KEYCLOAK_VERSION 15.0.2
ENV WILDFLY_HOME /opt/jboss/wildfly
RUN cd $WILDFLY_HOME && curl -LO https://github.com/keycloak/keycloak/releases/download/${KEYCLOAK_VERSION}/keycloak-oidc-wildfly-adapter-${KEYCLOAK_VERSION}.tar.gz \
&& tar -xzvf keycloak-oidc-wildfly-adapter-${KEYCLOAK_VERSION}.tar.gz \
&& rm keycloak-oidc-wildfly-adapter-${KEYCLOAK_VERSION}.tar.gz \
&& bin/jboss-cli.sh --file=bin/adapter-elytron-install-offline.cli \
# Admin-User anlegen
&& bin/add-user.sh admin admin1234 --silent \
# Zu Vermeidung von Fehlermeldungen beim Start
&& rm -r standalone/configuration/standalone_xml_history/current/
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]
EXPOSE 8285
EXPOSE 9992
在浏览器中打开 wildfly -> 配置 -> 子系统显示 keycloak 在那里。 我可以在 wildfly 容器的standalone.xml 文件中看到已设置以下内容:
<http-authentication-factory name="keycloak-http-authentication" security-domain="KeycloakDomain" http-server-mechanism-factory="keycloak-http-server-mechanism-factory">
<mechanism-configuration>
<mechanism mechanism-name="KEYCLOAK">
<mechanism-realm realm-name="KeycloakOIDCRealm" realm-mapper="keycloak-oidc-realm-mapper"/>
</mechanism>
</mechanism-configuration>
</http-authentication-factory>
该应用在 WEB-INF 中也有 keyclaock.json。 任何想法如何解决这个问题?
【问题讨论】:
-
我无法解决这个问题,但我使用带有 keyclaok 的 spring boot 而不是 jakarta 和 wildfly,它可以正常工作。
标签: jakarta-ee wildfly keycloak