Skip to content

Commit

Permalink
Merge pull request #265 from codesquad-members-2023-team6/dev
Browse files Browse the repository at this point in the history
Fix : Authentication 로그 추가 및 토큰에 유저 정보 삽입
  • Loading branch information
lvalentine6 committed Jun 1, 2023
2 parents c967ba5 + af4443f commit 21ea93a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
log.info("5. 인증 정보 저장 시작");
Authentication authentication = jwtService.getAuthentication(jwt);
SecurityContextHolder.getContext().setAuthentication(authentication);
log.info("6. Security에 인증 정보 저장 완료 : " + authentication.getName() + responseURI);
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
log.info("6. Security에 인증 정보 저장 완료 : " + authentication.getName());
log.info("현재 저장된 인증 정보 목록 : " + auth);
} else {
log.info("유효한 토큰이 없습니다. : " + responseURI);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class JwtService {

public String createToken(MemberDetail user) {
return Jwts.builder()
.setSubject("github_login_member")
.setSubject(user.getName())
.setHeaderParam("typ", "JWT")
.setExpiration(new Date(System.currentTimeMillis() + JWT_TOKEN_VALIDITY * 1000))
.claim("userprofile", user)
Expand All @@ -55,6 +55,8 @@ public Authentication getAuthentication(String token) {
.parseClaimsJws(token)
.getBody();

log.info("클레임 확인 : " + claims.get("userprofile"));

Collection<? extends GrantedAuthority> authorities =
Arrays.stream(claims.get("userprofile").toString().split(","))
.map(SimpleGrantedAuthority::new)
Expand Down

0 comments on commit 21ea93a

Please sign in to comment.