@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/my")
public class MemberApiController {
private final MemberService memberService;
@PatchMapping("/hospital")
@ResponseStatus(HttpStatus.OK)
public String appendFavorites(
@AuthenticationPrincipal UserDetails principal,
@RequestParam("hospitalSeq") Long hospitalSeq
) {
log.info("=========================={}===========================", hospitalSeq);
log.info("=========================={}===========================", principal.getUsername());
memberService.changeFavoriteStatus(hospitalSeq, principal.getUsername());
return "Favorites have been successfully changed";
}
}
해당 컨트롤러에서만 AuthenticationPrincipal이 담기지 않아 한참을 뻘짓했는데
알고보니 api 개발 단계에서 편의성을 위해 스프링 시큐리티에 api를 제외하는 설정값을 줬었다.
// 시큐리티 비활성화
@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return (web) -> web.ignoring().
requestMatchers(new AntPathRequestMatcher("/h2-console/**"))
.requestMatchers(new AntPathRequestMatcher("/img/**"))
.requestMatchers(new AntPathRequestMatcher("/css/**"))
.requestMatchers(new AntPathRequestMatcher("/js/**"))
.requestMatchers(new AntPathRequestMatcher("/img/**"))
.requestMatchers(new AntPathRequestMatcher("/lib/**"))
// 개발 단계에서 편의성을 위해 api를 AntPathRequestMatcher에 추가했습니다.
.requestMatchers(new AntPathRequestMatcher("/api/**"));
}
맨 밑줄을 삭제하고 다시 조회하니 멀쩡히 잘 돌아간다
정말 바보같은 실수를 했네
'코딩딩 > Error' 카테고리의 다른 글
IntelliJ Testcode에서 lombok 안먹힐때 (0) | 2024.08.16 |
---|---|
옵시디언 vim 모드 사용시 줄 바꿈 문제 (1) | 2024.05.21 |
Thymeleaf 사용시 redirect가 동작하지 않는 오류 (1) | 2024.01.10 |
Spring Data JPA 사용시 Repository BeanCreationException (0) | 2024.01.09 |
파이썬 셀레니움 웹 스크레핑 시 hidden에 숨겨져있는 src 경로 가져오기 (3) | 2024.01.08 |