I have a server application:
@RestController
@SpringBootApplication
public class ServerApplication {
    
    @GetMapping("/data")
    public ResponseEntity<String> getData() {
        return ResponseEntity.ok("Some Data.");
    }
    public static void main(String[] args) {
        SpringApplication.run(ServerApplication.class, args);
    }
}
and a client application:
@RestController
@SpringBootApplication
public class ClientApplication {
    
    RestTemplate restTemplate = new RestTemplate();
    
    @GetMapping("/test")
    public ResponseEntity<String> test(){
        ResponseEntity<String> response = restTemplate.getForEntity("http://localhost:8023/data", String.class);
        return ResponseEntity.ok("Received: " + response.getBody());
    }
    public static void main(String[] args) {
        SpringApplication.run(ClientApplication.class, args);
    }
}
both have the exact same security config (Spring security enabled):
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
            .antMatchers("/**")
            .permitAll();
    }
}
I expected this restTemplate call to fail, since i didnt activate CORS with @CrossOrigin or any other method. But this works perfectly fine. When i search for similar problems, i only ever find questions about why a enpoint CANT be reached, and not about why it CAN be reached.
Both applications share the same dependencies:
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
 
    