Improve state handling in handleAuthorizationCodeResponse

Fail fast when there is no state in session, e.g. because the session
cookie was removed.

Resolves #949
pull/952/merge
Mark Janssen 2015-10-25 19:17:58 +01:00 committed by Justin Richer
parent 6d2b73a7ef
commit 4f9ea0b474
1 changed files with 3 additions and 5 deletions

View File

@ -286,11 +286,9 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
// check for state, if it doesn't match we bail early
String storedState = getStoredState(session);
if (!Strings.isNullOrEmpty(storedState)) {
String state = request.getParameter("state");
if (!storedState.equals(state)) {
throw new AuthenticationServiceException("State parameter mismatch on return. Expected " + storedState + " got " + state);
}
String requestState = request.getParameter("state");
if (storedState == null || !storedState.equals(requestState)) {
throw new AuthenticationServiceException("State parameter mismatch on return. Expected " + storedState + " got " + requestState);
}
// look up the issuer that we set out to talk to