gpt4 book ai didi

authentication - Wildfly 自定义身份验证方法

转载 作者:行者123 更新时间:2023-12-04 22:30:31 26 4
gpt4 key购买 nike

你如何在 Wildfly 中添加自定义身份验证器?我曾经在 JBoss 4.2 中这样做过:

<JBoss>\jboss-as\server\production\deploy\jboss-web.deployer\META-INF\jboss-service.xml 中,添加以下内容:

 <java:property>
<java:key>MY-CUSTOM-AUTH</java:key>
<java:value>com.test.MyCustomAuthenticator</java:value>
</java:property>

<JBoss>\jboss-as\server\production\deploy\jboss-portal-ha.sar\portal-server.war\WEB-INF\web.xml 中,修改:
...
<login-config>
<auth-method>MY-CUSTOM-AUTH</auth-method>
...

Wildfly 不再有 jboss-service.xml。

最佳答案

我找到了答案。我们需要在 META-INF/services 中创建一个 Undertow ServletExtension(io.undertow.servlet.ServletExtension)来注册认证机制。我的扩展类如下所示:

public class NtlmServletExtension implements ServletExtension {
@Override
public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) {
deploymentInfo.addAuthenticationMechanism("NTLM", new NtlmAuthenticationMechanism.Factory());
}
}

查看更多详细信息: http://undertow.io/documentation/servlet/security.html

这是一个示例:
https://github.com/dstraub/spnego-wildfly

你现在可以在你的 web.xml 中引用它:
...
<login-config>
<auth-method>NTLM</auth-method>
...

关于authentication - Wildfly 自定义身份验证方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28416668/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com