Skip to content

Commit

Permalink
#14 [Refactor] JwtAuth Filter HeaderUtil 사용하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
fanta4715 committed May 16, 2024
1 parent 2e6fcf9 commit 5e31b13
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import gdsc.comunity.security.info.UserPrincipal;
import gdsc.comunity.security.jwt.JwtProvider;
import gdsc.comunity.security.jwt.JwtVO;
import gdsc.comunity.util.HeaderUtil;
import io.jsonwebtoken.Claims;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
Expand All @@ -26,18 +27,13 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
String bearerToken = request.getHeader(JwtVO.HEADER);
String accessToken = HeaderUtil.extractToken(request, JwtVO.HEADER, JwtVO.TOKEN_PREFIX);

if (bearerToken == null) {
if (accessToken == null) {
filterChain.doFilter(request, response);
return;
}

if (!bearerToken.startsWith(JwtVO.TOKEN_PREFIX)) {
throw new CustomException(ErrorCode.INVALID_TOKEN_PREFIX_ERROR);
}

String accessToken = bearerToken.substring(7);
Claims claims;
try {
claims = jwtProvider.validateToken(accessToken);
Expand Down

0 comments on commit 5e31b13

Please sign in to comment.