REF-30: Change the session id when a login is accepted - #97
Merged
Merged
Conversation
The validated assertion was stored on whatever session the browser already had. The container session id was never rotated across the authentication boundary, so an id present before login stayed valid as an authenticated session afterwards, which is what session fixation relies on. AssertionHandler now changes the session id once validation has passed and before the assertion is stored. Session state is keyed on the container session id, so the in-flight AuthnRequest is stored again under the new id, otherwise the session would look unauthenticated to AuthenticatedFilter and the user would be sent straight back to the IdP. changeSessionId() is Servlet 3.1, so javax.servlet-api goes from 3.0.1 to 3.1.0 and the library now requires a Servlet 3.1 container, which the README states. The demo ran on the tomcat7 plugin, Servlet 3.0, and now runs on the jetty-maven-plugin with the HTTPS connector configured in demo/src/main/jetty/jetty-https.xml. Verified by starting the demo and fetching the front page and the SP metadata over https://localhost:8443. Two test stream stubs had to implement the methods Servlet 3.1 added to ServletInputStream and ServletOutputStream. Tested by asserting the order in AssertionHandler: session id changed, AuthnRequest stored again, assertion stored.
mthiim
approved these changes
Aug 26, 2026
# Conflicts: # oiosaml/src/test/java/dk/gov/oio/saml/util/TestConstants.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gives the session a new id when a login is accepted.
Problem
The validated assertion was stored on whatever session the browser already had. The container session id was never rotated across the authentication boundary, so an id present before login stayed valid as an authenticated session afterwards, which is what session fixation relies on.
Changes
AssertionHandlerchanges the session id once validation has passed and before the assertion is stored.AuthenticatedFilterand the user is sent straight back to the IdP.Breaking: the library now requires Servlet 3.1
HttpServletRequest.changeSessionId()is Servlet 3.1, sojavax.servlet-apigoes from 3.0.1 to 3.1.0. Consumers on a Servlet 3.0 container will need to move to 3.1 or later; worth a line inRELEASE_NOTES.mdat release time.Consequences in this repository:
tomcat7-maven-plugin, which is Servlet 3.0. It now runs onjetty-maven-plugin9.4 with the HTTPS connector configured indemo/src/main/jetty/jetty-https.xml, reading the existingmisc/ssl-demo.pfxkeystore. The run command is nowmvn clean installfollowed bymvn -pl demo jetty:run-war, as documented in the README.ServletInputStreamandServletOutputStream.Verification
mvn -pl oiosaml test→ 113 tests, 1 failure: the pre-existingOIOBPPUtilTest(JDK 26 JAXB incompatibility), which also fails onmaster.The new test asserts the ordering: session id changed, AuthnRequest stored again, assertion stored. With
AssertionHandlerreverted it fails.The demo was started on Jetty and checked over TLS:
https://localhost:8443/oiosaml3-demo.java/returns 200 and/saml/metadataserves the SP metadata.Note that
mvn installat the reactor level stops in theidpmodule. That failure is present on unmodifiedmasteras well and is unrelated to this change.