ti.*_*002 13 jsf redirect login spring-security
我有一个带有spring-security和PrimeFaces的项目,当我执行我的项目时,我收到了一个错误.
此网址始终显示 /javax.faces.resource/primefaces.js.xhtml?ln=primefaces&v=5.1
当我覆盖此方法时会发生这种情况:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
http.authorizeRequests()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login.xhtml")
.permitAll();
}
Run Code Online (Sandbox Code Playgroud)
并把我自己的登录页面.但是我的web.xml调用home.xhtml页面
<welcome-file-list>
<welcome-file>home.xhtml</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud)
这就是它显示是这样:

Bal*_*usC 15
默认情况下,登录将重定向到当前HTTP会话的上次请求的受限资源.显然你(不知不觉)也将JSF生成的HTML页面的JS/CSS /图像资源作为受限资源.当登录页面本身完全引用该JavaScript文件时,它将被记住为最后请求的受限资源,然后Spring Security会在成功登录后盲目地重定向到该文件.
您需要告诉Spring Security将它们从受限制的资源中排除.一种方法是将以下行添加到Spring Security XML配置文件中.
<intercept-url pattern="/javax.faces.resource/**" filters="none"/>
Run Code Online (Sandbox Code Playgroud)
另一种方法是覆盖SecurityConfig#configure(WebSecurity).
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/javax.faces.resource/**");
}
Run Code Online (Sandbox Code Playgroud)
这也应该立即解决登录页面本身上所有破碎的CSS/JS /图像(在加载登录页面时通过检查浏览器的内置HTTP流量监视器和/或JS控制台应该注意到这一点).
| 归档时间: |
|
| 查看次数: |
2536 次 |
| 最近记录: |