Spring Security for Web Flow: How to access flow scoped variables in the login page

287 views Asked by At

When I use Spring Security for Spring Web Flow - how can I access flow scoped variables in the login page? The situation:
A view state in the web flow is secured by a <secured/> tag. When an unauthorized user enters this state, the filter chain calls the login page. But this login page is outside the flow. In the Spring MVC controller of this login page I've tried to access the flow variable like in this answer. But I get null for requestContext.

1

There are 1 answers

1
Essex Boy On

There should be no problem with using flow scoped variables on unsecured pages. I have the following which works ok:

<flow xmlns="http://www.springframework.org/schema/webflow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/webflow
        http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">

    <view-state id="start" model="userForm" view="user/login">
        <on-entry>
            <set name="flowScope.titleCode" value="'login'" />
            <set name="flowScope.login_error" value="requestParameters.login_error" />
            <set name="flowScope.showRecaptcha" value="recaptchaService.showRecaptcha()" />
        </on-entry>
    </view-state>

Then my login.jsp looks like:

<h2>
    <spring:message code="title_${titleCode}" />
</h2>

The relevant tag header for the jsp is:

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>