spring-projects / spring-projects/spring-security
Logout and InvalidSessionStrategy
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
I have problem during logout when I have set invalid session url.
sessionManagement()
.invalidSessionUrl("/login?sessionExpired");
Spring goes to Logout filter invalidate session and then in SessionManagerFilter check it session is valid. In that moment request point to login?logout but goes to invalidSessionStrategy and change that to login?sessionExpired. Maybe in SimpleRedirectInvalidSessionStrategy there should be some check if that url has set permitAll() and don't redirect
public void onInvalidSessionDetected(HttpServletRequest request, HttpServletResponse response) throws IOException {
logger.debug("Starting new session (if required) and redirecting to '" + destinationUrl + "'");
if (createNewSession) {
request.getSession();
}
// some check hier ???
redirectStrategy.sendRedirect(request, response, destinationUrl);
}
There is parameter to don't invalidate session in logout config but what are the security consensuses of not invalidating it ? There was probably a reason what it is by default turn on.
.logout()
.invalidateHttpSession(false)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the logout flow using invalidSessionUrl("/login?sessionExpired") and inspect SessionManagerFilter, SimpleRedirectInvalidSessionStrategy, and the logout configuration around invalidateHttpSession(false). Determine the intended behavior when logout invalidates the session, then define and verify the resulting redirect behavior with regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100