Spring Security2 [Spring security + Jwt #2] jwt 관리 클래스 생성 1. 관리 클래스 생성 @Slf4j @Component public class JwtProvider { private static final String JWT_SECRET_KEY = "사용할 비밀 키"; private static final int JWT_EXPIRATIONMS = 86400000; // ms 세컨드 단위로 사용 시간 설정 가능 합니다. // jwt 키 생성 여기서 지정된 값을 가지고 유저를 체크합니다. public String generateJwtToken(String name) { return Jwts.builder().setSubject(name).setIssuedAt(new Date()).setExpiration(new Date((new Date()).getTime() + JWT.. 2022. 2. 21. [Spring security + Jwt #1] Spring Security 설정하기 1. dependency 설정 org.springframework.boot spring-boot-starter-security io.jsonwebtoken jjwt 0.9.1 jwt 토큰이 session 처럼 기본 설정으로 적용된 것이 아니기 때문에 dependency를 따로 추가 해줘야 합니다. 2. Spring Security 설정 class 생성 @Configuration @EnableWebSecurity @AllArgsConstructor public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ... } @Configuration - 빈 등록 @EnableWebSecurity - Security class를 등록합니다. @All.. 2022. 2. 21. 이전 1 다음