Skip to content

saveAuthenticationRequest should read relayState from authenticationRequest#18872

Open
therepanic wants to merge 1 commit intospring-projects:6.5.xfrom
therepanic:gh-18243
Open

saveAuthenticationRequest should read relayState from authenticationRequest#18872
therepanic wants to merge 1 commit intospring-projects:6.5.xfrom
therepanic:gh-18243

Conversation

@therepanic
Copy link
Contributor

@therepanic therepanic commented Mar 10, 2026

I believe there are a number of design implementation mistakes in CacheSaml2AuthenticationRequestRepository.

One of them is that in CacheSaml2AuthenticationRequest#saveAuthenticationRequest, if authenticationRequest == null, we cache the cache itself with a null value, whereas we should be removing it.

Furthermore, I believe we should take the relay state directly from authenticationRequest and not from request, since our Saml2AuthenticationRequestResolver should resolve and return an object that should be passed to our method.

Closes: gh-18243

Comment on lines +57 to +60
if (authenticationRequest == null) {
removeAuthenticationRequest(request, response);
return;
}
Copy link
Contributor Author

@therepanic therepanic Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@therepanic
Copy link
Contributor Author

BTW, the mention of deletion and null was made not so long ago: e771ec0 I believe we reached this conclusion based on the logic of HttpSessionSaml2AuthenticationRequestRepository.

@jzheaux jzheaux self-assigned this Mar 11, 2026
@jzheaux jzheaux added type: bug A general bug in: saml2 An issue in SAML2 modules and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 11, 2026
@jzheaux jzheaux added this to the 6.5.9 milestone Mar 11, 2026
Closes spring-projectsgh-18243

Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
@jzheaux jzheaux changed the base branch from main to 6.5.x March 11, 2026 22:59
HttpServletRequest request, HttpServletResponse response) {
Assert.notNull(authenticationRequest, "authenticationRequest must not be null");
String relayState = request.getParameter(Saml2ParameterNames.RELAY_STATE);
String relayState = authenticationRequest.getRelayState();
Copy link
Contributor

@jzheaux jzheaux Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

Please see 266d260 and ef76ba0, which I believe were necessary changes on different branches to address the other concerns you raised in your PR comments. These ultimately simplified this PR to allow focusing on the specific bug.

@jzheaux jzheaux changed the title Fix saveAuthenticationRequest to read relayState from authenticationRequest saveAuthenticationRequest should read relayState from authenticationRequest Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: saml2 An issue in SAML2 modules type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CacheSaml2AuthenticationRequestRepository.saveAuthenticationRequest(..) throws IllegalArgumentException

3 participants