Fehler: Symbol nicht finden .AntMatcher ("/**")Java

Java-Forum
Anonymous
 Fehler: Symbol nicht finden .AntMatcher ("/**")

Post by Anonymous »

Ich habe meine Spring -Boot -Anwendung von Version 2.6.15 auf Version 3.1.12 aktualisiert. Es scheint jedoch, dass einige Methoden umbenannt wurden und ihre Positionen geändert werden. Zum Beispiel existiert Anmatcher () nicht mehr. Ich habe herausgefunden, dass es RequestMatchers () innerhalb von AuthorizeHttpRequests () gibt, aber dann hat Access () keine Zeichenfolge akzeptiert. Und ich weiß auch nicht, wo ich oAuth2Resourceserver () und jwt ().import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
@EnableWebSecurity
public class ResourceServerConfig {

@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.csrf(AbstractHttpConfigurer::disable)
.antMatcher("/**") // web.ignoring().requestMatchers("/**/actuator/health");
}

public static class WebSecurityAccess {

@Value("${om.test.app.client-id}")
private String omTestAppClientId;

public boolean hasAccess(Authentication authentication) {
return authentication.isAuthenticated() && authentication.getPrincipal() instanceof Jwt
&& omTestAppClientId.equals(((Jwt) authentication.getPrincipal()).getClaims().get("clientId"));
}
}

}
< /code>
Wie sollte ich dieses Problem mit AntMatcher () und Access () beheben? Oder gibt es gute Tutorials?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post