[英]Keycloak Wildfly auth method
我創建了一個以 keycloak 作為子系統的 Wildfly 容器(wildfly 25.0.1 和 keycloak 15.0.2)。 我還有一個正在運行的 keycloak 容器。 嘗試使用 web.xml 部署一個簡單的 jakarta 應用程序(通過 maven 構建為戰爭並將其上傳到 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>
我的野蠅 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。 任何想法如何解決這個問題?
Keycloak 已棄用 Wildfly-Adapter 以支持內置的 Elytron OIDC-Authenticator。 https://www.keycloak.org/2021/12/keycloak-1510-released
您可以檢查這是否符合您的要求,或者暫時堅持使用 Wildfly 24。
有關使用 Elytron 內置身份驗證的更多信息,請參閱https: //wildfly-security.github.io/wildfly-elytron/blog/securing-wildfly-apps-openid-connect/。
不要將適配器安裝到 Wildfly 25 或 Wildfly 26 中。使用 wildfly:elytron-oidc-client:1.0 方式進行配置。 我的問題是一樣的,但是當我進行配置時,我得到了 403 狀態碼錯誤。 如果更改為 wildfly 23 一切正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.