Java Spring安全注销
我遇到了Spring Security的麻烦。我可以登录,但不能注销(至少不像预期的那样) 登录后,我将被重定向到/secure/home.xhtmlJava Spring安全注销,java,spring,security,logout,Java,Spring,Security,Logout,我遇到了Spring Security的麻烦。我可以登录,但不能注销(至少不像预期的那样) 登录后,我将被重定向到/secure/home.xhtml 使用spring url taglig或jstl url taglib写下您的url。有助于了解spring安全配置您已在启用CRLF保护 您可以通过将以下内容添加到表单中来尝试支持CRLF: <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.
使用spring url taglig或jstl url taglib写下您的url。有助于了解spring安全配置您已在启用CRLF保护 您可以通过将以下内容添加到表单中来尝试支持CRLF:
<input type="hidden"
name="${_csrf.parameterName}"
value="${_csrf.token}"/>
如果这不起作用,您可以删除CSRF-尽管不建议这样做
更多信息:
<security:http use-expressions="true" >
<security:intercept-url pattern="/secure/**" access="hasAnyRole('USER','ADMIN')" />
<security:intercept-url pattern="/admin/**" access="hasRole('ADMIN')" />
<!--<security:access-denied-handler error-page="/404.xhtml" />-->
<security:form-login
login-page="/index.xhtml"
default-target-url="/secure/home.xhtml"
authentication-failure-url="/index.xhtml?error"
username-parameter="username"
password-parameter="password" />
<security:logout logout-url="/logout" logout-success-url="/index.xhtml?logout" invalidate-session="true" delete-cookies="JSESSIONID" />
<security:csrf />
</security:http>
<a href="#{request.contextPath}/logout">logout</a>
<h:outputLink value="#{request.contextPath}/logout">Logout</h:outputLink>
<form method="POST" id="loginForm" action="#{request.contextPath}/logout" class="form-signin" autocomplete="off">
<button type="submit" tabindex="3" class="btn btn-success btn-block">#{bundle["logout.action"]}</button>
<input type="hidden" name="#{_csrf.parameterName}" value="#{_csrf.token}" />
</form>
HTTP Status 403 - Expected CSRF token not found. Has your session expired?
type Status report
messageExpected CSRF token not found. Has your session expired?
descriptionAccess to the specified resource has been forbidden.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>messages</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/application-context.xml
classpath:/application-security.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- Predefined pages -->
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<!-- <error-page>
<error-code>403</error-code>
<location>/error.xhtml</location>
</error-page>-->
<error-page>
<error-code>404</error-code>
<location>/404.xhtml</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.xhtml</location>
</error-page>
<error-page>
<exception-type>javax.faces.application.ServletException</exception-type>
<location>/index.xhtml</location>
</error-page>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/error.xhtml</location>
</error-page>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<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>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/logout</url-pattern>
</filter-mapping>
<!-- MIME TYPES -->
<mime-mapping>
<extension>css</extension>
<mime-type>text/css</mime-type>
</mime-mapping>
<mime-mapping>
<extension>eot</extension>
<mime-type>application/x-font-eot</mime-type>
</mime-mapping>
<mime-mapping>
<extension>js</extension>
<mime-type>text/javascript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>latex</extension>
<mime-type>application/x-latex</mime-type>
</mime-mapping>
<mime-mapping>
<extension>otf</extension>
<mime-type>application/x-font-opentype</mime-type>
</mime-mapping>
<mime-mapping>
<extension>roff</extension>
<mime-type>application/x-troff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>svg</extension>
<mime-type>application/svg+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ttf</extension>
<mime-type>application/x-font-ttf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>woff</extension>
<mime-type>application/x-font-woff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>woff2</extension>
<mime-type>application/x-font-woff2</mime-type>
</mime-mapping>
</web-app>
<input type="hidden"
name="${_csrf.parameterName}"
value="${_csrf.token}"/>