【发布时间】:2017-03-24 21:29:55
【问题描述】:
我在一个 JEE 项目上工作,使用 Spring Boot 框架。 对于身份验证,我使用 Spring Security,并在模板中指定了页面。
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/login").permitAll()
.antMatchers("/token", "/index", "/index.html", "/main", "/main.html", "/main2", "/main2.html", "/recent1", "/recent1.html", "/recent2", "/recent2.html").hasRole("USER");
http
.csrf()
.disable()
.formLogin()
.loginPage("/login")
.failureUrl("/login?error=true")
.defaultSuccessUrl("/index");
http
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login");
}
问题是,当我运行应用程序并使用大写字母(例如:localhost:8080/INDEX.HTML 或添加两个字母 localhost/index.httml)编写 URL 时,页面确实会出现而没有经过身份验证。
【问题讨论】:
-
你可以用这个解决方案 .antMatchers("/login","/LOGIN")。另一个像这样。
标签: spring url spring-boot spring-security