繁体   English   中英

Spring,CORS和j_spring_security_logout

[英]Spring, CORS, and j_spring_security_logout

我需要在Spring Security中使用CORS。 我已使用在app-beans.xml中配置的OncePerRequestFilter如下成功完成了登录和基本安全性工作:

<bean id="corsAwareAuthenticationFilter"class="org.broadinstitute.portal.servlet.CorsAwareAuthenticationFilter"/>
<security:http use-expressions="true">
  <security:custom-filter ref="corsAwareAuthenticationFilter" after="PRE_AUTH_FILTER"/>
...

我基本上遵循此问题中的方法: 使用Spring Security进行跨域资源共享

我在app-beans.xml中注销的配置很简单:

    <security:logout delete-cookies="JSESSIONID"/>

没有CORS,这可以正常工作。

我的问题是注销。 CORS正在停止访问j_spring_security_logout。 知道为什么在登录时调用我的OncePerRequestFilter而不在退出时调用它吗?

编辑添加:

感谢alain.janinm,我解决了这个问题。 我需要将过滤器设置为在LOGOUT_FILTER之前被调用。 以下配置添加解决了该问题:

    <security:custom-filter ref="corsAwareAuthenticationFilter" before="LOGOUT_FILTER"/>

请注意,使用position =“ LOGOUT_FILTER”不起作用,因为这会将我的过滤器放置在与Spring LOGOUT_FILTER相同的位置。 我的过滤器与LOGOUT_FILTER的功能不同-我所做的只是添加CORS标头。 因此,我实际上需要仍然调用Spring LOGOUT_FILTER。

感谢alain.janinm,我解决了这个问题。 我需要将过滤器设置为在LOGOUT_FILTER之前被调用。 以下配置添加解决了该问题:

<security:custom-filter ref="corsAwareAuthenticationFilter" before="LOGOUT_FILTER"/>

请注意,使用position =“ LOGOUT_FILTER”不起作用,因为这会将我的过滤器放置在与Spring LOGOUT_FILTER相同的位置。 我的过滤器与LOGOUT_FILTER的功能不同-我所做的只是添加CORS标头。 因此,我实际上需要仍然调用Spring LOGOUT_FILTER。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM