fix: multi domain cookie if allowed
This commit is contained in:
@@ -10,10 +10,15 @@ import (
|
|||||||
func SetCookie(gc *gin.Context, token string) {
|
func SetCookie(gc *gin.Context, token string) {
|
||||||
secure := true
|
secure := true
|
||||||
httpOnly := true
|
httpOnly := true
|
||||||
host := GetDomainName(constants.AUTHORIZER_URL)
|
host := GetHostName(constants.AUTHORIZER_URL)
|
||||||
|
domain := GetDomainName(constants.AUTHORIZER_URL)
|
||||||
|
if domain != "localhost" {
|
||||||
|
domain = "." + domain
|
||||||
|
}
|
||||||
|
|
||||||
gc.SetSameSite(http.SameSiteNoneMode)
|
gc.SetSameSite(http.SameSiteNoneMode)
|
||||||
gc.SetCookie(constants.COOKIE_NAME, token, 3600, "/", host, secure, httpOnly)
|
gc.SetCookie(constants.COOKIE_NAME, token, 3600, "/", host, secure, httpOnly)
|
||||||
|
gc.SetCookie(constants.COOKIE_NAME+"-client", token, 3600, "/", domain, secure, httpOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCookie(gc *gin.Context) (string, error) {
|
func GetCookie(gc *gin.Context) (string, error) {
|
||||||
@@ -30,7 +35,12 @@ func DeleteCookie(gc *gin.Context) {
|
|||||||
httpOnly := true
|
httpOnly := true
|
||||||
|
|
||||||
host := GetDomainName(constants.AUTHORIZER_URL)
|
host := GetDomainName(constants.AUTHORIZER_URL)
|
||||||
|
domain := GetDomainName(constants.AUTHORIZER_URL)
|
||||||
|
if domain != "localhost" {
|
||||||
|
domain = "." + domain
|
||||||
|
}
|
||||||
|
|
||||||
gc.SetSameSite(http.SameSiteNoneMode)
|
gc.SetSameSite(http.SameSiteNoneMode)
|
||||||
gc.SetCookie(constants.COOKIE_NAME, "", -1, "/", host, secure, httpOnly)
|
gc.SetCookie(constants.COOKIE_NAME, "", -1, "/", host, secure, httpOnly)
|
||||||
|
gc.SetCookie(constants.COOKIE_NAME+"-client", "", -1, "/", domain, secure, httpOnly)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user