spring-projects / spring-projects/spring-security

SEC-2609: Add an InvalidSessionStrategy implementation for JSF

Open
#2,825 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: web type: enhancement type: jira
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Mauro Molinari (Migrated from SEC-2609) said:

The only InvalidSessionStrategy implementation provided is SimpleRedirectInvalidSessionStrategy which simply does a redirect to the configured invalid session URL.
However in a JSF environments there's a common problem for which people are usually creating various kind of workarounds: when a JSF component in a page protected by Spring Security makes an Ajax request and the server session is invalid (i.e. expired), the SimpleRedirectInvalidSessionStrategy sends a redirect response to the client-side code that generated the request. However, this plain redirect is not handled correctly by the JSF JavaScript code and no actual redirection is performed. The actual result is that the user clicks on components in the page and nothing happens.

The correct way to handle these kind of requests is to reply with a proper Ajax response with the redirect URL, as described in the JSF specification:

<?xml version="1.0" encoding="UTF-8"?>
<partial-response>
  <redirect url="${redirectUrl}" />
</partial-response>

There are a couple of independent implementations around that do this, however having a suitable InvalidSessionStrategy built in in Spring Security would be very useful and would save a lot of headaches to many people.

As a starting point, two examples of a proper implementation are:

Please note that improving the <security:session-management> namespace tag to be able to specify a proper InvalidSessionStrategy would also help a lot in these scenarios ;-)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing InvalidSessionStrategy and the existing SimpleRedirectInvalidSessionStrategy implementation. Check how session-management handles invalid sessions and how the strategy can produce the JSF partial-response redirect format; done means JSF Ajax requests receive that response and the strategy can be used through the session-management configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.