1. 회원가입,로그인,로그아웃 기능 - auth.service const API_URL = "http://localhost:8080/api/auth/"; class AuthService { register(username, email, password) { return axios.post(API_URL + "signup", { username, email, password }); } } - spring boot 서버에 넘겨주기 위해 API_URL를 알맞게 설정하고 username, email, password를 값을 post를 보내준다. 이 때 통신을 하기 위해서 axios 썼다. 서버에서는 중복값 체크를 한다. login(username, password) { return axios .post(API_..
1. Controller 생성 - AuthController @CrossOrigin(origins = "*", maxAge = 3600) @RestController @RequestMapping("/api/auth") public class AuthController { ..... @PostMapping("/signin") public ResponseEntity authenticateUser(@Valid @RequestBody LoginRequest loginRequest) { Authentication authentication = authenticationManager.authenticate( new UsernamePasswordAuthenticationToken (loginRequest.getUse..
1. unauthorizedHandler 비인증 처리 - AuthEntryPointJwt @Component // 인증,인가 예외발생시 처리 public class AuthEntryPointJwt implements AuthenticationEntryPoint { private static final Logger logger = LoggerFactory.getLogger(AuthEntryPointJwt.class); @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletExceptio..
1. model 생성 - User @Data @Entity @Table(name = "users", uniqueConstraints = { @UniqueConstraint(columnNames = "username"), @UniqueConstraint(columnNames = "email") }) public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @NotBlank @Size(max = 20) private String username; @NotBlank @Size(max = 50) @Email private String email; @NotBlank @Size(max = 120) priva..