SpringSecurity 3

SpringSecurity를 사용할 때 일관적인 Exception 처리를 위해

1. Spring Security Filter chain의 구조 따라서 @Controller나 @Service에서 GlobalCustomException처리하면 (@ControllerAdvice, @ExceptionHandler) 해당 메소드로 넘어가지만, Filter에서 똑같이 Exception 터트려도 GlobalCustomException로 넘어가지 않는다. 해결방법은 Filter영역에서 Exception 처리는 아래와 같이. @Component // 유효한 자격증명을 제공하지 않고 접근하려 할 때 401Unauthorized 에러를 리턴 public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint { @Override p..

Springboot Swagger- SpringSecurity 연결 설정

1. SpringSecurity- Swagger2 설정 연결 https://it-recording.tistory.com/64 [Spring] Spring Security + Swagger2 연결 Spring을 사용한 프로젝트를 할 때 API를 하나하나 적는 것은 많은 시간과 노력을 요구한다. 이에 자동화 된 API 툴을 제공하는데 그 중 Swagger를 연결하는 방법을 알아보겠다. (+마주했던 오류와 함 it-recording.tistory.com 2. SpringBoot - Swagger 설정 https://velog.io/@borab/Spring-boot-Swagger-%EC%84%A4%EC%A0%95-gradle Spring boot Swagger 설정 (gradle) 🐏 ❗ 스프링 부트 swagg..

JSP 태그 라이브러리

스프링 MVC는 , 등 HTML 폼과 커맨드 객체를 연동하기 위한 JSP 태그 라이브러리를 제공한다. 1. -> id대신 modelAttribute 지정하면 커맨드 객체 이름 설정할 수 있다. 예를 들어 modelAttibute = "loginCommand"라는 커맨드 객체와 연결해주고 여기서 이메일, 비밀번호 꺼내와서 authInfo라는 커맨드 객체에 다시 값을 넣어준 뒤 세션을 만드는 컨트롤러를 보자. @PostMapping public String submit( LoginCommand loginCommand, Errors errors, HttpSession session, HttpServletResponse response) { new LoginCommandValidator().validate(lo..