[英]Spring Security Form Login Not Identified
我不得不將應用程序從Spring Security 2遷移到3.2,我完全迷路了,我從未使用過Spring Security :(
我在spring-security.xml上修改了一些配置:
<http pattern="/ordreminderform.jsp" security="none" />
<http pattern="/passwordreminder.jsp" security="none" />
<http pattern="/getUser.jsp" security="none" />
<http pattern="/csra2.css" security="none" />
<http auto-config="true" access-denied-page="/accessDenied.jsp">
<intercept-url pattern="/login.jsp" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<intercept-url pattern="/index.jsp"
access="ROLE_USER,ROLE_ADMIN,ROLE_B1,ROLE_B2,ROLE_B3" />
<intercept-url pattern="/Users.do" access="ROLE_ADMIN" />
<intercept-url pattern="/Project.do"
access="ROLE_USER,ROLE_ADMIN,ROLE_B1,ROLE_B2,ROLE_B3" />
<intercept-url pattern="/Csra.do"
access="ROLE_USER,ROLE_ADMIN,ROLE_B1,ROLE_B2,ROLE_B3" />
<intercept-url pattern="/About.do"
access="ROLE_USER,ROLE_ADMIN,ROLE_B1,ROLE_B2,ROLE_B3" />
<session-management session-fixation-protection="newSession">
<concurrency-control max-sessions="1"
error-if-maximum-exceeded="false" />
</session-management>
<form-login login-page="/login.jsp"
authentication-failure-url="/login.jsp?login_error=true"
username-parameter="username" password-parameter="password"
default-target-url="/index.jsp" always-use-default-target="true" />
</http>
<http>
<intercept-url pattern="/usuarios/**"
access="ROLE_USER,ROLE_ADMIN,ROLE_B1,ROLE_B2,ROLE_B3" />
<intercept-url pattern="/admin/**" access="ROLE_ADMIN" />
<!--<intercept-url pattern="/**" -->
<!-- access="ROLE_USER,ROLE_ADMIN,ROLE_B1,ROLE_B2,ROLE_B3" /> -->
</http>
<http pattern="/imagens/**" security="none" />
<http pattern="/js/**" security="none" />
<http pattern="/css/**" security="none" />
<http pattern="/fonts/**" security="none" />
<http>
<intercept-url pattern="/**"
access="ROLE_USER,ROLE_ADMIN,ROLE_B1,ROLE_B2,ROLE_B3" />
</http>
當我嘗試部署它時,它拋出:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem:No AuthenticationEntryPoint could be established. Please make sure you have a login mechanism configured through the namespace (such as form-login) or specify a custom AuthenticationEntryPoint with the 'entry-point-ref' attribute |Offending resource: class path resource [spring-security-config.xml]
很奇怪,因為我確實有一個表單登錄! .xml是一團糟,我正在嘗試使其更好。 我正在使用Spring * 3.1.0和Spring Security 3.2.3
謝謝!
您有三個<http>
塊,它們正在創建三個單獨的安全過濾器鏈(即,您未使用security='none'
繞過特定URL的安全性)。
這些都不具有“模式”屬性,這意味着它們都將被配置為處理所有請求,這沒有任何意義。 這些塊的第二個和第三個塊未配置身份驗證方法。 這些中的任何一個都會導致您得到錯誤。 form-login
僅適用於包含它的http
元素。
只需使用一個<http>
元素即可包含您要應用的所有intercept-url
配置,除非您特別希望針對不同的URL模式具有不同的安全配置。
還要看看這個問答 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.