'apply(C)' is deprecated since version 6.2 and marked for removal

141 views Asked by At

we have migrated to Spring 3 now as i can see apply method of HttpSecurity is deprecated with warning and in java doc it's written to use with() method, so how can i Change my apply method to with method I tried to use with method but it takes two argument, one argument Configurer i am aware but second argument Customer i don't know, so passing null is correct ?enter image description here

@Bean
@Profile({"zip"})
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
    String csp = "default-src 'self'; img-src 'self'; script-src 'self'; style-src 'self'; object-src 'none'";
    http.authorizeHttpRequests(authorizationManagerRequestMatcherRegistry ->
                    authorizationManagerRequestMatcherRegistry.requestMatchers("/actuator/health", "/docs/**").
                            permitAll().anyRequest().authenticated()).
            apply(AadResourceServerHttpSecurityConfigurer.aadResourceServer());
    http.headers(httpSecurityHeadersConfigurer -> httpSecurityHeadersConfigurer.
            contentSecurityPolicy(contentSecurityPolicyConfig ->
                    contentSecurityPolicyConfig.policyDirectives(csp)));

    return http.build();
}
0

There are 0 answers