如何在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。
答案 0 :(得分:11)
我找到了答案。我们需要在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>
...
答案 1 :(得分:0)