Код: Выделить всё
@RestController
@RequestMapping("/api/our")
@PreAuthorize(value = "hasRole('ROLE_USER')")
@Api(value="our", produces="Our data")
public class OurController {
Без надлежащего управления доступом метод findAll() в OurService.java может выполнить оператор SQL в строке 36, который содержит контролируемый злоумышленником первичный ключ, тем самым позволяя злоумышленнику получить доступ к неавторизованным записям.
Поэтому я попытался добавить аннотацию @PreAuthorize к нашему классу обслуживания следующим образом:
Код: Выделить всё
@Service
@PreAuthorize(value = "hasRole('ROLE_USER')")
public class OurService {
private final OurRepository ourRepository;
public OurService(OurRepository ourRepository) {
this.ourRepository = ourRepository;
}
public Page findAll(Pageable pageable) {
return ourRepository.findAll(pageable);
}
public Page findAll(Specification specification, Pageable pageable) {
return ourRepository.findAll(specification, pageable);
}
}
Вызвано: org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: объект аутентификации не найден в SecurityContext
Подробнее здесь: https://stackoverflow.com/questions/587 ... ct-was-not