fix: cookie host
This commit is contained in:
4
Makefile
4
Makefile
@@ -4,4 +4,6 @@ VERSION := $(or $(VERSION),$(DEFAULT_VERSION))
|
|||||||
cmd:
|
cmd:
|
||||||
cd server && go build -ldflags "-w -X main.Version=$(VERSION)" -o '../build/server'
|
cd server && go build -ldflags "-w -X main.Version=$(VERSION)" -o '../build/server'
|
||||||
clean:
|
clean:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
|
test:
|
||||||
|
cd server && go test ./...
|
@@ -10,7 +10,7 @@ import (
|
|||||||
func SetCookie(gc *gin.Context, token string) {
|
func SetCookie(gc *gin.Context, token string) {
|
||||||
secure := true
|
secure := true
|
||||||
httpOnly := true
|
httpOnly := true
|
||||||
host := GetHostName(constants.AUTHORIZER_URL)
|
host := GetDomainName(constants.AUTHORIZER_URL)
|
||||||
|
|
||||||
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)
|
||||||
@@ -29,7 +29,7 @@ func DeleteCookie(gc *gin.Context) {
|
|||||||
secure := true
|
secure := true
|
||||||
httpOnly := true
|
httpOnly := true
|
||||||
|
|
||||||
host := GetHostName(constants.AUTHORIZER_URL)
|
host := GetDomainName(constants.AUTHORIZER_URL)
|
||||||
|
|
||||||
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)
|
||||||
|
@@ -17,7 +17,7 @@ func GetHostName(auth_url string) string {
|
|||||||
return host
|
return host
|
||||||
}
|
}
|
||||||
|
|
||||||
// function to get domain name
|
// GetDomainName function to get domain name
|
||||||
func GetDomainName(auth_url string) string {
|
func GetDomainName(auth_url string) string {
|
||||||
u, err := url.Parse(auth_url)
|
u, err := url.Parse(auth_url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user