Skip to content

Commit

Permalink
[BE] JWT 파싱에 Base64 URL Decoder 사용하도록 변경
Browse files Browse the repository at this point in the history
특정 JWT는 파싱 안되는 에러 있어서 수정

참고:
Base64 URL 안전 디코딩: 일반적인 Base64 디코딩 대신 Base64 URL 안전 디코딩을 사용해야 합니다. URL 안전 버전은 '+'와 '/' 문자 대신 '-'와 '_'를 사용합니다. Java의 java.util.Base64 유틸리티는 URL 안전 디코딩을 지원합니다.
  • Loading branch information
Jinwook94 committed Jan 30, 2024
1 parent 6fc86a9 commit d760210
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -83,8 +83,9 @@ public JwtVo parseToken(String token) {
try {
String[] jwtParts = token.split("\\.");
ObjectMapper mapper = new ObjectMapper();
JwtVo.Header header = mapper.readValue(Base64.getDecoder().decode(jwtParts[0]), JwtVo.Header.class);
JwtVo.Body body = mapper.readValue(Base64.getDecoder().decode(jwtParts[1]), JwtVo.Body.class);
Base64.Decoder decoder = Base64.getUrlDecoder();
JwtVo.Header header = mapper.readValue(decoder.decode(jwtParts[0]), JwtVo.Header.class);
JwtVo.Body body = mapper.readValue(decoder.decode(jwtParts[1]), JwtVo.Body.class);
return new JwtVo(header, body);
} catch (IOException | IllegalArgumentException e ) {
throw new TokenParseException(TOKEN_PARSING_FAIL, token, e);
Expand Down

0 comments on commit d760210

Please sign in to comment.