File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed
kotlin/com/team/incube/gsmc/v3/global/common/cookie Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -30,3 +30,4 @@ JWT_REFRESH_TOKEN_SECRET=string
3030JWT_REFRESH_TOKEN_EXPIRATION = number
3131SPRINGDOC_ENABLED = boolean
3232SWAGGER_ENABLED = boolean
33+ SERVER_COOKIE_DOMAIN = string
Original file line number Diff line number Diff line change 11package com.team.incube.gsmc.v3.global.common.cookie
22
3+ import org.springframework.beans.factory.annotation.Value
34import org.springframework.core.env.Environment
45import org.springframework.http.ResponseCookie
56import org.springframework.stereotype.Component
@@ -13,6 +14,9 @@ class CookieUtil(
1314 companion object {
1415 private const val ACCESS_TOKEN_COOKIE_NAME = " accessToken"
1516 private const val REFRESH_TOKEN_COOKIE_NAME = " refreshToken"
17+
18+ @Value(" \$ {server.cookie.domain}" )
19+ private lateinit var cookieDomain: String
1620 }
1721
1822 private val isProduction: Boolean
@@ -30,7 +34,11 @@ class CookieUtil(
3034 .sameSite(" Strict" )
3135 .path(" /" )
3236 .maxAge(maxAge)
33- .build()
37+ .apply {
38+ if (isProduction) {
39+ domain(cookieDomain)
40+ }
41+ }.build()
3442
3543 fun createAuthCookies (
3644 accessToken : String ,
Original file line number Diff line number Diff line change @@ -83,6 +83,8 @@ spring:
8383server :
8484 port : ${SERVER_PORT:8080}
8585 shutdown : graceful
86+ cookie :
87+ domain : ${SERVER_COOKIE_DOMAIN:localhost}
8688management :
8789 endpoints :
8890 web :
You can’t perform that action at this time.
0 commit comments