Improve state handling in handleAuthorizationCodeResponse
Fail fast when there is no state in session, e.g. because the session cookie was removed. Resolves #949pull/952/merge
parent
6d2b73a7ef
commit
4f9ea0b474
|
@ -286,11 +286,9 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
|
||||||
|
|
||||||
// check for state, if it doesn't match we bail early
|
// check for state, if it doesn't match we bail early
|
||||||
String storedState = getStoredState(session);
|
String storedState = getStoredState(session);
|
||||||
if (!Strings.isNullOrEmpty(storedState)) {
|
String requestState = request.getParameter("state");
|
||||||
String state = request.getParameter("state");
|
if (storedState == null || !storedState.equals(requestState)) {
|
||||||
if (!storedState.equals(state)) {
|
throw new AuthenticationServiceException("State parameter mismatch on return. Expected " + storedState + " got " + requestState);
|
||||||
throw new AuthenticationServiceException("State parameter mismatch on return. Expected " + storedState + " got " + state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// look up the issuer that we set out to talk to
|
// look up the issuer that we set out to talk to
|
||||||
|
|
Loading…
Reference in New Issue