-
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.
π :: Api-v0.0.3
- Loading branch information
Showing
74 changed files
with
1,362 additions
and
313 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
45 changes: 45 additions & 0 deletions
45
DuDoong-Api/src/main/java/band/gosrock/api/auth/service/helper/CookieGenerateHelper.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,45 @@ | ||
package band.gosrock.api.auth.service.helper; | ||
|
||
|
||
import band.gosrock.api.auth.model.dto.response.TokenAndUserResponse; | ||
import band.gosrock.common.annotation.Helper; | ||
import java.util.Arrays; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.ResponseCookie; | ||
|
||
@Helper | ||
@RequiredArgsConstructor | ||
public class CookieGenerateHelper { | ||
private final Environment env; | ||
|
||
public HttpHeaders getTokenCookies(TokenAndUserResponse tokenAndUserResponse) { | ||
String[] activeProfiles = env.getActiveProfiles(); | ||
String sameSite = "None"; | ||
|
||
if (Arrays.stream(activeProfiles).toList().contains("prod")) { | ||
sameSite = "Strict"; | ||
} | ||
ResponseCookie accessToken = | ||
ResponseCookie.from("accessToken", tokenAndUserResponse.getAccessToken()) | ||
.path("/") | ||
.maxAge(tokenAndUserResponse.getAccessTokenAge()) | ||
.sameSite(sameSite) | ||
.httpOnly(true) | ||
.secure(true) | ||
.build(); | ||
ResponseCookie refreshToken = | ||
ResponseCookie.from("refreshToken", tokenAndUserResponse.getRefreshToken()) | ||
.path("/") | ||
.maxAge(tokenAndUserResponse.getRefreshTokenAge()) | ||
.sameSite(sameSite) | ||
.httpOnly(true) | ||
.secure(true) | ||
.build(); | ||
HttpHeaders httpHeaders = new HttpHeaders(); | ||
httpHeaders.add(HttpHeaders.SET_COOKIE, accessToken.toString()); | ||
httpHeaders.add(HttpHeaders.SET_COOKIE, refreshToken.toString()); | ||
return httpHeaders; | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
DuDoong-Api/src/main/java/band/gosrock/api/config/ExampleHolder.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,14 @@ | ||
package band.gosrock.api.config; | ||
|
||
|
||
import io.swagger.v3.oas.models.examples.Example; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class ExampleHolder { | ||
private Example holder; | ||
private String name; | ||
private int code; | ||
} |
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
22 changes: 22 additions & 0 deletions
22
DuDoong-Api/src/main/java/band/gosrock/api/example/docs/ExampleException2Docs.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 band.gosrock.api.example.docs; | ||
|
||
|
||
import band.gosrock.common.annotation.ExceptionDoc; | ||
import band.gosrock.common.annotation.ExplainError; | ||
import band.gosrock.common.exception.DuDoongCodeException; | ||
import band.gosrock.common.exception.InvalidTokenException; | ||
import band.gosrock.domain.domains.order.exception.InvalidOrderException; | ||
import band.gosrock.domain.domains.order.exception.OrderNotFoundException; | ||
|
||
@ExceptionDoc | ||
public class ExampleException2Docs { | ||
|
||
@ExplainError("μ΄μ©κ΅¬ μ μ©κ΅¬") | ||
public DuDoongCodeException μ μ μμλ = InvalidTokenException.EXCEPTION; | ||
|
||
@ExplainError("μ€λ λ«νμ΄λ") | ||
public DuDoongCodeException νκΈλλλ€ = OrderNotFoundException.EXCEPTION; | ||
|
||
@ExplainError("μΈλ°Έλ¦¬λ μ€λ") | ||
public DuDoongCodeException μ€λ₯κ°λ¬μλ = InvalidOrderException.EXCEPTION; | ||
} |
Oops, something went wrong.