![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/nu4tC/btrQZgLPJxP/M8VQgH8IvpgwSyLW3rYXOk/img.png)
https://sh970901.tistory.com/108 를 참고하여 REST API를 개발하기 위한 RsData를 생성하였다. Member 컨트롤러를 생성하여 로그인 요청에 대한 처리를 작성해보자. @PostMapping("/login") public ResponseEntity login(@Valid @RequestBody LoginDto loginDto) { Member member = memberService.findByUsername(loginDto.getUsername()).orElse(null); if (member == null) { return Util.spring.responseEntityOf(RsData.of("F-2", "일치하는 회원이 존재하지 않습니다.")); } if (pass..
1. SecurityConfig를 작성하자. JwtAuthorizationFilter 라는 필터를 생성하여 스프링 시큐리티 내부에 여러 인증 필터 중 만만한 UsernamePasswordAuthenticationFilter 앞에 추가하였다. @Bean public SecurityFilterChain apiFilterChain(HttpSecurity http) throws Exception { http .antMatcher("/api/**") .exceptionHandling(exceptionHandling -> exceptionHandling .authenticationEntryPoint(authenticationEntryPoint) ) .httpBasic().disable() .csrf().disabl..
JWT에 대한 이론은 https://sh970901.tistory.com/85 포스팅했으니 참고하도록 하자. 1. build.gradle에 JWT와 Security 관련 라이브러리를 추가해준다. //JWT 관련 implementation 'io.jsonwebtoken:jjwt-api:0.11.5' runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5' runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5' //Security 관련 implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.thymeleaf.extras:thymeleaf-ex..