我有这个春季安全配置:
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/home.jsp" access="permitAll" />
<intercept-url pattern="/loginFailed" access="permitAll" />
<intercept-url pattern="/logOut" access="permitAll" />
<intercept-url pattern="/*" access="isAuthenticated()" />
<form-login login-page="/home.jsp" default-target-url="/index"
authentication-failure-url="/loginFailed" />
<logout logout-success-url="/logOut"/>
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="N_a" password="12" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>如果输入url,则需要access="isAuthenticated(),然后重定向到home.jsp。我想看到403个错误。怎么改呢?
发布于 2013-10-08 13:01:06
您正在使用基于表单的登录,因此,如果未进行身份验证,您将被提示使用登录页。这就是您所配置的,默认情况下,这就是Security的工作方式。
如果您想要覆盖这一点,您需要显式地配置一个AuthenticationEntryPoint,使之精确地成为Http403ForbiddenEntryPoint。这基本上总是给一个403,如果某人没有身份验证或没有访问权。这将禁用使用登录表单提示用户更改登录的功能。
<beans:bean id="entryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint" />
<http auto-config="true" use-expressions="true" entry-point-ref="entryPoint">
<!-- Your other elements here -->
</http>发布于 2013-10-08 13:16:34
在access-denied-handler 标签中使用标签。
http://www.mkyong.com/spring-security/customize-http-403-access-denied-page-in-spring-security/
或者使用access-denied-page属性。
<http auto-config="true" access-denied-page="/403"></http>https://stackoverflow.com/questions/19247894
复制相似问题