Configure DB Login Module in JBoss

Add to conf/login-config.xml:

<application-policy name="MyPolicy">


<login-module flag="required" code="">

<module-option name="dsJndiName">java:/AuthorityDB</module-option>

<module-option name="principalsQuery">SELECT Password FROM Users WHERE Username=?</module-option>

<module-option name="rolesQuery">SELECT Rolename, "Roles" FROM Roles WHERE Username=?</module-option>




The application policy name declares a new policy. We will reference this name in each [web] application that wishes to use it.

To enrich your career and become a JBoss professional, visit Tekslate, the global online training platform:" JBoss Training". This course will help you achieve excellence in this field.

The required flag means that the login module is required to succeed.

If it succeeds or fails, authentication still continues to proceed down the LoginModule list

Other options are: requisite, sufficient, and optional

Module option dsJndiName:

Defines the JNDI name of the RDBMS DataSource that defines logical users and roles tables

Defaults to java:/DefaultDS

Module option principalsQuery:

Defines a prepared SQL statement that queries the password of a given username

Defaults to select Password from Principals where PrincipalID=?

Module option rolesQuery:

Defines a prepared SQL statement that queries role names (and groups) of a given username

The default group name is Roles (hard-coded). Defaults to select Role, RoleGroup from Roles where PrincipalID=?

For an in-depth understanding on JBoss click on: