简体   繁体   English

Spring Security Spring-boot-starter-web从1.2.5迁移到1.3.2.RELEASE

[英]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.

相关问题 在没有 spring-boot-starter-web 的情况下配置 Spring Security AuthenticationManager - Configure Spring Security AuthenticationManager without spring-boot-starter-web Spring 引导:托管版本为 1.3.2.RELEASE 工件在 org.springframework.boot:spring-boot-dependencies:1.3.2.RELEASE 中管理 - Spring Boot: The managed version is 1.3.2.RELEASE The artifact is managed in org.springframework.boot:spring-boot-dependencies:1.3.2.RELEASE 使用spring-boot-starter-web的Spring Boot无法在Maven中编译 - Spring Boot with spring-boot-starter-web fails to compile in maven 如何在不继承spring-boot-starter-web的情况下在Spring Boot中获取ObjectMapper实例? - How can I get an ObjectMapper instance in Spring Boot without inheriting from spring-boot-starter-web? spring-boot-starter-web @Autowired无效 - spring-boot-starter-web @Autowired isn't working 使用 spring-boot-starter-web “找不到可接受的表示” - "Could not find acceptable representation" using spring-boot-starter-web @CrossOrigin 不适用于 spring-boot-starter-web 2.5.2 - @CrossOrigin not working for spring-boot-starter-web 2.5.2 如何限制 spring-boot-starter-web 中的完整有效负载大小? - How to limit full payload size in spring-boot-starter-web? 结合 ObjectDB 使用 Spring-Boot-Starter-Web - Using Spring-Boot-Starter-Web in combination with ObjectDB spring initializr:spring-boot-starter vs spring-boot-starter-web - spring initializr: spring-boot-starter vs spring-boot-starter-web
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM