Modified security config to allow a JSF POST request to be intercepted and continued after successful login.
This commit is contained in:
@@ -9,16 +9,32 @@
|
||||
http://www.springframework.org/schema/security/spring-security-2.0.xsd">
|
||||
|
||||
<!-- Configure Spring Security -->
|
||||
<security:http auto-config="true">
|
||||
<security:http auto-config="true" >
|
||||
|
||||
<!-- Restrict URLs based on role -->
|
||||
<security:intercept-url pattern="/spring/login*" access="ROLE_ANONYMOUS" />
|
||||
<security:intercept-url pattern="/spring/logoutSuccess*" access="ROLE_ANONYMOUS" />
|
||||
<security:intercept-url pattern="/spring/logout*" access="ROLE_USER" />
|
||||
|
||||
<!-- Override default login and logout pages -->
|
||||
<security:form-login login-page="/spring/login" login-processing-url="/spring/loginProcess" default-target-url="/spring/main" authentication-failure-url="/spring/login?login_error=1" />
|
||||
<security:form-login login-page="/spring/login" />
|
||||
<security:logout logout-url="/spring/logout" logout-success-url="/spring/logoutSuccess" />
|
||||
</security:http>
|
||||
|
||||
<security:authentication-manager alias="authenticationManager"/>
|
||||
|
||||
<bean id="authFilter" class="org.springframework.security.ui.webapp.AuthenticationProcessingFilter">
|
||||
<property name="authenticationManager" ref="authenticationManager"/>
|
||||
<property name="authenticationFailureUrl" value="/spring/login?login_error=1"/>
|
||||
<property name="defaultTargetUrl" value="/spring/main"/>
|
||||
<property name="filterProcessesUrl" value="/spring/loginProcess"/>
|
||||
<property name="targetUrlResolver">
|
||||
<bean class="org.springframework.security.ui.TargetUrlResolverImpl">
|
||||
<property name="justUseSavedRequestOnGet" value="false"/>
|
||||
</bean>
|
||||
</property>
|
||||
<security:custom-filter position="AUTHENTICATION_PROCESSING_FILTER"/>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
Define local authentication provider, a real app would use an external provider (JDBC, LDAP, CAS, etc)
|
||||
|
||||
@@ -10,52 +10,47 @@
|
||||
|
||||
<div class="section">
|
||||
<h2>View Hotel</h2>
|
||||
<!-- Use of a plain form element instead of the h:form component is a temporary workaround as spring-security 2.0-M2 is not forwarding to the correct URL when using a post -->
|
||||
<form id="hotel" method="get">
|
||||
<input name="execution" type="hidden" value="${flowExecutionContext.key}"/>
|
||||
<fieldset>
|
||||
<div class="field">
|
||||
<div class="label">Name:</div>
|
||||
<div class="output">#{hotel.name}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Address:</div>
|
||||
<div class="output">#{hotel.address}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">City:</div>
|
||||
<div class="output">#{hotel.city}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">State:</div>
|
||||
<div class="output">#{hotel.state}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Zip:</div>
|
||||
<div class="output">#{hotel.zip}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Country:</div>
|
||||
<div class="output">#{hotel.country}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Nightly rate:</div>
|
||||
<div class="output">
|
||||
<h:outputText value="#{hotel.price}">
|
||||
<f:convertNumber type="currency" currencySymbol="$"/>
|
||||
</h:outputText>
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttonGroup">
|
||||
<sf:commandButton id="book" ajaxEnabled="false" action="book" value="Book Hotel"/> 
|
||||
<sf:commandButton id="cancel" ajaxEnabled="false" action="cancel" value="Back to Search"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
<h:form id="hotel">
|
||||
<fieldset>
|
||||
<div class="field">
|
||||
<div class="label">Name:</div>
|
||||
<div class="output">#{hotel.name}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Address:</div>
|
||||
<div class="output">#{hotel.address}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">City:</div>
|
||||
<div class="output">#{hotel.city}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">State:</div>
|
||||
<div class="output">#{hotel.state}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Zip:</div>
|
||||
<div class="output">#{hotel.zip}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Country:</div>
|
||||
<div class="output">#{hotel.country}</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Nightly rate:</div>
|
||||
<div class="output">
|
||||
<h:outputText value="#{hotel.price}">
|
||||
<f:convertNumber type="currency" currencySymbol="$"/>
|
||||
</h:outputText>
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttonGroup">
|
||||
<sf:commandButton id="book" ajaxEnabled="false" action="book" value="Book Hotel"/> 
|
||||
<sf:commandButton id="cancel" ajaxEnabled="false" action="cancel" value="Back to Search"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</h:form>
|
||||
</div>
|
||||
|
||||
<!--Only used to enable view state saving with Facelets due to spring-security workaround above -->
|
||||
<h:form id="hotel_stateSaving"></h:form>
|
||||
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
Reference in New Issue
Block a user