-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refresh token 발급 및 access token 재발급 api 추가
[#815]
- Loading branch information
Showing
5 changed files
with
143 additions
and
5 deletions.
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
35 changes: 35 additions & 0 deletions
35
...ain/java/com/carffeine/carffeine/auth/controller/support/RefreshTokenCookieGenerator.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,35 @@ | ||
package com.carffeine.carffeine.auth.controller.support; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.http.ResponseCookie; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.Duration; | ||
|
||
@Component | ||
public class RefreshTokenCookieGenerator { | ||
|
||
private static final String REFRESH_TOKEN = "refreshToken"; | ||
private static final String VALID_COOKIE_PATH = "/"; | ||
private static final String LOGOUT_COOKIE_VALUE = ""; | ||
private static final int LOGOUT_COOKIE_AGE = 0; | ||
|
||
@Value("${jwt.refresh-token-expiration-period}") | ||
private long expireLength; | ||
|
||
public ResponseCookie createCookie(String refreshToken) { | ||
return ResponseCookie.from(REFRESH_TOKEN, refreshToken) | ||
.maxAge(Duration.ofMillis(expireLength)) | ||
.path(VALID_COOKIE_PATH) | ||
.secure(true) | ||
.httpOnly(true) | ||
.build(); | ||
} | ||
|
||
public ResponseCookie createLogoutCookie() { | ||
return ResponseCookie.from(REFRESH_TOKEN, LOGOUT_COOKIE_VALUE) | ||
.maxAge(LOGOUT_COOKIE_AGE) | ||
.build(); | ||
} | ||
|
||
} |
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