Skip to content

Commit

Permalink
#31 [Update] header로 들어오는 토큰을 AuthToken으로 변환하는 로직 변경
Browse files Browse the repository at this point in the history
refresh token과 access token을 AuthToken으로 변환하는 로직 분리
  • Loading branch information
Anna-Jin committed Jul 23, 2022
1 parent 860a433 commit df665be
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/com/mpnp/baechelin/login/jwt/AuthTokenProvider.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mpnp.baechelin.login.jwt;

import com.mpnp.baechelin.login.jwt.exception.TokenValidFailedException;
import com.mpnp.baechelin.util.HeaderUtil;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.security.Keys;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -10,6 +11,7 @@
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;

import javax.servlet.http.HttpServletRequest;
import java.security.Key;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -37,11 +39,17 @@ public AuthToken createAuthToken(String id, String role, Date expiry) {
return new AuthToken(id, role, expiry, key);
}

// header 로 들어온 String 형태의 access token 을 AuthToken 형태로 변환
public AuthToken convertAuthToken(String token) {
// refresh token 을 AuthToken 형태로 변환
public AuthToken convertRefreshToken(String token) {
return new AuthToken(token, key);
}

// 요청값으로 들어온 request를 가지고 header에서 String 형태의 access token을 뽑아 AuthToken 형태로 변환
public AuthToken convertAccessToken(HttpServletRequest request) {
String accessToken = HeaderUtil.getAccessToken(request);
return new AuthToken(accessToken, key);
}


// 인증 객체 생성
public Authentication getAuthentication(AuthToken authToken) {
Expand Down

0 comments on commit df665be

Please sign in to comment.