小编Ben*_*ner的帖子

Spring Security改变了请求URI

我将Spring Security集成到现有的Spring Boot项目中(版本:1.5.3.RELEASE).

在集成之前,我们通过扩展HandlerInterceptorAdapater的preHandle方法通过getRequestURI从请求中获取重定向信息.

请求URI正确指向其路径(例如:/ admin/login).

集成后,请求URI指向jsp的完整路径.

此外,我们已经向ConfigurableApplicationContext注册了一个ContextUtil类,以进行进一步的URI检查.在这个类中,我们获取这样的请求:

public HttpServletRequest getCurrentRequest()
{
    final ServletRequestAttributes servletRequestAttributes = 
    (ServletRequestAttributes) 
    RequestContextHolder.currentRequestAttributes();
    return servletRequestAttributes.getRequest();
}
Run Code Online (Sandbox Code Playgroud)

但URI也是其"物理路径"下的 /WEB-INF/

例如:GET请求指向/WEB-INF/pages/admin/admin_login.jsp:

我的WebSecurityConfig班级是:

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter
{
    @Override
    protected void configure(HttpSecurity http) throws Exception
    {
        //jeden Aufruf akzeptieren. Authorisierung und 
    Authentifizierung von Spring Security wird nicht genutzt
    http.authorizeRequests().antMatchers("/").permitAll();
}

    @Override
    public void configure(WebSecurity web) throws Exception
    {
    web.ignoring().antMatchers("/resources/**", "/css/**", "/js/**", 
    "/img/**", "resources/*", "/WEB-INF/**").and().debug(true);
    }
}
Run Code Online (Sandbox Code Playgroud)

相关applicationContext.xml部分:

<mvc:default-servlet-handler/>
<mvc:annotation-driven/> …
Run Code Online (Sandbox Code Playgroud)

jsp uri spring-security

7
推荐指数
1
解决办法
346
查看次数

标签 统计

jsp ×1

spring-security ×1

uri ×1