-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 회원가입 로그인 시 redirect 제거, samesite none 쿠키 제공 (#88)
* feat: 회원가입, 로그인 시 302 대싱 200 반환 * chore: apply ktlint * test: 302 -> 200 으로 변경하여 깨진 테스트 복구 * feat: 로그인 시 same site none 쿠키 발급
- Loading branch information
1 parent
a9a1f02
commit 363e256
Showing
6 changed files
with
26 additions
and
24 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
24 changes: 14 additions & 10 deletions
24
src/main/kotlin/com/celuveat/common/utils/CookieExtensions.kt
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 |
---|---|---|
@@ -1,21 +1,25 @@ | ||
package com.celuveat.common.utils | ||
|
||
import jakarta.servlet.http.Cookie | ||
import jakarta.servlet.http.HttpServletResponse | ||
import org.springframework.http.ResponseCookie | ||
|
||
inline fun HttpServletResponse.addSecureCookie( | ||
name: String, | ||
value: String, | ||
path: String = "/", | ||
maxAge: Int = -1, | ||
maxAge: Long = -1, | ||
isHttpOnly: Boolean = true, | ||
isSecure: Boolean = true | ||
isSecure: Boolean = true, | ||
sameSite: String = "Lex", | ||
) { | ||
val cookie = Cookie(name, value).apply { | ||
this.isHttpOnly = isHttpOnly | ||
this.secure = isSecure | ||
this.path = path | ||
this.maxAge = maxAge | ||
} | ||
this.addCookie(cookie) | ||
|
||
val cookie = ResponseCookie.from(name, value) | ||
.path(path) | ||
.sameSite(sameSite) | ||
.httpOnly(isHttpOnly) | ||
.secure(isSecure) | ||
.maxAge(maxAge) | ||
.build() | ||
|
||
this.addHeader("Set-Cookie", cookie.toString()) | ||
} |
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