-
Notifications
You must be signed in to change notification settings - Fork 0
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
✨ implement refresh token #113
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f4d685d
:sparkles: implement login with refresh token
HaiSeong 46af48d
:sparkles: create token refresh api
HaiSeong d8cb2fc
:white_check_mark: add test code for restdocs
HaiSeong 802c76e
:bug: change static import
HaiSeong 3944945
Merge remote-tracking branch 'origin/be/dev' into be/feat/69
HaiSeong 774719d
:recycle: refactor with Duration
HaiSeong a5f2e44
:memo: add description summary on login controller test
HaiSeong de63d2e
:recycle: change method name and add api docs
HaiSeong 7f82641
:bug: fix duplicated authorization header bug
HaiSeong 156a5d9
:recycle: jwt pattern check test
HaiSeong 5f1cb4c
:recycle: improve test with random port
HaiSeong 406a25c
:sparkles: implement username check api
HaiSeong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...k/authentication/util/TokenExtractor.java → ...authentication/domain/TokenExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
backend/src/main/java/net/pengcook/authentication/domain/TokenPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package net.pengcook.authentication.domain; | ||
|
||
import net.pengcook.authentication.exception.JwtTokenException; | ||
|
||
public record TokenPayload( | ||
long userId, | ||
String email, | ||
TokenType tokenType | ||
) { | ||
|
||
public void validateAccessToken(String message) { | ||
if (tokenType != TokenType.ACCESS) { | ||
throw new JwtTokenException(message); | ||
} | ||
} | ||
|
||
public void validateRefreshToken(String message) { | ||
if (tokenType != TokenType.REFRESH) { | ||
throw new JwtTokenException(message); | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
backend/src/main/java/net/pengcook/authentication/domain/TokenType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package net.pengcook.authentication.domain; | ||
|
||
public enum TokenType { | ||
|
||
ACCESS, REFRESH, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
backend/src/main/java/net/pengcook/authentication/dto/TokenPayload.java
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
backend/src/main/java/net/pengcook/authentication/dto/TokenRefreshRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package net.pengcook.authentication.dto; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
|
||
public record TokenRefreshRequest(@NotBlank String refreshToken) { | ||
} |
7 changes: 7 additions & 0 deletions
7
backend/src/main/java/net/pengcook/authentication/dto/TokenRefreshResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package net.pengcook.authentication.dto; | ||
|
||
public record TokenRefreshResponse( | ||
String accessToken, | ||
String refreshToken | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
properties
에 코멘트 남겨놓은 것을 추가하면 여기에 타입으로long
이 아닌Duration
을 줄 수 있을 것 같아요!