【发布时间】:2016-06-03 21:25:40
【问题描述】:
我在我的应用程序中使用 Spring Security。到现在为止我用过
org.springframework.boot spring-boot-starter-web 1.2.5 发布
现在我想使用
org.springframework.boot spring-boot-starter-web 1.3.2 发布
我的 SecurityConfiguration.java 如下所示:
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private UserDetailsService userService;
@Autowired
public void configureAuth(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userService).passwordEncoder(new BCryptPasswordEncoder());
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated().and().formLogin().loginPage("/login.html")
.failureUrl("/login.html?error").defaultSuccessUrl("/index", true).permitAll().and().logout()
.logoutSuccessUrl("/logout.html").permitAll().and().csrf().disable();
}
}
我的一项休息服务如下所示:
@RequestMapping("/test")
@PreAuthorize("hasRole('ADMIN')")
public List<Tests> getTests() {
return ...
}
旧版本有效。使用较新的版本,如果我尝试调用其余服务,则会收到 403 禁止。有谁知道如何让它再次工作?
【问题讨论】:
标签: spring spring-mvc spring-security spring-boot