我一直在嘗試爲多個登錄頁面實現解決方案。我目前有一個唯一的LoginController,並且它只是在有人請求/app_name/login.htm時檢索登錄jsp。我希望保持這種狀態,但還需要添加兩個位置:/app_name/customers/login.htm和/app_name/employees/login.htm,每個位置都有一個單獨的控制器CustomerLoginController和EmployeeLoginController。認證之前訪問控制器Spring Security
所以我的想法是員工通過他們的URL和客戶使用他們的訪問權限,但如果有人試圖訪問舊的login.htm控制器重定向到他們各自的登錄使用存儲的cookie和客戶作爲默認。
對我來說這聽起來不錯,但是當我嘗試訪問/app_name/customers/login.htm或/app_name/employees/login.htm時,它只是在我沒有通過身份驗證時將我重定向到login.htm。
我真的不知道爲什麼它不解決它們。任何意見,建議,指南,教程,示例代碼或鏈接都將有所幫助。
我的工作有這個CONFIGS
的web.xml
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
的servlet-config.xml中
<!-- Controllers Mapping -->
<context:component-scan base-package="com.company.project.controllers">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
安全的context.xml項目
<sec:http auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint" access-denied-page="/warning/accessDenied.htm" >
<sec:intercept-url pattern="/employees/login.htm" filters="none" />
<sec:intercept-url pattern="/customers/login.htm" filters="none" />
<sec:intercept-url pattern="/login**" filters="none" />
</sec:http>
<bean id="authenticationProcessingFilterEntryPoint" class="org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint">
<property name="loginFormUrl" value="/login.htm" />
<property name="forceHttps" value="false" />
</bean>
<bean id="authenticationProcessingFilter" class="org.springframework.security.ui.webapp.AuthenticationProcessingFilter">
<property name="authenticationFailureUrl" value="/login.htm?login_error=1"/>
<property name="defaultTargetUrl" value="/home.htm"/>
<property name="alwaysUseDefaultTargetUrl" value="true"/>
<property name="filterProcessesUrl" value="/j_spring_security_check"/>
</bean>
PD:使用Spring 2.5.4和Spring 2.0.4安全-_-我知道,但是是一個相當規模的項目,它已經生產了一段時間
有人嗎?我還沒有確定 – Gustavo