Skip to content

Commit

Permalink
FEAT : SecurityUtil clearSecurityContext 메소드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
choidongkuen committed Oct 29, 2023
1 parent 7a90ff5 commit 6e916a3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class AuthService {
private final UserService userService;
private final OauthService oauthService;

@Transactional
/* jwt 만료시 access token 재발급 해주는 메소드 with 만료된 access token + refresh token */
@Transactional
public UserOauthLoginResponseDto accessTokenByRefreshToken(String accessToken, String refreshToken) {
// 1. refresh token 유효성
this.validationRefreshToken(refreshToken);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/example/howmuch/util/JwtService.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public String getPayLoad(String token) {
.getBody()
.getSubject();
} catch (ExpiredJwtException e) {
// accessToken 이 만료된 경우 또한 userId 반환
return e.getClaims().getSubject();
} catch (JwtException e) {
throw new UnauthorizedUserException("로그인이 필요합니다.");
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/example/howmuch/util/SecurityUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ public static Collection<GrantedAuthority> getUserNickname() {
= (UserAuthentication) SecurityContextHolder.getContext().getAuthentication();
return authentication.getAuthorities();
}

public static void clearSecurityContext() {
SecurityContextHolder.clearContext();
}
}

0 comments on commit 6e916a3

Please sign in to comment.