这是我第一次将 Spring Security 与 Spring WebFlow 一起使用。我有两个用户(管理员;用户),每个用户都有她唯一的空间。
我的项目结构如下:
文件夹" compte "对于用户包含:
文件夹" compteAdmin " for Admin包含:
文件夹" 主要"包含:
main-flow.xml 的配置是:
<view-state id="authentification" view="authentification.xhtml" model="user">
<transition on="valider" to="authentifierUser" />
</view-state>
<action-state id="authentifierUser">
<evaluate
expression="userAuthenticationProviderService.processUserAuthentication(user)" />
<transition on="yes" to="finish" />
<transition on="no" to="authentification" />
</action-state>
<end-state id="finish" view="externalRedirect:compteAdmin" />
security-config.xml 的配置是:
<security:http auto-config="true" use-expressions="true">
<!-- Restrict URLs based on role -->
<security:intercept-url pattern="/app/main" access="permitAll"/>
<security:intercept-url pattern="/app/main/compteAdmin" access="hasRole('ROLE_ADMIN')" />
<security:intercept-url pattern="/app/main/compte" access="hasRole('ROLE_USER')" />
<security:form-login login-page="/app/main" default-target-url="/app/main"/>
<security:logout logout-url="/app/logout"
logout-success-url="/app/main" />
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:jdbc-user-service
data-source-ref="dataSource" />
</security:authentication-provider>
</security:authentication-manager>
<bean id="daoAuthenticationProvider"
class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<property name="userDetailsService" ref="userService" />
<property name="hideUserNotFoundExceptions" value="false" />
</bean>
<bean id="authenticationManager"
class="org.springframework.security.authentication.ProviderManager">
<constructor-arg>
<ref local="daoAuthenticationProvider" />
</constructor-arg>
</bean>
在这种情况下,只有管理员才能访问她的空间。那么如何配置 main-flow.xml 以便让用户也可以访问她的空间。 提前致谢。