Wildfly Custom auth-method

jer*_*nja 4 authentication wildfly

如何在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>
Run Code Online (Sandbox Code Playgroud)

<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>
...
Run Code Online (Sandbox Code Playgroud)

Wildfly不再有jboss-service.xml了.

jer*_*nja 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());
    }
}
Run Code Online (Sandbox Code Playgroud)

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

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

您现在可以在web.xml中引用它:

...
 <login-config>
      <auth-method>NTLM</auth-method>
...
Run Code Online (Sandbox Code Playgroud)