https://github.com/SilverNine/spring-boot-jwt-tutorial
Spring Boot JWT Tutorial (1) – JWT 소개, 프로젝트 생성
Spring Boot JWT Tutorial (2) – Security 기본 설정, Data 설정
Spring Boot JWT Tutorial (3) – JWT 코드, Security 설정 추가
Spring Boot JWT Tutorial (4) – Repository, 로그인
Spring Boot JWT Tutorial (5) – 회원가입, 권한검증
dto 패키지를 만들고 외부와의 데이터 통신에 사용할 3개의 클래스를 만들어 줍니다.
package me.silvernine.tutorial.dto;
import lombok.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class LoginDto {
@NotNull
@Size(min = 3, max = 50)
private String username;
@NotNull
@Size(min = 3, max = 100)
private String password;
}
package me.silvernine.tutorial.dto;
import lombok.*;
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TokenDto {
private String token;
}
package me.silvernine.tutorial.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class UserDto {
@NotNull
@Size(min = 3, max = 50)
private String username;
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
@NotNull
@Size(min = 3, max = 100)
private String password;
@NotNull
@Size(min = 3, max = 50)
private String nickname;
}