Я пытаюсь выполнить обновление до Spring Boot 3.0.0 и Spring Security 6.0.
Я обнаружил, что метод защиты запросовauthorizeRequests() устарел . А также удалены аннотации метода antMatchers() и @EnableGlobalMethodSecurity. Как я могу обновить конфигурацию безопасности?
Мой код:
Я пытаюсь выполнить обновление до Spring Boot 3.0.0 и Spring Security 6.0. Я обнаружил, что метод защиты запросовauthorizeRequests() устарел . А также удалены аннотации метода antMatchers() и @EnableGlobalMethodSecurity. Как я могу обновить конфигурацию безопасности? Мой код: [code]package org.sid.securityservice.config;
//@Bean public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { return authenticationConfiguration.getAuthenticationManager(); } @Bean public AuthenticationManager authenticationManager(UserDetailsService userDetailsService){ var authProvider = new DaoAuthenticationProvider(); authProvider.setPasswordEncoder(passwordEncoder); authProvider.setUserDetailsService(userDetailsService); return new ProviderManager(authProvider); }
@Bean public UserDetailsService inMemoryUserDetailsManager(){ return new InMemoryUserDetailsManager( User.withUsername("user1").password(passwordEncoder.encode("1234")).authorities("USER").build(), User.withUsername("user2").password(passwordEncoder.encode("1234")).authorities("USER").build(), User.withUsername("admin").password(passwordEncoder.encode("1234")).authorities("USER","ADMIN").build() ); } @Bean public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { return httpSecurity .csrf(csrf->csrf.disable()) .authorizeRequests(auth->auth.antMatchers("/token/**").permitAll()) .authorizeRequests(auth->auth.anyRequest().authenticated()) .sessionManagement(sess->sess.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt) .httpBasic(Customizer.withDefaults()) .build(); } @Bean JwtDecoder jwtDecoder(){ return NimbusJwtDecoder.withPublicKey(rsakeysConfig.publicKey()).build(); } @Bean JwtEncoder jwtEncoder(){ JWK jwk= new RSAKey.Builder(rsakeysConfig.publicKey()).privateKey(rsakeysConfig.privateKey()).build(); JWKSource jwkSource= new ImmutableJWKSet(new JWKSet(jwk)); return new NimbusJwtEncoder(jwkSource); }
} [/code] Вот что показывает мне IDE (зачеркнутоauthorizeRequests() и отсутствует antMatchers() < em>выделено красным): [img]https://i.sstatic.net/OBj6E.png[/img]
Я пытаюсь выполнить обновление до Spring Boot 3.0.0 и Spring Security 6.0.
Я обнаружил, что метод защиты запросовauthorizeRequests() устарел . А также удалены аннотации метода antMatchers() и @EnableGlobalMethodSecurity. Как я могу обновить...
Я пытаюсь обновить свой проект до версии Spring boot 3.3.2, а версия безопасности Spring — 6.3.1.
В коде класс JwtWebSecurityConfigurer используется для установки под полями.
JwtWebSecurityConfigurer
.forRS256(env.getRequiredProperty(...
Я работаю над архитектурой микросервисов, которая сочетает в себе сервлеты и реактивные приложения Spring Boot; они развернуты в кластере K8S, и каждый микросервис предоставляет конечные точки Spring Actuator для мониторинга работоспособности и...
Я обновил http-клиент Apache 5.3.x до 5.4.x.
Приведенный ниже код работает нормально
var sslContext = SSLContexts.custom()
.loadTrustMaterial(null, TrustAllStrategy.INSTANCE)
.build();
Я обновил http-клиент Apache 5.3.x до 5.4.x.
Приведенный ниже код работает нормально
var sslContext = SSLContexts.custom()
.loadTrustMaterial(null, TrustAllStrategy.INSTANCE)
.build();