0

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.

Community
  • 1
  • 1
olivmir
  • 692
  • 10
  • 29

1 Answers1

0

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"%>
Essex Boy
  • 7,565
  • 2
  • 21
  • 24
  • I've tried this out, but the variable is not accessible from the login page. Maybe it's because I use my own custom login page - that means: in my setup the configured `HttpSecurity.loginPage` invokes a Spring MVC LoginController class, which then is displaying the Login-Page. What is your setup? – olivmir Jan 04 '17 at 09:46