• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

JPA 강의 - delete 구현시 에러 발생합니다.

23.04.09 19:54 작성 23.04.09 19:57 수정 조회수 379

0

안녕하세요.

강의 잘 듣고 있습니다.

현재 JPA 강의 - delete 부분을 수강 중입니다.

그런데, 컨트롤러에 아래 코드 추가 후 response에 403 에러 (foobidden) 이 출력됩니다.

security에 아래 코드처럼 설정해 줬는데도 에러가 나니, 이유를 모르겠습니다. ;;;;

@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
    http.authorizeRequests((auth) -> {
        auth.antMatchers("/jpa/users").permitAll();
        
    });
    return http.build();
}
@DeleteMapping("/users/{id}")
public void deleteUser(@PathVariable int id) {
    userRepository.deleteById(id);
}

답변 1

답변을 작성해보세요.

0

Jun Yu님의 프로필

Jun Yu

2023.04.09

ant matcher가 전혀 다르네요. antmatcher 뿐만 아니라 requestMatcher를 통해 ant matcher잡아주시고 권한 ant matcher를 잡아주세요. /users/* 와 같이 잡으시면 될것 같네요