Description of problem:
When new HttpClient send request to servlet to do programmatic login, HttpSession isn't automatically created. Authentication is successful, but credentials aren't stored and you cannot access secured resource. It is needed to call request.getSession() on servlet to initialize session and store credentials.
If Single Sing On (SSO) configuration is enabled:
1. Non-clustered SSO - after second request to login, HttpSession is automatically created and user can access secured resource
2. Clustered SSO - on first request HttpSession is automatically created
Steps to Reproduce:
send request to
1. LoginServlet - admin/admin
FYI - https://community.jboss.org/thread/200602
This appears in Tomcat programmatic login as well, probably inherits from there. Checking Servlet 3.1 spec chapter7.2, although a "new" session is created, its not established until client joins it. By now, I'm not quite sure when exactly client should "join" it and make session become established during the programmatic authentication process.
For SSO situation, in AuthenticatorBase.register(), if sso is not null it ensures session association with a new SSO registration at last.
This issue/discussion needs to be brought to the notice of the JBoss Web team, if it hasn't already been.
Discussed with rmaucher on IRC, programmatic-login does not create sessions, therefore, to each secured page/servlet request it's normal to require re-authentication. With SSO configured, sessions are created because of a new SSO registration needs a session to associate with(same behaviour as tomcat does) which makes the second request passes without asking to login.
I am against any "behavior alignment" since the only possibility is to always create a session, something which has been carefully avoided so far.
Tomcat now has a new option to always create a session, disabled by default. That option can be ported.
Ported in r2336. System property to enable it is org.apache.catalina.authenticator.AuthenticatorBase.ALWAYS_USE_SESSION
Seeing as this was fixed a long time ago during 6.3.0, I am setting it to ON_QA for EAP 6.4.0
Verified in EAP 6.4.0.DR12. Doc Text should be changed from Known Issue to Enhancement or Bug Fix with description of system property that enables creating sessions: org.apache.catalina.authenticator.AuthenticatorBase.ALWAYS_USE_SESSION