Description
When #6215 was fixed only the adding of new OAuth2AuthorizationRequest
s was fixed, not the removal of those. With a distributed session store we observed an increase in session size for users having long running sessions.
A dump of the keys of the session attributes revealed a huge HashMap
of OAuth2AuthorizationRequest
. This is due to org.springframework.security.oauth2.client.web.server.WebSessionOAuth2ServerAuthorizationRequestRepository#removeAuthorizationRequest
only removing the OAuth2AuthorizationRequest
from the HashMap
and not updating the session attributes leaving no clue to the session repository that the session was amended.
The expected behaviour would be that the stateToAuthzRequest HashMap
should not grow without limit and OAuth2AuthorizationRequest
should be removed after it was used to create a new session.
Used version: spring-security-oauth2-client-5.1.6.RELEASE.jar
however the issue exists on master: https://github.com/spring-projects/spring-security/blob/master/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/server/WebSessionOAuth2ServerAuthorizationRequestRepository.java#L85