-
Notifications
You must be signed in to change notification settings - Fork 0
[REFACTOR] Auth 도메인 리펙토링 #220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
93c3c3c
487fea6
3c299fa
1f08206
5339bf9
935ae97
65a2f05
859593c
a94e16f
6341418
e0776b3
04b2c0f
c0ccf24
01cd395
181848e
e1fa5f1
63301d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,4 +5,5 @@ | |
| @Data | ||
| public class ReissueRequest { | ||
| private String refreshToken; | ||
| private String accessToken; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package org.atdev.artrip.global.apipayload.code.status; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import org.atdev.artrip.global.apipayload.code.BaseErrorCode; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| public enum AuthError implements BaseErrorCode { | ||
|
|
||
| // Auth Errors | ||
| _UNSUPPORTED_SOCIAL_PROVIDER(HttpStatus.BAD_REQUEST, "AUTH400-UNSUPPORTED_PROVIDER", "지원하지 않는 소셜 로그인입니다."), | ||
| _SOCIAL_EMAIL_NOT_PROVIDED(HttpStatus.BAD_REQUEST, "AUTH400-EMAIL_NOT_PROVIDED", "소셜 로그인에서 이메일 정보를 제공받지 못했습니다."); | ||
|
|
||
| private final HttpStatus httpStatus; | ||
| private final String code; | ||
| private final String message; | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| import java.security.Key; | ||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
| import java.util.Date; | ||
|
|
||
| @Slf4j | ||
| @Component | ||
|
|
@@ -97,9 +98,24 @@ private Claims parseClaims(String accessToken) { | |
| } | ||
| } | ||
|
|
||
| //만료까지 남은시간 | ||
| public long getExpiration(String accessToken) { | ||
|
|
||
| try { | ||
| Claims claims = Jwts.parserBuilder() | ||
| .setSigningKey(key) | ||
| .build() | ||
| .parseClaimsJws(accessToken) | ||
| .getBody(); | ||
|
|
||
| long expirationTime = claims.getExpiration().getTime(); | ||
| long now = new Date().getTime(); | ||
|
|
||
| return (expirationTime - now); | ||
| } catch (ExpiredJwtException e){ | ||
| return 0; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 토큰이 만료되었다면 예외를 반환하는게 좋지 않을까요?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 로직은 로그아웃시 엑세스토큰 만료까지 남은 기간을 구하는 로직입니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. API에서 활용되는 부분이라면 예외가 맞을 것 같고 그게 아니라 단순 계산이라면 지금처럼 해도 될 것 같네요.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네 만료예외를 제외한 예외에는 에러처리를 하겠습니다 |
||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.