I'm trying to work out how the Login module flags work in JAAS (using JBoss 5.1 EAP) and I've come across a puzzling situation that I'm hoping someone can clarify for me.
For background, my login-config.xml looks like this:
<authentication-policy>
<authentication>
<login-module code="...loginModule1" flag="sufficient">
...
</login-module>
<login-module code="...loginModule2" flag="optional">
...
</login-module>
<login-module code="...loginModule3" flag="optional">
...
</login-module>
</authentication>
</authentication-policy>
In this case, loginModule1 is standalone, but loginModule2 depends on loginModule3. The problem I've got is that if loginModule1 fails and loginModule2 and loginModule3 both succeed I still get a failed login. If I change loginModule1 to be optional then when loginModule1 fails and 2 and 3 succeed I get a successful login.
From the JBoss security documentation (http://docs.jboss.org/jbossas/admindevel326/html/ch8.chapter.html):
sufficient: the LoginModule is not required to succeed. If it does succeed,
control immediately returns to the application (authentication does not proceed
down the LoginModule list). If it fails, authentication continues down the
LoginModule list.
I would have thought based on on this that when LoginModule with a sufficient flag fails, but a following LoginModule passes then I would get a successful login, anyone know why this isn't the case?