Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wildfly Custom auth-method

How do you add a custom authenticator in Wildfly? I used to do this in JBoss 4.2:

In <JBoss>\jboss-as\server\production\deploy\jboss-web.deployer\META-INF\jboss-service.xml, add the following in :

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

In <JBoss>\jboss-as\server\production\deploy\jboss-portal-ha.sar\portal-server.war\WEB-INF\web.xml, modify :

...
 <login-config>
      <auth-method>MY-CUSTOM-AUTH</auth-method>
...

Wildfly does not have jboss-service.xml anymore.

like image 812
jersey-city-ninja Avatar asked Dec 14 '22 16:12

jersey-city-ninja


1 Answers

I found the answer. We need to create an Undertow ServletExtension (io.undertow.servlet.ServletExtension) in the META-INF/services to register the authentication mechanism . My extension class looks like this:

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

Check this for more details: http://undertow.io/documentation/servlet/security.html

Here's a sample: https://github.com/dstraub/spnego-wildfly

You can now refer to this in your web.xml:

...
 <login-config>
      <auth-method>NTLM</auth-method>
...
like image 94
jersey-city-ninja Avatar answered May 19 '23 07:05

jersey-city-ninja