Если внутри @Bean SecurityFilterChain defaultSecurityFilterChain построить цепочку http с контроллером .requestMatchers("/auth/**").permitAll(); с сопоставлением «/ auth» нельзя вызвать из-за 403, но если я использую requestMatchers("/**").permitAll(), я могу перейти к этому адресу. Почему это так?
@Bean
SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
http.cors().disable().csrf().disable()
.authorizeHttpRequests()
/*.requestMatchers("/myAccount").hasAuthority("VIEWACCOUNT")
.requestMatchers("/myBalance").hasAnyAuthority("VIEWACCOUNT","VIEWBALANCE")
.requestMatchers("/myLoans").hasAuthority("VIEWLOANS")
.requestMatchers("/myCards").hasAuthority("VIEWCARDS")*/
.requestMatchers("/auth/**").permitAll();
return http.build();
}
@RestController("/аутентификация") открытый класс LoginController {
@Autowired
private CustomerRepository customerRepository;
@Autowired
private PasswordEncoder passwordEncoder;
@GetMapping
public String showUserString(@RequestBody User user) {
return "Hello World!";
}`




Реализуйте SecurityConfiguration следующим образом:
@Bean
public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
http
// .csrf().disable not recommended in prod environment
.csrf().disable()
.authorizeHttpRequests((authz) -> authz
.requestMatchers("/auth/**").permitAll()
.anyRequest().authenticated()
);
return http.build();
}
Затем измените эту строку
@RestController("/auth")
к
@RestController
@RequestMapping("/auth")
и эта линия
@GetMapping
к
@RequestMapping(value = "/showUserString", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)