JBoss AS7: Enabling JASPI Authentication for Web Applications

This document describes the steps needed to enable JASPI authentication for Web applications on JBoss AS7.


Application Server Configuration


The first step to enable JASPI is to configure a security domain that installs the JASPI login modules. So, in your standalone.xml (or domain.xml if using domain mode), add the JASPI configuration in the security subsystem:


                <!-- security domain configuration for the jaspi web basic test -->
                <security-domain name="jaspi-test" cache-type="default">
                        <login-module-stack name="lm-stack">
                            <login-module code="UsersRoles" flag="required">
                                <module-option name="usersProperties" value="../standalone/configuration/jaspi-users.properties"/>
                                <module-option name="rolesProperties" value="../standalone/configuration/jaspi-roles.properties"/>
                        <auth-module code="org.jboss.as.web.security.jaspi.modules.HTTPBasicServerAuthModule" login-module-stack-ref="lm-stack"/>


In this example we are configuring the HTTPBasicServerAuthModule, which will perform the BASIC authentication of a Web application. If FORM authentication is desired, just change the auth-module to org.jboss.as.web.security.jaspi.modules.HTTPFormServerAuthModule. Notice the configuration style is very similar to what is found in previous JBoss AS versions. The configured JASPI module can delegate the authentication and role mapping processes to a login module stack. In this case, we're using a simple UsersRoles module to authenticate and obtain roles for the users.


Web Application Configuration


The next step is to configure the Web application. First, we specify the type of authentication that is to be performed. For example, an application that requires BASIC authentication must specify that in the WEB-INF/web.xml file:


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">




Finally, we need to link the Web application to the security domain that will perform the authentication and configure the valve that will enable the JASPI authentication. Both things are done in the WEB-INF/jboss-web.xml file:


<?xml version="1.0"?>



The specified <security-domain> must match the name of the security domain that has been configured in the application server. It is also important that the WebJASPIAuthenticatorValve is configured as this valve replaces the Web container authenticator ir order to perform the JASPI authentication.


NOTE: the WebJASPIAuthenticator replaces the previous org.jboss.web.tomcat.security.jaspi.TomcatJASPIAuthenticator and MUST be configured in the jboss-web.xml file. JBoss AS7 doesn't allow for the configuration of authenticator valves in the JBossWeb subsystem like previous versions.