[英]Spring Security Spring-boot-starter-web migrate from 1.2.5 to 1.3.2.RELEASE
I use spring security for my application. 我在应用程序中使用spring安全性。 Up to now I used
到现在为止
org.springframework.boot spring-boot-starter-web 1.2.5 RELEASE
org.springframework.boot spring-boot-starter-web 1.2.5发布
now I want to use 现在我要使用
org.springframework.boot spring-boot-starter-web 1.3.2 RELEASE
org.springframework.boot spring-boot-starter-web 1.3.2发布
My SecurityConfiguration.java looks like this: 我的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();
}
}
One of my rest services looks like this: 我的一项休息服务如下所示:
@RequestMapping("/test")
@PreAuthorize("hasRole('ADMIN')")
public List<Tests> getTests() {
return ...
}
The old version works. 旧版本有效。 With the newer version I get a 403 forbidden if I try to call the rest service.
在较新的版本中,如果我尝试致电其余服务,则会得到403禁止。 Does anyone know how to get this to work again?
有谁知道如何使它重新工作?
When upgrading from 1.2.5 to 1.3.2 you also update spring-security from 3.X to 4.X. 从1.2.5升级到1.3.2时,还将弹簧安全性从3.X升级到4.X。
You can override spring security dependency in your own project to keep previous version of spring-security. 您可以在自己的项目中覆盖spring安全性依赖关系,以保留spring-security的早期版本。 (I don't think that it is recommended, at least you will see a warning at startup)
(我不建议您这样做,至少您会在启动时看到警告)
Alternatively, you can read carefully the documentation bellow and perform all necessary configuration update when moving from spring-security 3.X to 4.X 另外,当您从spring-security 3.X升级到4.X时,您可以仔细阅读以下文档并执行所有必要的配置更新。
Migration from spring security 3 to 4 (xml config) 从Spring Security 3迁移到4(xml配置)
Migration from spring security 3 to 4 (java config) 从Spring Security 3迁移到4(java config)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.