Устаревшие методы .csrf() и .requiresChannel() после миграции Spring Boot v3 ⇐ JAVA
-
Anonymous
Устаревшие методы .csrf() и .requiresChannel() после миграции Spring Boot v3
Я пытался перенести старый проект на новейшую версию Spring Boot, то есть 3.1.2, как мы говорим. Однако методы .csrf() и .requiresChannel() в приведенном ниже фрагменте кода больше не работают из-за устаревания.
Я не могу найти методы, которые их заменили. Можете ли вы помочь?
@Configuration @EnableWebSecurity общественный класс ApplicationSecurityConfig { частный окончательный ApplicationUserService applicationUserService; частный окончательный BCryptPasswordEncoder bCryptPasswordEncoder; общедоступное приложениеSecurityConfig( ПриложениеUserService приложениеUserService, BCryptPasswordEncoder bCryptPasswordEncoder) { this.applicationUserService = applicationUserService; this.bCryptPasswordEncoder = bCryptPasswordEncoder; } @Бин protected SecurityFilterChain filterChain(HttpSecurity http) выдает исключение { http .csrf().отключить() .requiresChannel() .antMatchers("/актуатор/**") .requiresInsecure() .и() .authorizeRequests() .antMatchers( "/api/v*/регистрация/**", "/регистр*", "/авторизоваться", "/актуатор/**").permitAll() .Любой запрос() .аутентифицированный() .и() .formLogin() .loginPage("/логин") .usernameParameter("электронная почта") .permitAll() .defaultSuccessUrl("/", true) .failureUrl("/ошибка входа") .и() .выйти() .logoutUrl("/выход") .clearAuthentication(истина) .invalidateHttpSession(истина) .deleteCookies("JSESSIONID", "Idea-2e8e7cee") .logoutSuccessUrl("/login"); вернуть http.build(); } @Бин общедоступный менеджер аутентификации AuthenticationManager( AuthenticationConfigurationauthenticationConfiguration) выдает исключение { вернуть аутентификациюConfiguration.getAuthenticationManager(); } @Бин общественный DaoAuthenticationProvider daoAuthenticationProvider () { Поставщик DaoAuthenticationProvider = новый DaoAuthenticationProvider(); поставщик.setPasswordEncoder(bCryptPasswordEncoder); поставщик.setUserDetailsService(applicationUserService); поставщик возврата; } }
Я пытался перенести старый проект на новейшую версию Spring Boot, то есть 3.1.2, как мы говорим. Однако методы .csrf() и .requiresChannel() в приведенном ниже фрагменте кода больше не работают из-за устаревания.
Я не могу найти методы, которые их заменили. Можете ли вы помочь?
@Configuration @EnableWebSecurity общественный класс ApplicationSecurityConfig { частный окончательный ApplicationUserService applicationUserService; частный окончательный BCryptPasswordEncoder bCryptPasswordEncoder; общедоступное приложениеSecurityConfig( ПриложениеUserService приложениеUserService, BCryptPasswordEncoder bCryptPasswordEncoder) { this.applicationUserService = applicationUserService; this.bCryptPasswordEncoder = bCryptPasswordEncoder; } @Бин protected SecurityFilterChain filterChain(HttpSecurity http) выдает исключение { http .csrf().отключить() .requiresChannel() .antMatchers("/актуатор/**") .requiresInsecure() .и() .authorizeRequests() .antMatchers( "/api/v*/регистрация/**", "/регистр*", "/авторизоваться", "/актуатор/**").permitAll() .Любой запрос() .аутентифицированный() .и() .formLogin() .loginPage("/логин") .usernameParameter("электронная почта") .permitAll() .defaultSuccessUrl("/", true) .failureUrl("/ошибка входа") .и() .выйти() .logoutUrl("/выход") .clearAuthentication(истина) .invalidateHttpSession(истина) .deleteCookies("JSESSIONID", "Idea-2e8e7cee") .logoutSuccessUrl("/login"); вернуть http.build(); } @Бин общедоступный менеджер аутентификации AuthenticationManager( AuthenticationConfigurationauthenticationConfiguration) выдает исключение { вернуть аутентификациюConfiguration.getAuthenticationManager(); } @Бин общественный DaoAuthenticationProvider daoAuthenticationProvider () { Поставщик DaoAuthenticationProvider = новый DaoAuthenticationProvider(); поставщик.setPasswordEncoder(bCryptPasswordEncoder); поставщик.setUserDetailsService(applicationUserService); поставщик возврата; } }
Мобильная версия