JBoss Community

JBoss AS7: Security : Custom Login Modules

created by Anil Saldhana in PicketBox Development - View the full document

When you write your own custom login module (or Authorization Module or Audit Provider or Mapping Provider), then you have two choices as to where the class files exist in JBoss AS7.1

 

Options

  1. Package them as part of your EE archives (such as WEB-INF/classes or WEB-INF/lib)

  2. Place in a separate module in the modules directory of JBoss AS 7.1

 

 

Option 1 is covered in http://community.jboss.org/wiki/JBossAS7SecurityDomainModel

 

Option 2 is described here with an example:

 

Assume we have a web application called form-auth.war  which utilizes form authentication. It is attached to the article.

 

It uses a security domain form-auth that will be defined in standalone/configuration/standalone.xml as follows:

 

 <security-domain name="form-auth" cache-type="default">
    <authentication>
         <login-module code="custom.MyLoginModule" flag="required" module="custom_module">
              <module-option name="usersProperties" value="users.properties"/>
              <module-option name="rolesProperties" value="roles.properties"/>
         </login-module>
    </authentication>
 </security-domain>

 

Note: You will have to download the attached custom_module.zip and unzip it in the modules directory of AS7.1

 

 

jboss-as-7.1.0.Alpha2-SNAPSHOT/modules$ ls -la
drwxrwxr-x.  3 anil anil 4096 Nov 16 14:53 asm
drwxrwxr-x.  3 anil anil 4096 Nov 16 14:53 ch
drwxrwxr-x.  5 anil anil 4096 Nov 16 14:53 com
drwxrwxr-x.  3 anil anil 4096 Nov 16 14:57 custom_module
drwxrwxr-x.  3 anil anil 4096 Nov 16 14:53 gnu
drwxrwxr-x.  3 anil anil 4096 Nov 16 14:53 javaee
drwxrwxr-x. 25 anil anil 4096 Nov 16 14:54 javax
drwxrwxr-x.  3 anil anil 4096 Nov 16 14:53 jline
drwxrwxr-x.  3 anil anil 4096 Nov 16 14:53 juddi
drwxrwxr-x.  3 anil anil 4096 Nov 16 14:53 net
drwxrwxr-x. 23 anil anil 4096 Nov 16 14:54 org
drwxrwxr-x.  3 anil anil 4096 Nov 16 14:54 sun

 

 

If everything is ok, when you start AS7.1, then you should be able to access http://localhost:8080/form-auth/

Username: anil

Password: anil

Comment by going to Community

Create a new document in PicketBox Development at Community