Configure DB Login Module in JBoss

Ratings:
(4)
Views: 0
Banner-Img
Share this blog:

Configure DB Login Module in JBoss

Add to conf/login-config.xml:

<application-policy name="MyPolicy">
<authentication>
<login-module flag="required" code="org.jboss.security.auth.spi.DatabaseServerLoginModule">
<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>
</login-module>
</authentication>
</application-policy>

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=?

 

You liked the article?

Like: 0

Vote for difficulty

Current difficulty (Avg): Medium

EasyMediumHardDifficultExpert
IMPROVE ARTICLEReport Issue

About Author

Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.

Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox